Skip to content

Commit 653cc4d

Browse files
jparisejbodah
authored andcommitted
Use 'setfiletype' to set local &filetype (#473)
'setfiletype' is nice in these cases because it prevents &filetype from being set redundantly. Note that the Vim runtime ships with a filetype match for *.ex (for Euphoria), but our plugin-based filetype detection still gets the last say. Also, use 'setlocal' when setting &filetype in the shebang detection path. We don't want to use 'setfiletype' here because it's possible we need to override an existing syntax assignment, and we already guard against setting &filetype to 'elixir' twice.
1 parent 9b466fd commit 653cc4d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ftdetect/elixir.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
2-
au BufRead,BufNewFile *.eex set filetype=eelixir
1+
au BufRead,BufNewFile *.ex,*.exs setfiletype elixir
2+
au BufRead,BufNewFile *.eex setfiletype eelixir
33
au BufRead,BufNewFile * call s:DetectElixir()
44

55
function! s:DetectElixir()
66
if &filetype !=# 'elixir' && getline(1) =~# '^#!.*\<elixir\>'
7-
set filetype=elixir
7+
setlocal filetype=elixir
88
endif
99
endfunction

0 commit comments

Comments
 (0)