mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.0012: signature files not detected properly
Problem: Signature files not detected properly. Solution: Add a function to better detect signature files. (Doug Kearns)
This commit is contained in:
parent
d25f003342
commit
cdbfc6dbab
23
runtime/autoload/dist/ft.vim
vendored
23
runtime/autoload/dist/ft.vim
vendored
@ -459,7 +459,7 @@ export def FTmm()
|
|||||||
setf nroff
|
setf nroff
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
# Returns true if file content looks like LambdaProlog
|
# Returns true if file content looks like LambdaProlog module
|
||||||
def IsLProlog(): bool
|
def IsLProlog(): bool
|
||||||
# skip apparent comments and blank lines, what looks like
|
# skip apparent comments and blank lines, what looks like
|
||||||
# LambdaProlog comment may be RAPID header
|
# LambdaProlog comment may be RAPID header
|
||||||
@ -848,6 +848,27 @@ export def FTperl(): number
|
|||||||
return 0
|
return 0
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
# LambdaProlog and Standard ML signature files
|
||||||
|
export def FTsig()
|
||||||
|
if exists("g:filetype_sig")
|
||||||
|
exe "setf " .. g:filetype_sig
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
var lprolog_comment = '^\s*\%(/\*\|%\)'
|
||||||
|
var lprolog_keyword = '^\s*sig\s\+\a'
|
||||||
|
var sml_comment = '^\s*(\*'
|
||||||
|
var sml_keyword = '^\s*\%(signature\|structure\)\s\+\a'
|
||||||
|
|
||||||
|
var line = getline(nextnonblank(1))
|
||||||
|
|
||||||
|
if line =~ lprolog_comment || line =~# lprolog_keyword
|
||||||
|
setf lprolog
|
||||||
|
elseif line =~ sml_comment || line =~# sml_keyword
|
||||||
|
setf sml
|
||||||
|
endif
|
||||||
|
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
|
||||||
|
@ -157,6 +157,7 @@ variables can be used to overrule the filetype used for certain extensions:
|
|||||||
*.pp g:filetype_pp |ft-pascal-syntax|
|
*.pp g:filetype_pp |ft-pascal-syntax|
|
||||||
*.prg g:filetype_prg
|
*.prg g:filetype_prg
|
||||||
*.r g:filetype_r
|
*.r g:filetype_r
|
||||||
|
*.sig g:filetype_sig
|
||||||
*.sql g:filetype_sql |ft-sql-syntax|
|
*.sql g:filetype_sql |ft-sql-syntax|
|
||||||
*.src g:filetype_src
|
*.src g:filetype_src
|
||||||
*.sys g:filetype_sys
|
*.sys g:filetype_sys
|
||||||
|
@ -997,8 +997,8 @@ au BufNewFile,BufRead *.latte,*.lte setf latte
|
|||||||
" Limits
|
" Limits
|
||||||
au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf setf limits
|
au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf setf limits
|
||||||
|
|
||||||
" LambdaProlog (see dist#ft#FTmod for *.mod)
|
" LambdaProlog or SML (see dist#ft#FTmod for *.mod)
|
||||||
au BufNewFile,BufRead *.sig setf lprolog
|
au BufNewFile,BufRead *.sig call dist#ft#FTsig()
|
||||||
|
|
||||||
" LDAP LDIF
|
" LDAP LDIF
|
||||||
au BufNewFile,BufRead *.ldif setf ldif
|
au BufNewFile,BufRead *.ldif setf ldif
|
||||||
|
@ -313,7 +313,6 @@ let s:filename_checks = {
|
|||||||
\ 'lotos': ['file.lot', 'file.lotos'],
|
\ 'lotos': ['file.lot', 'file.lotos'],
|
||||||
\ 'lout': ['file.lou', 'file.lout'],
|
\ 'lout': ['file.lou', 'file.lout'],
|
||||||
\ 'lpc': ['file.lpc', 'file.ulpc'],
|
\ 'lpc': ['file.lpc', 'file.ulpc'],
|
||||||
\ 'lprolog': ['file.sig'],
|
|
||||||
\ 'lsl': ['file.lsl'],
|
\ 'lsl': ['file.lsl'],
|
||||||
\ 'lss': ['file.lss'],
|
\ 'lss': ['file.lss'],
|
||||||
\ 'lua': ['file.lua', 'file.rockspec', 'file.nse'],
|
\ 'lua': ['file.lua', 'file.rockspec', 'file.nse'],
|
||||||
@ -1760,4 +1759,59 @@ func Test_cls_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_sig_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
call writefile(['this is neither Lambda Prolog nor SML'], 'Xfile.sig')
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" Test dist#ft#FTsig()
|
||||||
|
|
||||||
|
let g:filetype_sig = 'sml'
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('sml', &filetype)
|
||||||
|
bwipe!
|
||||||
|
unlet g:filetype_sig
|
||||||
|
|
||||||
|
" Lambda Prolog
|
||||||
|
|
||||||
|
call writefile(['sig foo.'], 'Xfile.sig')
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('lprolog', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['/* ... */'], 'Xfile.sig')
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('lprolog', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['% ...'], 'Xfile.sig')
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('lprolog', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" SML signature file
|
||||||
|
|
||||||
|
call writefile(['signature FOO ='], 'Xfile.sig')
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('sml', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['structure FOO ='], 'Xfile.sig')
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('sml', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['(* ... *)'], 'Xfile.sig')
|
||||||
|
split Xfile.sig
|
||||||
|
call assert_equal('sml', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call delete('Xfile.sig')
|
||||||
|
filetype off
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -735,6 +735,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 */
|
||||||
|
/**/
|
||||||
|
12,
|
||||||
/**/
|
/**/
|
||||||
11,
|
11,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user