path: root/vim/after/syntax
diff options
authorTom Ryder <tom@sanctum.geek.nz>2017-11-08 11:57:21 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-08 12:44:59 +1300
commitac577df9f6516308c2f9661c8abbc44f6c19d854 (patch)
tree5dbb56b651377ac9745d140491e01f6a47cc991f /vim/after/syntax
parentMerge branch 'hotfix/v0.11.1' into develop (diff)
Use sh.vim local vars not global POSIX hacks
Rather than setting g:is_posix and working around core syntax/sh.vim's ideas about Korn and POSIX shells, forego sh.vim's efforts to guess what shell the system /bin/sh is entirely. It's irrelevant to me anyway, since I'll often be writing shell scripts to run on an entirely different system. Instead, if we have a #!/bin/sh shebang reflected in the b:is_sh variable set by core filetype.vim, and we don't have any other buffer-level indication of what shell this is, assume it's POSIX, because I very rarely write Bourne. Then, after the syntax file is loaded, clear away all but one of the resulting b:is_* variables. I have a feeling this is going to end with me re-implementing this syntax file, possibly as separate sh.vim, bash.vim, and ksh.vim files.
Diffstat (limited to 'vim/after/syntax')
1 files changed, 9 insertions, 7 deletions
diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim
index d07f4cff..930255fc 100644
--- a/vim/after/syntax/sh.vim
+++ b/vim/after/syntax/sh.vim
@@ -1,10 +1,12 @@
-" 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/ftdetect/sh.vim,
-" and if it isn't, we'll throw away the highlighting groups for ksh.
-if exists('g:is_kornshell') && !exists('b:is_ksh')
- syntax clear kshSpecialVariables
- syntax clear kshStatement
+" If we know we have another shell type, clear away the others completely, now
+" that core syntax/sh.vim is done prodding /bin/sh to determine the system
+" shell type (which I don't care about).
+if exists('b:is_bash')
+ unlet! b:is_sh b:is_posix b:is_kornshell
+elseif exists('b:is_kornshell')
+ unlet! b:is_sh b:is_posix
+elseif exists('b:is_posix')
+ unlet! b:is_sh
" Some corrections for highlighting if we have any of POSIX, Bash, or Ksh