diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-11 16:22:36 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-11 16:38:45 +1300 |
commit | 52615f646626e93a1560d3bcebcdf122f246e59a (patch) | |
tree | 67c0c349b2998459588a9e96ff9814827ece5719 /vim/after/syntax/sh.vim | |
parent | Disable sh error syntax highlighting for now (diff) | |
download | dotfiles-52615f646626e93a1560d3bcebcdf122f246e59a.tar.gz dotfiles-52615f646626e93a1560d3bcebcdf122f246e59a.zip |
Still untangling the shell highlighting mess
Diffstat (limited to 'vim/after/syntax/sh.vim')
-rw-r--r-- | vim/after/syntax/sh.vim | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim new file mode 100644 index 00000000..e8b41ba4 --- /dev/null +++ b/vim/after/syntax/sh.vim @@ -0,0 +1,98 @@ +" If g:is_posix is set, g:is_kornshell is probably set too, a strange decision +" by sh.vim. No matter; we can tease out whether this is actually a Korn shell +" script using our own b:is_ksh flag set at the end of +" ~/.vim/after/ftdetect/sh.vim, and if it isn't, we'll throw away the +" highlighting groups for ksh. +if exists('g:is_posix') && exists('g:is_kornshell') && !exists('b:is_ksh') + syntax clear kshSpecialVariables + syntax clear kshStatement +endif + +" Some corrections for highlighting if we have any of POSIX, Bash, or Ksh +if exists('g:is_posix') || exists('b:is_bash') || exists('b:is_ksh') + + " The syntax highlighter seems to flag '/baz' in '"${foo:-"$bar"/baz}"' as an + " error, and I'm pretty sure it's not, at least in POSIX sh, Bash, and Ksh. + syntax clear shDerefWordError + + " The syntax highlighter doesn't match parens for subshells for 'if' tests + " correctly if they're on separate lines. This happens enough that it's + " probably not worth keeping the error. + syntax clear shParenError + +endif + +" Some corrections for highlighting specific to the Bash mode +if exists('b:is_bash') + + " I don't like bashAdminStatement; these are not keywords, they're just + " strings for init scripts. + syntax clear bashAdminStatement + + " Reduce bashStatement down to just builtins; highlighting 'grep' is not + " very useful. This list was taken from `compgen -A helptopic` on Bash + " 4.4.5. + syntax clear bashStatement + syntax keyword bashStatement + \ . + \ : + \ alias + \ bg + \ bind + \ break + \ builtin + \ caller + \ cd + \ command + \ compgen + \ complete + \ compopt + \ continue + \ coproc + \ dirs + \ disown + \ echo + \ enable + \ eval + \ exec + \ exit + \ false + \ fc + \ fg + \ function + \ getopts + \ hash + \ help + \ history + \ jobs + \ kill + \ let + \ logout + \ mapfile + \ popd + \ printf + \ pushd + \ pwd + \ read + \ readarray + \ readonly + \ return + \ select + \ set + \ shift + \ shopt + \ source + \ suspend + \ test + \ time + \ times + \ trap + \ true + \ type + \ ulimit + \ umask + \ unalias + \ until + \ variables + \ wait +endif |