diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/dist/ft.vim | 19 | ||||
-rw-r--r-- | runtime/filetype.vim | 6 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 4 | ||||
-rw-r--r-- | runtime/lua/vim/filetype/detect.lua | 13 |
4 files changed, 37 insertions, 5 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 77140d62b1..7333e5a7e7 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -468,7 +468,7 @@ endfunc " Returns true if file content looks like LambdaProlog module func IsLProlog() - " skip apparent comments and blank lines, what looks like + " skip apparent comments and blank lines, what looks like " LambdaProlog comment may be RAPID header let l = nextnonblank(1) while l > 0 && l < line('$') && getline(l) =~ '^\s*%' " LambdaProlog comment @@ -877,6 +877,23 @@ func dist#ft#FTsig() endif endfunc +" This function checks the first 100 lines of files matching "*.sil" to +" resolve detection between Swift Intermediate Language and SILE. +func dist#ft#FTsil() + for lnum in range(1, [line('$'), 100]->min()) + let line = getline(lnum) + if line =~ '^\s*[\\%]' + setf sile + return + elseif line =~ '^\s*\S' + setf sil + return + endif + endfor + " no clue, default to "sil" + setf sil +endfunc + func dist#ft#FTsys() if exists("g:filetype_sys") exe "setf " .. g:filetype_sys diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 98d9df8b5c..d26cb808b5 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1823,7 +1823,7 @@ au BufNewFile,BufRead *.score setf slrnsc au BufNewFile,BufRead *.st setf st " Smalltalk (and Rexx, TeX, and Visual Basic) -au BufNewFile,BufRead *.cls call dist#ft#FTcls() +au BufNewFile,BufRead *.cls call dist#ft#FTcls() " Smarty templates au BufNewFile,BufRead *.tpl setf smarty @@ -1930,8 +1930,8 @@ au BufNewFile,BufRead *.cm setf voscm au BufNewFile,BufRead *.swift setf swift au BufNewFile,BufRead *.swift.gyb setf swiftgyb -" Swift Intermediate Language -au BufNewFile,BufRead *.sil setf sil +" Swift Intermediate Language or SILE +au BufNewFile,BufRead *.sil call dist#ft#FTsil() " Sysctl au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index fcd697a7c1..6306605641 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -902,7 +902,9 @@ local extension = { sig = function(path, bufnr) return require('vim.filetype.detect').sig(bufnr) end, - sil = 'sil', + sil = function(path, bufnr) + return require('vim.filetype.detect').sil(bufnr) + end, sim = 'simula', ['s85'] = 'sinda', sin = 'sinda', diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 2be9dcff88..7fc7f1b7ca 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -1194,6 +1194,19 @@ function M.shell(path, contents, name) return name end +-- Swift Intermediate Language or SILE +function M.sil(bufnr) + for _, line in ipairs(getlines(bufnr, 1, 100)) do + if line:find('^%s*[\\%%]') then + return 'sile' + elseif line:find('^%s*%S') then + return 'sil' + end + end + -- No clue, default to "sil" + return 'sil' +end + -- SMIL or SNMP MIB file function M.smi(bufnr) local line = getlines(bufnr, 1) |