mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.0349: filetype of *.sil files not well detected
Problem: Filetype of *.sil files not well detected. Solution: Inspect the file contents to guess the filetype.
This commit is contained in:
parent
36eb14fa3e
commit
be807d5824
17
runtime/autoload/dist/ft.vim
vendored
17
runtime/autoload/dist/ft.vim
vendored
@ -878,6 +878,23 @@ export def FTsig()
|
|||||||
endif
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
# This function checks the first 100 lines of files matching "*.sil" to
|
||||||
|
# resolve detection between Swift Intermediate Language and SILE.
|
||||||
|
export def FTsil()
|
||||||
|
for lnum in range(1, [line('$'), 100]->min())
|
||||||
|
var line: string = getline(lnum)
|
||||||
|
if line =~ '^\s*[\\%]'
|
||||||
|
setf sile
|
||||||
|
return
|
||||||
|
elseif line =~ '^\s*\S'
|
||||||
|
setf sil
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
# no clue, default to "sil"
|
||||||
|
setf sil
|
||||||
|
enddef
|
||||||
|
|
||||||
export def FTsys()
|
export def FTsys()
|
||||||
if exists("g:filetype_sys")
|
if exists("g:filetype_sys")
|
||||||
exe "setf " .. g:filetype_sys
|
exe "setf " .. g:filetype_sys
|
||||||
|
@ -1822,7 +1822,7 @@ au BufNewFile,BufRead *.score setf slrnsc
|
|||||||
au BufNewFile,BufRead *.st setf st
|
au BufNewFile,BufRead *.st setf st
|
||||||
|
|
||||||
" Smalltalk (and Rexx, TeX, and Visual Basic)
|
" 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
|
" Smarty templates
|
||||||
au BufNewFile,BufRead *.tpl setf smarty
|
au BufNewFile,BufRead *.tpl setf smarty
|
||||||
@ -1929,8 +1929,8 @@ au BufNewFile,BufRead *.cm setf voscm
|
|||||||
au BufNewFile,BufRead *.swift setf swift
|
au BufNewFile,BufRead *.swift setf swift
|
||||||
au BufNewFile,BufRead *.swift.gyb setf swiftgyb
|
au BufNewFile,BufRead *.swift.gyb setf swiftgyb
|
||||||
|
|
||||||
" Swift Intermediate Language
|
" Swift Intermediate Language or SILE
|
||||||
au BufNewFile,BufRead *.sil setf sil
|
au BufNewFile,BufRead *.sil call dist#ft#FTsil()
|
||||||
|
|
||||||
" Sysctl
|
" Sysctl
|
||||||
au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl
|
au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl
|
||||||
|
@ -1827,6 +1827,44 @@ func Test_sig_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test dist#ft#FTsil()
|
||||||
|
func Test_sil_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
split Xfile.sil
|
||||||
|
call assert_equal('sil', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
// valid
|
||||||
|
let protoErasedPathA = \ABCProtocol.a
|
||||||
|
|
||||||
|
// also valid
|
||||||
|
let protoErasedPathA =
|
||||||
|
\ABCProtocol.a
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xfile.sil')
|
||||||
|
|
||||||
|
split Xfile.sil
|
||||||
|
call assert_equal('sil', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" SILE
|
||||||
|
|
||||||
|
call writefile(['% some comment'], 'Xfile.sil')
|
||||||
|
split Xfile.sil
|
||||||
|
call assert_equal('sile', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['\begin[papersize=a6]{document}foo\end{document}'], 'Xfile.sil')
|
||||||
|
split Xfile.sil
|
||||||
|
call assert_equal('sile', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call delete('Xfile.sil')
|
||||||
|
filetype off
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_inc_file()
|
func Test_inc_file()
|
||||||
filetype on
|
filetype on
|
||||||
|
|
||||||
|
@ -707,6 +707,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
349,
|
||||||
/**/
|
/**/
|
||||||
348,
|
348,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user