diff options
author | Christian Clason <christian.clason@uni-due.de> | 2021-09-10 14:01:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 14:01:13 +0200 |
commit | aab3583e74fa3fd295bd367113be60965c748205 (patch) | |
tree | 88b33978cb29ca7ca1b4b5c45208cd32b974115a /runtime | |
parent | 185ed18e6cc9113ef257e5491ada657a769a9d04 (diff) | |
download | rneovim-aab3583e74fa3fd295bd367113be60965c748205.tar.gz rneovim-aab3583e74fa3fd295bd367113be60965c748205.tar.bz2 rneovim-aab3583e74fa3fd295bd367113be60965c748205.zip |
vim-patch:8.2.3399: Octave files are not recognized (#15622)
Problem: Octave files are not recognized.
Solution: Detect Octave files. (Doug Kearns)
https://github.com/vim/vim/commit/deba5eb195d6ac70171d4973091fa884809fa3fa
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/dist/ft.vim | 19 | ||||
-rw-r--r-- | runtime/doc/filetype.txt | 1 | ||||
-rw-r--r-- | runtime/filetype.vim | 5 |
3 files changed, 20 insertions, 5 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index ac80659113..48a9657cf5 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -264,6 +264,13 @@ func dist#ft#ProtoCheck(default) endfunc func dist#ft#FTm() + if exists("g:filetype_m") + exe "setf " . g:filetype_m + return + endif + + let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>' + let n = 1 let saw_comment = 0 " Whether we've seen a multiline comment leader. while n < 100 @@ -278,6 +285,13 @@ func dist#ft#FTm() setf objc return endif + if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' || + \ line =~ '^\s*unwind_protect\>' || + \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators + setf octave + return + endif + " TODO: could be Matlab or Octave if line =~ '^\s*%' setf matlab return @@ -298,11 +312,8 @@ func dist#ft#FTm() " 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 + " Default is Matlab setf matlab endif endfunc diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 894d1627ab..4d0fdd71cc 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -135,6 +135,7 @@ can be used to overrule the filetype used for certain extensions: *.inc g:filetype_inc *.w g:filetype_w |ft-cweb-syntax| *.i g:filetype_i |ft-progress-syntax| + *.m g:filetype_m |ft-mathematica-syntax| *.p g:filetype_p |ft-pascal-syntax| *.pp g:filetype_pp |ft-pascal-syntax| *.sh g:bash_is_sh |ft-sh-syntax| diff --git a/runtime/filetype.vim b/runtime/filetype.vim index b3148bde25..c9eca870c2 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1025,7 +1025,7 @@ au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown " Mason au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason -" Mathematica, Matlab, Murphi or Objective C +" Mathematica, Matlab, Murphi, Objective C or Octave au BufNewFile,BufRead *.m call dist#ft#FTm() " Mathematica notebook @@ -1171,6 +1171,9 @@ au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit,*.mlt,*.mlp,*.mlip,*.mli " Occam au BufNewFile,BufRead *.occ setf occam +" Octave +au BufNewFile,BufRead octave.conf,.octaverc,octaverc setf octave + " Omnimark au BufNewFile,BufRead *.xom,*.xin setf omnimark |