diff options
Diffstat (limited to 'autoload/polyglot/ft.vim')
-rw-r--r-- | autoload/polyglot/ft.vim | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/autoload/polyglot/ft.vim b/autoload/polyglot/ft.vim index e4c32415..56012da1 100644 --- a/autoload/polyglot/ft.vim +++ b/autoload/polyglot/ft.vim @@ -1,7 +1,7 @@ " Vim functions for file type detection " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2020 Aug 17 +" Last Change: 2021 Nov 27 " These functions are moved here from runtime/filetype.vim to make startup " faster. @@ -219,6 +219,23 @@ func polyglot#ft#FTe() endif endfunc +" Distinguish between Forth and F#. +" Provided by Doug Kearns. +func polyglot#ft#FTfs() + if exists("g:filetype_fs") + exe "setf " . g:filetype_fs + else + let line = getline(nextnonblank(1)) + " comments and colon definitions + if line =~ '^\s*\.\=( ' || line =~ '^\s*\\G\= ' || line =~ '^\\$' + \ || line =~ '^\s*: \S' + setf forth + else + setf fsharp + endif + endif +endfunc + " Distinguish between HTML, XHTML and Django func polyglot#ft#FThtml() let n = 1 @@ -269,7 +286,10 @@ func polyglot#ft#FTm() return endif - let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>' + " excluding end(for|function|if|switch|while) common to Murphi + let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>' + + let objc_preprocessor = '^\s*#\s*\%(import\|include\|define\|if\|ifn\=def\|undef\|line\|error\|pragma\)\>' let n = 1 let saw_comment = 0 " Whether we've seen a multiline comment leader. @@ -281,12 +301,11 @@ func polyglot#ft#FTm() " anything more definitive. let saw_comment = 1 endif - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' + if line =~ '^\s*//' || line =~ '^\s*@import\>' || line =~ objc_preprocessor setf objc return endif - if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' || - \ line =~ '^\s*unwind_protect\>' || + if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' || \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators setf octave return @@ -792,6 +811,23 @@ func polyglot#ft#Redif() endwhile endfunc +" This function is called for all files under */debian/patches/*, make sure not +" to non-dep3patch files, such as README and other text files. +func polyglot#ft#Dep3patch() + if expand('%:t') ==# 'series' + return + endif + + for ln in getline(1, 100) + if ln =~# '^\%(Description\|Subject\|Origin\|Bug\|Forwarded\|Author\|From\|Reviewed-by\|Acked-by\|Last-Updated\|Applied-Upstream\):' + setf dep3patch + return + elseif ln =~# '^---' + " end of headers found. stop processing + return + endif + endfor +endfunc " Restore 'cpoptions' let &cpo = s:cpo_save |