1
0
Fork 0
mirror of synced 2024-06-27 19:21:10 -04:00
ultimate-vim/sources_non_forked/vim-go/ftdetect/gofiletype.vim

41 lines
1 KiB
VimL
Raw Normal View History

2018-02-04 06:35:08 -05:00
" vint: -ProhibitAutocmdWithNoGroup
2018-12-17 06:28:27 -05:00
" don't spam the user when Vim is started in Vi compatibility mode
let s:cpo_save = &cpo
set cpo&vim
2018-02-04 06:35:08 -05:00
" Note: should not use augroup in ftdetect (see :help ftdetect)
2019-03-08 06:04:56 -05:00
au BufRead,BufNewFile *.go setfiletype go
au BufRead,BufNewFile *.s setfiletype asm
au BufRead,BufNewFile *.tmpl setfiletype gohtmltmpl
2015-07-13 06:22:46 -04:00
2018-11-01 06:03:42 -04:00
" remove the autocommands for modsim3, and lprolog files so that their
" highlight groups, syntax, etc. will not be loaded. *.MOD is included, so
" that on case insensitive file systems the module2 autocmds will not be
" executed.
2019-03-08 06:04:56 -05:00
au! BufRead,BufNewFile *.mod,*.MOD
2018-09-24 20:40:17 -04:00
" Set the filetype if the first non-comment and non-blank line starts with
" 'module <path>'.
2019-03-08 06:04:56 -05:00
au BufRead,BufNewFile go.mod call s:gomod()
2018-09-24 20:40:17 -04:00
fun! s:gomod()
for l:i in range(1, line('$'))
let l:l = getline(l:i)
if l:l ==# '' || l:l[:1] ==# '//'
continue
endif
if l:l =~# '^module .\+'
2019-03-08 06:04:56 -05:00
setfiletype gomod
2018-09-24 20:40:17 -04:00
endif
break
endfor
endfun
2018-12-17 06:28:27 -05:00
" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
2016-06-26 07:12:36 -04:00
" vim: sw=2 ts=2 et