Skip to content

Commit

Permalink
improvement(ansible): better filetype detection logic in .vimrc.local
Browse files Browse the repository at this point in the history
  • Loading branch information
midchildan committed Sep 1, 2024
1 parent dc2dfe1 commit 6c42706
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ansible/.vimrc.local
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ if exists('g:did_load_vimrc_local_0af878c')
finish
endif

func! s:setfiletype()
if stridx(expand('%:p:h'), expand('<script>:p:h')) == 0
set filetype=yaml.ansible
endif
endf

augroup filetypedetect
au! BufNewFile,BufRead */ansible/*.yml set filetype=yaml.ansible
au! BufNewFile,BufRead *.yml call s:setfiletype()
augroup END

filetype detect
Expand Down

0 comments on commit 6c42706

Please sign in to comment.