diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-02-03 11:58:44 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-02-11 19:03:26 +0100 |
commit | 16a416836464d64f3054aeb727c773ebe5ac7124 (patch) | |
tree | d7e864311f02ed253e46a796bca4cb45036866b2 /runtime | |
parent | a1ee06a0993ef8959cdcec61759b17aa68ee28bd (diff) | |
download | rneovim-16a416836464d64f3054aeb727c773ebe5ac7124.tar.gz rneovim-16a416836464d64f3054aeb727c773ebe5ac7124.tar.bz2 rneovim-16a416836464d64f3054aeb727c773ebe5ac7124.zip |
vim-patch:8.0.0613: the conf filetype is used before ftdetect from packages
Problem: The conf filetype detection is done before ftdetect scripts from
packages that are added later.
Solution: Add the FALLBACK argument to :setfiletype. (closes vim/vim#1679,
closes vim/vim#1693)
https://github.com/vim/vim/commit/3e54569b17683318e0cb6693ab0024c2ad1e3e8f
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/filetype.vim | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 76f76af345..90b4fdaa74 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1183,14 +1183,21 @@ au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown " Mason au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason -" Matlab or Objective C +" Mathematica, Matlab, Murphi or Objective C au BufNewFile,BufRead *.m call s:FTm() func! s:FTm() let n = 1 - while n < 10 + let saw_comment = 0 " Whether we've seen a multiline comment leader. + while n < 100 let line = getline(n) - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\|//\)' + if line =~ '^\s*/\*' + " /* ... */ is a comment in Objective C and Murphi, so we can't conclude + " it's either of them yet, but track this as a hint in case we don't see + " anything more definitive. + let saw_comment = 1 + endif + if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' setf objc return endif @@ -1202,11 +1209,23 @@ func! s:FTm() setf mma return endif + if line =~ '^\c\s*\(\(type\|var\)\>\|--\)' + setf murphi + return + endif let n = n + 1 endwhile - if exists("g:filetype_m") + + if saw_comment + " We didn't see anything definitive, but this looks like either Objective C + " or Murphi based on the comment leader. Assume the former as it is more + " common. + setf objc + elseif exists("g:filetype_m") + " Use user specified default filetype for .m exe "setf " . g:filetype_m else + " Default is matlab setf matlab endif endfunc @@ -2792,12 +2811,12 @@ runtime! ftdetect/*.vim " state. augroup END -" Generic configuration file (check this last, it's just guessing!) +" Generic configuration file. Use FALLBACK, it's just guessing! au filetypedetect BufNewFile,BufRead,StdinReadPost * \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' \ || getline(4) =~ '^#' || getline(5) =~ '^#') | - \ setf conf | + \ setf FALLBACK conf | \ endif |