From 7f98e949d4922ba2109304bd4cabe9578a8062fb Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 9 Sep 2021 12:05:33 +0200 Subject: Update --- autoload/polyglot/ft.vim | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'autoload/polyglot/ft.vim') diff --git a/autoload/polyglot/ft.vim b/autoload/polyglot/ft.vim index 2e4c1f69..e4c32415 100644 --- a/autoload/polyglot/ft.vim +++ b/autoload/polyglot/ft.vim @@ -264,6 +264,13 @@ func polyglot#ft#ProtoCheck(default) endfunc func polyglot#ft#FTm() + if exists("g:filetype_m") + exe "setf " . g:filetype_m + return + endif + + let octave_block_terminators = '\' + let n = 1 let saw_comment = 0 " Whether we've seen a multiline comment leader. while n < 100 @@ -278,6 +285,13 @@ func polyglot#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 polyglot#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 -- cgit v1.2.3