Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: tools/vim/mojom/ftdetect/mojomfiletype.vim

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/vim/filetypes.vim ('k') | tools/vim/mojom/indent/mojom.vim » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/vim/mojom/ftdetect/mojomfiletype.vim
diff --git a/tools/vim/mojom/ftdetect/mojomfiletype.vim b/tools/vim/mojom/ftdetect/mojomfiletype.vim
new file mode 100644
index 0000000000000000000000000000000000000000..3fda0b4aac1d8d54d3167e14f127f282c1f24aeb
--- /dev/null
+++ b/tools/vim/mojom/ftdetect/mojomfiletype.vim
@@ -0,0 +1,27 @@
+" Copyright 2015 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 mojom 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:mojomfiletype_pre()
+ let s:current_fileformats = &g:fileformats
+ let s:current_fileencodings = &g:fileencodings
+ set fileencodings=utf-8 fileformats=unix
+ setlocal filetype=mojom
+endfunction
+
+" restore fileencodings as others
+function! s:mojomfiletype_post()
+ let &g:fileformats = s:current_fileformats
+ let &g:fileencodings = s:current_fileencodings
+endfunction
+
+au BufNewFile *.mojom setlocal filetype=mojom fileencoding=utf-8 fileformat=unix
+au BufRead *.mojom call s:mojomfiletype_pre()
+au BufReadPost *.mojom call s:mojomfiletype_post()
« no previous file with comments | « tools/vim/filetypes.vim ('k') | tools/vim/mojom/indent/mojom.vim » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698