diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2024-06-20 17:45:41 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-20 17:45:41 +0800 |
| commit | af0021f990bfd9681e8889ef217d26a89fadf5f0 (patch) | |
| tree | 3d77149629ab08190c69eaa09317bde50733ffa3 /runtime/lua/vim/filetype | |
| parent | ac6f0c02cf31a5e6a426db0b4044c4a5d86f67a1 (diff) | |
| download | rneovim-af0021f990bfd9681e8889ef217d26a89fadf5f0.tar.gz rneovim-af0021f990bfd9681e8889ef217d26a89fadf5f0.tar.bz2 rneovim-af0021f990bfd9681e8889ef217d26a89fadf5f0.zip | |
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
https://github.com/vim/vim/commit/aa61b8a9087e9cd999ef07e0d87b60f43d68f2c6
Co-authored-by: PowerUser64 <blake@blakenorth.net>
Diffstat (limited to 'runtime/lua/vim/filetype')
| -rw-r--r-- | runtime/lua/vim/filetype/detect.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 997b53ba4b..b52dba7388 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -472,6 +472,41 @@ function M.def(_, bufnr) 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 function M.e(_, bufnr) if vim.g.filetype_euphoria then return vim.g.filetype_euphoria |