@@ -0,0 +1,56 @@
1+#compdef bat
2+# FIXME: help me with the subcommand `cache`, zsh completion is hard as hell
3+
4+local -a args
5+local state
6+
7+args=(
8+ '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
9+ {-p,--plain}'[Show plain style (alias for `--style=plain`)]:When `-p` is used twice (`-pp`), it also disables automatic paging (alias for `--style=plain --paging=never`)'
10+ '(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language'
11+ '(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N:M>...'
12+ '(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files'
13+ '(-d --diff)'--diff'[Only show lines that have been added/removed/modified]'
14+ '(--diff-context)'--diff-context'[Include N lines of context around added/removed/modified lines when using `--diff`]:<N> (lines):()'
15+ '(--tabs)'--tabs'[Set the tab width to T spaces]:<T> (tab width):()'
16+ '(--wrap)'--wrap='[Specify the text-wrapping mode]:<when>:(auto never character)'
17+ '(--terminal-width)'--terminal-width'[Explicitly set the width of the terminal instead of determining it automatically]:<width>'
18+ '(-n --number)'{-n,--number}'[Show line numbers]'
19+ '(--color)'--color='[When to use colors]:<when>:(auto never always)'
20+ '(--italic-text)'--italic-text='[Use italics in output]:<when>:(always never)'
21+ '(--decorations)'--decorations='[When to show the decorations]:<when>:(auto never always)'
22+ '(--paging)'--paging='[Specify when to use the pager]:<when>:(auto never always)'
23+ '(-m --map-syntax)'{-m+,--map-syntax=}'[Use the specified syntax for files matching the glob pattern]:<glob:syntax>...'
24+ '(--theme)'--theme='[Set the color theme for syntax highlighting]:<theme>:->theme'
25+ '(: --list-themes --list-languages -L)'--list-themes'[Display all supported highlighting themes]'
26+ '(--style)'--style='[Comma-separated list of style elements to display]:<components>:->style'
27+ '(-r --line-range)'{-r+,--line-range=}'[Only print the lines from N to M]:<N:M>...'
28+ '(: --list-themes --list-languages -L)'{-L,--list-languages}'[Display all supported languages]'
29+ '(: -)'{-h,--help}'[Print this help message]'
30+ '(: -)'{-V,--version}'[Show version information]'
31+ '*: :_files'
32+)
33+
34+_arguments -S -s $args
35+
36+case "$state" in
37+ language)
38+ local IFS=$'\n'
39+ local -a languages
40+ languages=( $(bat --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
41+
42+ _describe 'language' languages
43+ ;;
44+
45+ theme)
46+ local IFS=$'\n'
47+ local -a themes
48+ themes=( $(bat --list-themes | sort) )
49+
50+ _values 'theme' $themes
51+ ;;
52+
53+ style)
54+ _values -s , 'style' auto full plain changes header grid numbers snip
55+ ;;
56+esac