From ac577df9f6516308c2f9661c8abbc44f6c19d854 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 8 Nov 2017 11:57:21 +1300 Subject: 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. --- vim/after/syntax/sh.vim | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'vim/after/syntax') 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 endif " Some corrections for highlighting if we have any of POSIX, Bash, or Ksh -- cgit v1.2.3