diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 14:34:19 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 14:34:19 +1300 |
commit | 71acc00c5b688cc42e3d13881d1c6c9436335066 (patch) | |
tree | 1d41dd2d07c16f0cf3fc4e35f12bba95044d8066 | |
parent | Use consistent long-line indent (diff) | |
download | dotfiles-71acc00c5b688cc42e3d13881d1c6c9436335066.tar.gz dotfiles-71acc00c5b688cc42e3d13881d1c6c9436335066.zip |
Use :setfiletype in lieu of :setlocal filetype=
Use this recommended syntax in the custom ftplugin settings.
Seems to be the recommended way to set filetype idempotently, and is
present even in very old Vim (6.2 tested).
From the Vim documentation for :setfiletype:
>Set the 'filetype' option to {filetype}, but only if not done yet in a
>sequence of (nested) autocommands. This is short for:
> :if !did_filetype()
> : setlocal filetype={filetype}
> :endif
>This command is used in a filetype.vim file to avoid setting the
>'filetype' option twice, causing different settings and syntax files to
>be loaded.
-rw-r--r-- | vim/ftdetect/muttrc.vim | 2 | ||||
-rw-r--r-- | vim/ftdetect/sh.vim | 6 | ||||
-rw-r--r-- | vim/ftdetect/xdefaults.vim | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/vim/ftdetect/muttrc.vim b/vim/ftdetect/muttrc.vim index b54efd76..2ef72309 100644 --- a/vim/ftdetect/muttrc.vim +++ b/vim/ftdetect/muttrc.vim @@ -3,5 +3,5 @@ augroup dfmuttrc autocmd! autocmd BufNewFile,BufRead \ **/.dotfiles/mutt/muttrc.d/*.rc,**/.muttrc.d/*.rc - \ setlocal filetype=muttrc + \ setfiletype muttrc augroup END diff --git a/vim/ftdetect/sh.vim b/vim/ftdetect/sh.vim index dce776cf..236f329c 100644 --- a/vim/ftdetect/sh.vim +++ b/vim/ftdetect/sh.vim @@ -6,19 +6,19 @@ augroup dfsh autocmd BufNewFile,BufRead \ **/.dotfiles/bash/**,bash-fc-* \ let b:is_bash = 1 | - \ setlocal filetype=sh + \ setfiletype sh " Names/paths of things that are Korn shell script autocmd BufNewFile,BufRead \ **/.dotfiles/ksh/**,.kshrc,*.ksh \ let b:is_kornshell = 1 | - \ setlocal filetype=sh + \ setfiletype sh " Names/paths of things that are POSIX shell script autocmd BufNewFile,BufRead \ **/.dotfiles/sh/**,.shinit,.shrc,.xinitrc,/etc/default/* \ let b:is_posix = 1 | - \ setlocal filetype=sh + \ 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 diff --git a/vim/ftdetect/xdefaults.vim b/vim/ftdetect/xdefaults.vim index 2d4c6738..589f0dfc 100644 --- a/vim/ftdetect/xdefaults.vim +++ b/vim/ftdetect/xdefaults.vim @@ -3,5 +3,5 @@ augroup dfxdefaults autocmd! autocmd BufNewFile,BufRead \ **/.Xresources.d/* - \ setlocal filetype=xdefaults + \ setfiletype xdefaults augroup END |