| Index: tools/gn/misc/vim/ftdetect/gnfiletype.vim
|
| diff --git a/tools/gn/misc/vim/ftdetect/gnfiletype.vim b/tools/gn/misc/vim/ftdetect/gnfiletype.vim
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d7bf55cc1287c4deb21bf7b2b98eca3def8b6555
|
| --- /dev/null
|
| +++ b/tools/gn/misc/vim/ftdetect/gnfiletype.vim
|
| @@ -0,0 +1,27 @@
|
| +" Copyright 2014 The Chromium Authors. All rights reserved.
|
| +" Use of this source code is governed by a BSD-style license that can be
|
| +" found in the LICENSE file.
|
| +
|
| +" 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 GN files, which should 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:gnfiletype_pre()
|
| + let s:current_fileformats = &g:fileformats
|
| + let s:current_fileencodings = &g:fileencodings
|
| + set fileencodings=utf-8 fileformats=unix
|
| + setlocal filetype=gn
|
| +endfunction
|
| +
|
| +" restore fileencodings as others
|
| +function! s:gnfiletype_post()
|
| + let &g:fileformats = s:current_fileformats
|
| + let &g:fileencodings = s:current_fileencodings
|
| +endfunction
|
| +
|
| +au BufNewFile *.gn setlocal filetype=gn fileencoding=utf-8 fileformat=unix
|
| +au BufRead *.gn call s:gnfiletype_pre()
|
| +au BufReadPost *.gn call s:gnfiletype_post()
|
|
|