diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 15:54:40 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 16:01:54 +1300 |
commit | e36efd4f542a24fadf689b82418f94f57dd01f1e (patch) | |
tree | 692f04014d9c75e1b92db55d15c330f67187e565 /vim/ftplugin | |
parent | Correct a path in vim/after/syntax/sh.vim (diff) | |
download | dotfiles-e36efd4f542a24fadf689b82418f94f57dd01f1e.tar.gz dotfiles-e36efd4f542a24fadf689b82418f94f57dd01f1e.zip |
Rearrange and better explain ksh syntax workaround
Move the rule setting the custom b:is_ksh variable used for this
workaround (established in 52615f6) into an ftplugin file, rather than
into ftdetect; the latter seems a much more appropriate place since by
this point we've definitely decided the file type is "sh".
From the revised comment in this changeset:
>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.
Diffstat (limited to 'vim/ftplugin')
-rw-r--r-- | vim/ftplugin/sh.vim | 23 |
1 files changed, 19 insertions, 4 deletions
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 |