mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:9.1.0505: filetype: Faust files are not recognized (#29426)
Problem: filetype: Faust files are not recognized
Solution: Detect '*.lib' files as Faust filetype, add detection for
'*.dsp' files (Faust or Make), remove '*.lib' from Cobol
filetype (PowerUser64)
closes: vim/vim#14894
aa61b8a908
Co-authored-by: PowerUser64 <blake@blakenorth.net>
This commit is contained in:
@@ -147,6 +147,7 @@ variables can be used to overrule the filetype used for certain extensions:
|
|||||||
`*.csh` g:filetype_csh |ft-csh-syntax|
|
`*.csh` g:filetype_csh |ft-csh-syntax|
|
||||||
`*.dat` g:filetype_dat
|
`*.dat` g:filetype_dat
|
||||||
`*.def` g:filetype_def
|
`*.def` g:filetype_def
|
||||||
|
`*.dsp` g:filetype_dsp
|
||||||
`*.f` g:filetype_f |ft-forth-syntax|
|
`*.f` g:filetype_f |ft-forth-syntax|
|
||||||
`*.frm` g:filetype_frm |ft-form-syntax|
|
`*.frm` g:filetype_frm |ft-form-syntax|
|
||||||
`*.fs` g:filetype_fs |ft-forth-syntax|
|
`*.fs` g:filetype_fs |ft-forth-syntax|
|
||||||
|
@@ -281,7 +281,6 @@ local extension = {
|
|||||||
cook = 'cook',
|
cook = 'cook',
|
||||||
cmake = 'cmake',
|
cmake = 'cmake',
|
||||||
cmod = 'cmod',
|
cmod = 'cmod',
|
||||||
lib = 'cobol',
|
|
||||||
cob = 'cobol',
|
cob = 'cobol',
|
||||||
cbl = 'cobol',
|
cbl = 'cobol',
|
||||||
atg = 'coco',
|
atg = 'coco',
|
||||||
@@ -366,6 +365,7 @@ local extension = {
|
|||||||
gv = 'dot',
|
gv = 'dot',
|
||||||
drac = 'dracula',
|
drac = 'dracula',
|
||||||
drc = 'dracula',
|
drc = 'dracula',
|
||||||
|
dsp = detect.dsp,
|
||||||
dtd = 'dtd',
|
dtd = 'dtd',
|
||||||
d = detect.dtrace,
|
d = detect.dtrace,
|
||||||
dts = 'dts',
|
dts = 'dts',
|
||||||
@@ -417,6 +417,7 @@ local extension = {
|
|||||||
fal = 'falcon',
|
fal = 'falcon',
|
||||||
fan = 'fan',
|
fan = 'fan',
|
||||||
fwt = 'fan',
|
fwt = 'fan',
|
||||||
|
lib = 'faust',
|
||||||
fnl = 'fennel',
|
fnl = 'fennel',
|
||||||
m4gl = 'fgl',
|
m4gl = 'fgl',
|
||||||
['4gl'] = 'fgl',
|
['4gl'] = 'fgl',
|
||||||
@@ -666,7 +667,6 @@ local extension = {
|
|||||||
eml = 'mail',
|
eml = 'mail',
|
||||||
mk = 'make',
|
mk = 'make',
|
||||||
mak = 'make',
|
mak = 'make',
|
||||||
dsp = 'make',
|
|
||||||
page = 'mallard',
|
page = 'mallard',
|
||||||
map = 'map',
|
map = 'map',
|
||||||
mws = 'maple',
|
mws = 'maple',
|
||||||
|
@@ -471,6 +471,41 @@ function M.def(_, bufnr)
|
|||||||
return 'def'
|
return 'def'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @type vim.filetype.mapfn
|
||||||
|
function M.dsp(path, bufnr)
|
||||||
|
if vim.g.filetype_dsp then
|
||||||
|
return vim.g.filetype_dsp
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Test the filename
|
||||||
|
local file_name = fn.fnamemodify(path, ':t')
|
||||||
|
if file_name:find('^[mM]akefile.*$') then
|
||||||
|
return 'make'
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Test the file contents
|
||||||
|
for _, line in ipairs(getlines(bufnr, 1, 200)) do
|
||||||
|
if
|
||||||
|
findany(line, {
|
||||||
|
-- Check for comment style
|
||||||
|
[[#.*]],
|
||||||
|
-- Check for common lines
|
||||||
|
[[^.*Microsoft Developer Studio Project File.*$]],
|
||||||
|
[[^!MESSAGE This is not a valid makefile\..+$]],
|
||||||
|
-- Check for keywords
|
||||||
|
[[^!(IF,ELSEIF,ENDIF).*$]],
|
||||||
|
-- Check for common assignments
|
||||||
|
[[^SOURCE=.*$]],
|
||||||
|
})
|
||||||
|
then
|
||||||
|
return 'make'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Otherwise, assume we have a Faust file
|
||||||
|
return 'faust'
|
||||||
|
end
|
||||||
|
|
||||||
--- @type vim.filetype.mapfn
|
--- @type vim.filetype.mapfn
|
||||||
function M.e(_, bufnr)
|
function M.e(_, bufnr)
|
||||||
if vim.g.filetype_euphoria then
|
if vim.g.filetype_euphoria then
|
||||||
|
@@ -161,7 +161,7 @@ func s:GetFilenameChecks() abort
|
|||||||
\ 'cmakecache': ['CMakeCache.txt'],
|
\ 'cmakecache': ['CMakeCache.txt'],
|
||||||
\ 'cmod': ['file.cmod'],
|
\ 'cmod': ['file.cmod'],
|
||||||
\ 'cmusrc': ['any/.cmus/autosave', 'any/.cmus/rc', 'any/.cmus/command-history', 'any/.cmus/file.theme', 'any/cmus/rc', 'any/cmus/file.theme', '/.cmus/autosave', '/.cmus/command-history', '/.cmus/file.theme', '/.cmus/rc', '/cmus/file.theme', '/cmus/rc'],
|
\ 'cmusrc': ['any/.cmus/autosave', 'any/.cmus/rc', 'any/.cmus/command-history', 'any/.cmus/file.theme', 'any/cmus/rc', 'any/cmus/file.theme', '/.cmus/autosave', '/.cmus/command-history', '/.cmus/file.theme', '/.cmus/rc', '/cmus/file.theme', '/cmus/rc'],
|
||||||
\ 'cobol': ['file.cbl', 'file.cob', 'file.lib'],
|
\ 'cobol': ['file.cbl', 'file.cob'],
|
||||||
\ 'coco': ['file.atg'],
|
\ 'coco': ['file.atg'],
|
||||||
\ 'conaryrecipe': ['file.recipe'],
|
\ 'conaryrecipe': ['file.recipe'],
|
||||||
\ 'conf': ['auto.master', 'file.conf', 'texdoc.cnf', '.x11vncrc', '.chktexrc', '.ripgreprc', 'ripgreprc', 'file.ctags', '.mbsyncrc'],
|
\ 'conf': ['auto.master', 'file.conf', 'texdoc.cnf', '.x11vncrc', '.chktexrc', '.ripgreprc', 'ripgreprc', 'file.ctags', '.mbsyncrc'],
|
||||||
@@ -257,6 +257,7 @@ func s:GetFilenameChecks() abort
|
|||||||
\ 'factor': ['file.factor'],
|
\ 'factor': ['file.factor'],
|
||||||
\ 'falcon': ['file.fal'],
|
\ 'falcon': ['file.fal'],
|
||||||
\ 'fan': ['file.fan', 'file.fwt'],
|
\ 'fan': ['file.fan', 'file.fwt'],
|
||||||
|
\ 'faust': ['file.dsp', 'file.lib'],
|
||||||
\ 'fennel': ['file.fnl'],
|
\ 'fennel': ['file.fnl'],
|
||||||
\ 'fetchmail': ['.fetchmailrc'],
|
\ 'fetchmail': ['.fetchmailrc'],
|
||||||
\ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'],
|
\ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'],
|
||||||
@@ -421,7 +422,7 @@ func s:GetFilenameChecks() abort
|
|||||||
\ 'mail': ['snd.123', '.letter', '.letter.123', '.followup', '.article', '.article.123', 'pico.123', 'mutt-xx-xxx', 'muttng-xx-xxx', 'ae123.txt', 'file.eml', 'reportbug-file'],
|
\ 'mail': ['snd.123', '.letter', '.letter.123', '.followup', '.article', '.article.123', 'pico.123', 'mutt-xx-xxx', 'muttng-xx-xxx', 'ae123.txt', 'file.eml', 'reportbug-file'],
|
||||||
\ 'mailaliases': ['/etc/mail/aliases', '/etc/aliases', 'any/etc/aliases', 'any/etc/mail/aliases'],
|
\ 'mailaliases': ['/etc/mail/aliases', '/etc/aliases', 'any/etc/aliases', 'any/etc/mail/aliases'],
|
||||||
\ 'mailcap': ['.mailcap', 'mailcap'],
|
\ 'mailcap': ['.mailcap', 'mailcap'],
|
||||||
\ 'make': ['file.mk', 'file.mak', 'file.dsp', 'makefile', 'Makefile', 'makefile-file', 'Makefile-file', 'some-makefile', 'some-Makefile', 'Kbuild'],
|
\ 'make': ['file.mk', 'file.mak', 'makefile', 'Makefile', 'makefile-file', 'Makefile-file', 'some-makefile', 'some-Makefile', 'Kbuild'],
|
||||||
\ 'mallard': ['file.page'],
|
\ 'mallard': ['file.page'],
|
||||||
"\ 'man': ['file.man'],
|
"\ 'man': ['file.man'],
|
||||||
\ 'manconf': ['/etc/man.conf', 'man.config', 'any/etc/man.conf'],
|
\ 'manconf': ['/etc/man.conf', 'man.config', 'any/etc/man.conf'],
|
||||||
@@ -2399,6 +2400,32 @@ func Test_typ_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_dsp_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
" Microsoft Developer Studio Project file
|
||||||
|
|
||||||
|
call writefile(['# Microsoft Developer Studio Project File'], 'Xfile.dsp', 'D')
|
||||||
|
split Xfile.dsp
|
||||||
|
call assert_equal('make', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
let g:filetype_dsp = 'make'
|
||||||
|
split test.dsp
|
||||||
|
call assert_equal('make', &filetype)
|
||||||
|
bwipe!
|
||||||
|
unlet g:filetype_dsp
|
||||||
|
|
||||||
|
" Faust
|
||||||
|
|
||||||
|
call writefile(['this is a fallback'], 'Xfile.dsp')
|
||||||
|
split Xfile.dsp
|
||||||
|
call assert_equal('faust', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
filetype off
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_vba_file()
|
func Test_vba_file()
|
||||||
filetype on
|
filetype on
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user