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)
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 5f48f4b..a96bdf5 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -459,7 +459,7 @@
setf nroff
enddef
-# Returns true if file content looks like LambdaProlog
+# Returns true if file content looks like LambdaProlog module
def IsLProlog(): bool
# skip apparent comments and blank lines, what looks like
# LambdaProlog comment may be RAPID header
@@ -848,6 +848,27 @@
return 0
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()
if exists("g:filetype_sys")
exe "setf " .. g:filetype_sys
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index 282a796..90ae3e7 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -157,6 +157,7 @@
*.pp g:filetype_pp |ft-pascal-syntax|
*.prg g:filetype_prg
*.r g:filetype_r
+ *.sig g:filetype_sig
*.sql g:filetype_sql |ft-sql-syntax|
*.src g:filetype_src
*.sys g:filetype_sys
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 1648e82..c7c6eab 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -997,8 +997,8 @@
" Limits
au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf setf limits
-" LambdaProlog (see dist#ft#FTmod for *.mod)
-au BufNewFile,BufRead *.sig setf lprolog
+" LambdaProlog or SML (see dist#ft#FTmod for *.mod)
+au BufNewFile,BufRead *.sig call dist#ft#FTsig()
" LDAP LDIF
au BufNewFile,BufRead *.ldif setf ldif