OLD | NEW |
(Empty) | |
| 1 " Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 " Use of this source code is governed by a BSD-style license that can be |
| 3 " found in the LICENSE file. |
| 4 " We take care to preserve the user's fileencodings and fileformats, |
| 5 " because those settings are global (not buffer local), yet we want |
| 6 " to override them for loading mojom files, which should be UTF-8. |
| 7 " |
| 8 let s:current_fileformats = '' |
| 9 let s:current_fileencodings = '' |
| 10 |
| 11 " define fileencodings to open as utf-8 encoding even if it's ascii. |
| 12 function! s:mojomfiletype_pre() |
| 13 let s:current_fileformats = &g:fileformats |
| 14 let s:current_fileencodings = &g:fileencodings |
| 15 set fileencodings=utf-8 fileformats=unix |
| 16 setlocal filetype=mojom |
| 17 endfunction |
| 18 |
| 19 " restore fileencodings as others |
| 20 function! s:mojomfiletype_post() |
| 21 let &g:fileformats = s:current_fileformats |
| 22 let &g:fileencodings = s:current_fileencodings |
| 23 endfunction |
| 24 |
| 25 au BufNewFile *.mojom setlocal filetype=mojom fileencoding=utf-8 fileformat=unix |
| 26 au BufRead *.mojom call s:mojomfiletype_pre() |
| 27 au BufReadPost *.mojom call s:mojomfiletype_post() |
OLD | NEW |