Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ftdetect/gofiletype.vim so that it _only_ sets filetype; it no longer sets fileformat or fileencoding. fileformat and fileencoding are now set by autocmd events configured in plugin/go.vim Move most functions called by autocmd events into autoload/go/auto.vim. The only exceptions are s:gofiletype_pre and s:gofiletype_post in plugin/go.vim. Consistently use `setfiletype`; previously `set filetype` was used for gohtmltmpl and gomod files. Change s:gofiletype_pre in plugin/go.vim so that it does not set the filetype; it's already set in ftdetect/go.vim and setting it again may cause problems for any user that needs to set it to something else. Move the configuration of all autocmd events that occur after the FileType event into ftplugin files and clear them in undo_ftplugin so that they will not execute if the filetype is changed.
- Loading branch information
Showing
6 changed files
with
168 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
" don't spam the user when Vim is started in Vi compatibility mode | ||
let s:cpo_save = &cpo | ||
set cpo&vim | ||
|
||
function! go#auto#template_autocreate() | ||
" create new template from scratch | ||
if get(g:, "go_template_autocreate", 1) && &modifiable | ||
call go#template#create() | ||
endif | ||
endfunction | ||
|
||
function! go#auto#echo_go_info() | ||
if !get(g:, "go_echo_go_info", 1) | ||
return | ||
endif | ||
|
||
if !exists('v:completed_item') || empty(v:completed_item) | ||
return | ||
endif | ||
let item = v:completed_item | ||
|
||
if !has_key(item, "info") | ||
return | ||
endif | ||
|
||
if empty(item.info) | ||
return | ||
endif | ||
|
||
redraws! | echo "vim-go: " | echohl Function | echon item.info | echohl None | ||
endfunction | ||
|
||
function! go#auto#auto_type_info() | ||
" GoInfo automatic update | ||
if get(g:, "go_auto_type_info", 0) | ||
call go#tool#Info(0) | ||
endif | ||
endfunction | ||
|
||
function! go#auto#auto_sameids() | ||
" GoSameId automatic update | ||
if get(g:, "go_auto_sameids", 0) | ||
call go#guru#SameIds(0) | ||
endif | ||
endfunction | ||
|
||
function! go#auto#fmt_autosave() | ||
" Go code formatting on save | ||
if get(g:, "go_fmt_autosave", 1) | ||
call go#fmt#Format(-1) | ||
endif | ||
endfunction | ||
|
||
function! go#auto#metalinter_autosave() | ||
" run gometalinter on save | ||
if get(g:, "go_metalinter_autosave", 0) | ||
call go#lint#Gometa(0, 1) | ||
endif | ||
endfunction | ||
|
||
function! go#auto#modfmt_autosave() | ||
" go.mod code formatting on save | ||
if get(g:, "go_mod_fmt_autosave", 1) | ||
call go#mod#Format() | ||
endif | ||
endfunction | ||
|
||
function! go#auto#asmfmt_autosave() | ||
" Go asm formatting on save | ||
if get(g:, "go_asmfmt_autosave", 0) | ||
call go#asmfmt#Format() | ||
endif | ||
endfunction | ||
|
||
" restore Vi compatibility settings | ||
let &cpo = s:cpo_save | ||
unlet s:cpo_save | ||
|
||
" vim: sw=2 ts=2 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters