diff options
Diffstat (limited to 'vim')
-rw-r--r-- | vim/after/syntax/sh.vim | 7 | ||||
-rw-r--r-- | vim/ftdetect/sh.vim | 9 | ||||
-rw-r--r-- | vim/ftplugin/sh.vim | 23 |
3 files changed, 23 insertions, 16 deletions
diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim index b9a1a66f..9da1095d 100644 --- a/vim/after/syntax/sh.vim +++ b/vim/after/syntax/sh.vim @@ -1,8 +1,9 @@ " 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_posix') && exists('g:is_kornshell') && !exists('b:is_ksh') +" script using our own b:is_kornshell_proper 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 endif diff --git a/vim/ftdetect/sh.vim b/vim/ftdetect/sh.vim index 236f329c..8b4c10d3 100644 --- a/vim/ftdetect/sh.vim +++ b/vim/ftdetect/sh.vim @@ -20,13 +20,4 @@ augroup dfsh \ let b:is_posix = 1 | \ setfiletype sh - " If we determined something is b:is_kornshell, tack on b:is_ksh as well so - " we can still tease out what is actually a kornshell script after sh.vim is - " done changing our options for us; it conflates POSIX with Korn shell. - autocmd BufNewFile,BufRead - \ * - \ if exists('b:is_kornshell') | - \ let b:is_ksh = 1 | - \ endif - augroup END diff --git a/vim/ftplugin/sh.vim b/vim/ftplugin/sh.vim index 2b73611e..a6dd62eb 100644 --- a/vim/ftplugin/sh.vim +++ b/vim/ftplugin/sh.vim @@ -1,10 +1,25 @@ " Default to POSIX shell, as I never write Bourne, and if I write Bash or Ksh -" it'll be denoted with either a shebang or an appropriate extension. At the -" time of writing, changing this also prompts sh.vim to set g:is_kornshell, -" which is absurd, and requires a bit more massaging in after/syntax/sh.vim to -" turn off some unwanted stuff. +" it'll be denoted with either a shebang or an appropriate extension. let g:is_posix = 1 +" +" Setting g:is_posix above also prompts Vim's core syntax/sh.vim script to +" set g:is_kornshell and thereby b:is_kornshell to the same value as g:is_posix. +" +" That's very confusing, so before it happens we'll copy b:is_kornshell's +" value as determined by filetype.vim and ~/.vim/ftdetect/sh.vim into a custom +" variable b:is_ksh, before its meaning gets confused. +" +" b:is_ksh as a name is more inline with b:is_bash and b:is_sh, anyway, so +" we'll just treat b:is_kornshell like it's both misnamed and broken. +" +" We can then switch on our custom variable in ~/.vim/after/syntax/sh.vim to +" apply settings that actually *are* unique to Korn shell and its derivatives. +" +if exists('b:is_kornshell') + let b:is_ksh = b:is_kornshell +endif + " Use han(1df) as a man(1) wrapper for Bash files if available if exists('b:is_bash') && executable('han') setlocal keywordprg=han |