" We take care to preserve the user's fileencodings and fileformats,
" because those settings are global (not buffer local), yet we want
" to override them for loading Go files, which are defined to be UTF-8.
let s:current_fileformats = ''
let s:current_fileencodings = ''

" define fileencodings to open as utf-8 encoding even if it's ascii.
function! s:gofiletype_pre()
  let s:current_fileformats = &g:fileformats
  let s:current_fileencodings = &g:fileencodings
  set fileencodings=utf-8 fileformats=unix
  setlocal filetype=go
endfunction

" restore fileencodings as others
function! s:gofiletype_post()
  let &g:fileformats = s:current_fileformats
  let &g:fileencodings = s:current_fileencodings
endfunction

au BufNewFile *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix
au BufRead *.go call s:gofiletype_pre()
au BufReadPost *.go call s:gofiletype_post()

" We take care to preserve the user's fileencodings and fileformats,
" because those settings are global (not buffer local), yet we want
" to override them for loading Go files, which are defined to be UTF-8.
let s:current_fileformats = ''
let s:current_fileencodings = ''

" define fileencodings to open as utf-8 encoding even if it's ascii.
function! s:gofiletype_pre()
  let s:current_fileformats = &g:fileformats
  let s:current_fileencodings = &g:fileencodings
  set fileencodings=utf-8 fileformats=unix
  setlocal filetype=go
endfunction

" restore fileencodings as others
function! s:gofiletype_post()
  let &g:fileformats = s:current_fileformats
  let &g:fileencodings = s:current_fileencodings
endfunction

au BufNewFile *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix
au BufRead *.go call s:gofiletype_pre()
au BufReadPost *.go call s:gofiletype_post()

au BufRead,BufNewFile *.tmpl set filetype=gohtmltmpl


Set .tmpl files' syntax to gohtmltmpl.
Set .tmpl files' syntax to gohtmltmpl.

mizoR/vim-go,nowk/vim-go,glittershark/vim-go,emmagras/vim-go,ev46/vim-go,vim-IDE/vim-go,t-yuki/vim-go,rxwen/vim-go,andviro/vim-go,hiteshjoshi/vim-go,phemmer/vim-go,wingyplus/vim-go,vashstorm/vim-go,youleiy/vim-go,lioonline/vim-go,vim-IDE/vim-go,DrGo/vim-go,vim-IDE/vim-go,mechmind/vim-go,apriendeau/vim-go,jacobxk/vim-go,shaunstanislaus/vim-go,syohex/vim-go,mrnugget/vim-go,wheelcomplex/vim-go,andviro/vim-go,cjqian/vim-go,ebfe/vim-go,prodis/vim-go,marcosnils/vim-go