From 3d39ea3ea9b6e66640e59731d155d731218e7e62 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 May 2024 07:11:50 +0800 Subject: vim-patch:9.1.0442: hare runtime files outdated (#29011) Problem: hare runtime files outdated Solution: runtime(hare): update hare.vim to match upstream (Amelia Clarke) closes: vim/vim#14836 https://github.com/vim/vim/commit/35dfe58a540e2fb0eff953630f8e4fcbf4bc26ca Co-authored-by: Amelia Clarke --- runtime/lua/vim/filetype/detect.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index ba86d8de5a..58d2666564 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -650,6 +650,30 @@ function M.header(_, bufnr) end end +--- Recursively search for Hare source files in a directory and any +--- subdirectories, up to a given depth. +--- @param dir string +--- @param depth number +--- @return boolean +local function is_hare_module(dir, depth) + depth = math.max(depth, 0) + for name, _ in vim.fs.dir(dir, { depth = depth + 1 }) do + if name:find('%.ha$') then + return true + end + end + return false +end + +--- @type vim.filetype.mapfn +function M.haredoc(path, _) + if vim.g.filetype_haredoc then + if is_hare_module(vim.fs.dirname(path), vim.g.haredoc_search_depth or 1) then + return 'haredoc' + end + end +end + --- @type vim.filetype.mapfn function M.html(_, bufnr) for _, line in ipairs(getlines(bufnr, 1, 10)) do -- cgit From aa9f21ee953dd37c189a3a0388af84c87f7591ba Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 4 Jun 2024 11:55:59 +0300 Subject: fix(filetype): fix typos in filetype detection --- runtime/lua/vim/filetype/detect.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 58d2666564..c56ece6289 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -594,7 +594,7 @@ function M.frm(_, bufnr) end --- @type vim.filetype.mapfn -function M.fvwm_1(_, _) +function M.fvwm_v1(_, _) return 'fvwm', function(bufnr) vim.b[bufnr].fvwm_version = 1 end @@ -1355,7 +1355,7 @@ end function M.sgml(_, bufnr) local lines = table.concat(getlines(bufnr, 1, 5)) if lines:find('linuxdoc') then - return 'smgllnx' + return 'sgmllnx' elseif lines:find(' Date: Sun, 16 Jun 2024 11:27:20 +0200 Subject: vim-patch:9.1.0492: filetype: Vim-script files not detected by shebang line Problem: Vim-script files may not be recognised Solution: Add shebang line detection (Doug Kearns) closes: vim/vim#15012 https://github.com/vim/vim/commit/0d4d23dac0a5a77ccb0ebf1dcf646afe0c6886bf Co-authored-by: Doug Kearns --- runtime/lua/vim/filetype/detect.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index c56ece6289..fa90c83b81 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -1783,6 +1783,7 @@ local patterns_hashbang = { ['^janet\\>'] = { 'janet', { vim_regex = true } }, ['^dart\\>'] = { 'dart', { vim_regex = true } }, ['^execlineb\\>'] = { 'execline', { vim_regex = true } }, + ['^vim\\>'] = { 'vim', { vim_regex = true } }, } ---@private -- cgit From 6012f79557b8807593c1c88b75e54f14a88d5173 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 18 Jun 2024 20:00:43 +0200 Subject: vim-patch:9718ed7: runtime(filetype): update htmldjango detection - update tags to detect djangohtml based on https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#built-in-tag-reference - increase the lines to inspect to 40 lines 10 lines is too few and might result in high false negative. Increasing it to 40 lines should reduce the false negative. closes: vim/vim#15037 https://github.com/vim/vim/commit/9718ed7ab989c0a0be88a0d749f24321eb0e6af1 Co-authored-by: Afiq Nazrie --- runtime/lua/vim/filetype/detect.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index fa90c83b81..997b53ba4b 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -676,10 +676,15 @@ end --- @type vim.filetype.mapfn function M.html(_, bufnr) - for _, line in ipairs(getlines(bufnr, 1, 10)) do + for _, line in ipairs(getlines(bufnr, 1, 40)) do if matchregex(line, [[\\|{#\s\+]]) then + elseif + matchregex( + line, + [[\c{%\s*\(autoescape\|block\|comment\|csrf_token\|cycle\|debug\|extends\|filter\|firstof\|for\|if\|ifchanged\|include\|load\|lorem\|now\|query_string\|regroup\|resetcycle\|spaceless\|templatetag\|url\|verbatim\|widthratio\|with\)\>\|{#\s\+]] + ) + then return 'htmldjango' end end -- cgit From af0021f990bfd9681e8889ef217d26a89fadf5f0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 20 Jun 2024 17:45:41 +0800 Subject: 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 --- runtime/lua/vim/filetype/detect.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'runtime/lua/vim/filetype') 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 @@ -471,6 +471,41 @@ function M.def(_, bufnr) return 'def' 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 -- cgit From aa6b9c677d83d76d448c3bb0973bf8d14bfdf922 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 8 Jun 2024 21:40:18 +0200 Subject: refactor: use `vim._with` where possible This mostly means replacing `nvim_buf_call` and `nvim_win_call` with `vim._with`. --- runtime/lua/vim/filetype/detect.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index b52dba7388..e1891e299e 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -450,7 +450,7 @@ local function modula2(bufnr) return 'modula2', function(b) - vim.api.nvim_buf_call(b, function() + vim._with({ buf = b }, function() fn['modula2#SetDialect'](dialect, extension) end) end -- cgit From 8aab46da5e5bd8737d0d90ec10faa09cee5448c7 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 8 Jul 2024 10:46:16 +0200 Subject: vim-patch:94c1c66: runtime(tf): include tf ftplugin file Adds ftplugin support for tf (TinyFugue). Comment support taken from [here](https://github.com/kruton/tinyfugue/blob/1e8ac0bb014036c07bb3c679b0292ef20a6a0bb5/src/command.c#L568) closes: vim/vim#15168 https://github.com/vim/vim/commit/94c1c6638a652cbe21b4d25ae5f26078e2e633d7 Co-authored-by: Riley Bruins --- runtime/lua/vim/filetype/detect.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index e1891e299e..85c8d4c9dc 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -1597,7 +1597,7 @@ function M.tex(path, bufnr) end end --- Determine if a *.tf file is TF mud client or terraform +-- Determine if a *.tf file is TF (TinyFugue) mud client or terraform --- @type vim.filetype.mapfn function M.tf(_, bufnr) for _, line in ipairs(getlines(bufnr)) do -- cgit From 7fa089f463dac83f256a8336ddb0adc9eae483a2 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 9 Jul 2024 19:58:02 +0200 Subject: vim-patch:9.1.0551: filetype: htmlangular files are not properly detected Problem: filetype: htmlangular files are not properly detected Solution: Use the new htmlangular filetype for angular files, because since angular v17, those are no longer valid HTML files. (Dennis van den Berg) Since Angular 17, the new Control Flow Syntax is not valid HTML. This PR adds a new filetype detection for the HTML templates of Angular. It first checks the filename. The Angular convention is to use *.component.html for the template. However, this is not mandatory. If the filename does not match, it will check the contents of the file if it contains: - One of the Control-Flow blocks: @if, @for, @switch, @defer - A structural directive: *ngIf, *ngFor, *ngSwitch, *ngTemplateOutlet - Builtin Angular elements: ng-template or ng-content - String interpolation: {{ something }} This enables the Angular LSP to attach only to htmlangular filetypes, as well as language parsers, such as tree-sitter. closes: vim/vim#15190 https://github.com/vim/vim/commit/1ad194c0dfd82ca1e7a1b6f2fca89a487794158d Co-authored-by: Dennis van den Berg --- runtime/lua/vim/filetype/detect.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 85c8d4c9dc..8a217a4ac2 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -710,9 +710,22 @@ function M.haredoc(path, _) end --- @type vim.filetype.mapfn -function M.html(_, bufnr) +function M.html(path, bufnr) + -- Test if the filename follows the Angular component template convention + local filename = fn.fnamemodify(path, ':t') + if filename:find('%.component%.html$') then + return 'htmlangular' + end + for _, line in ipairs(getlines(bufnr, 1, 40)) do - if matchregex(line, [[\ Date: Wed, 10 Jul 2024 19:47:28 +0200 Subject: vim-patch:9.1.0555: filetype: angular ft detection is still problematic Problem: filetype: angular ft detection is still problematic (after 9.1.0551) Solution: detect htmlangular filetype only by inspecting the content, do not try to determine it from a generic name like '*.component.html' For the reasons mentioned here: https://github.com/vim/vim/pull/13594#issuecomment-1834465890 related: vim/vim#15190 related: vim/vim#13594 related: vim/vim#13604 https://github.com/vim/vim/commit/c03f631b7b01e672787b222a55898f8dcac8d859 Co-authored-by: Christian Brabandt --- runtime/lua/vim/filetype/detect.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 8a217a4ac2..95e55ebb21 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -710,12 +710,13 @@ function M.haredoc(path, _) end --- @type vim.filetype.mapfn -function M.html(path, bufnr) - -- Test if the filename follows the Angular component template convention - local filename = fn.fnamemodify(path, ':t') - if filename:find('%.component%.html$') then - return 'htmlangular' - end +function M.html(_, bufnr) + -- Disabled for the reasons mentioned here: + -- https://github.com/vim/vim/pull/13594#issuecomment-1834465890 + -- local filename = fn.fnamemodify(path, ':t') + -- if filename:find('%.component%.html$') then + -- return 'htmlangular' + -- end for _, line in ipairs(getlines(bufnr, 1, 40)) do if -- cgit From f67a7365afacfad3f05e7aaca0bb2538a6e9f125 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Jul 2024 12:57:56 +0800 Subject: vim-patch:9.1.0602: filetype: Prolog detection can be improved Problem: filetype: Prolog detection can be improved Solution: update the prolog detection regex (igna_martinoli) related: vim/vim#10835 related: vim/vim#15206 closes: vim/vim#15253 https://github.com/vim/vim/commit/37853b7de31ef34153fe76aa2b740d517ed0e5d4 N/A patch: vim-patch:7347642: runtime(filetype): Fix Prolog file detection regex Problem: filetype: .pro file detection for Prolog is broken Solution: fixed the regex to only match on the tested cases (igna_martinoli) fixes: vim/vim#10835 closes: vim/vim#15206 https://github.com/vim/vim/commit/7347642633eb2de23a78c51a4388c9080440eec4 Co-authored-by: igna_martinoli Co-authored-by: clason --- runtime/lua/vim/filetype/detect.lua | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 95e55ebb21..1fe7db0e1f 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -1116,6 +1116,8 @@ function M.perl(path, bufnr) end end +local prolog_patterns = { '^%s*:%-', '^%s*%%+%s', '^%s*%%+$', '^%s*/%*', '%.%s*$' } + --- @type vim.filetype.mapfn function M.pl(_, bufnr) if vim.g.filetype_pl then @@ -1124,11 +1126,7 @@ function M.pl(_, bufnr) -- Recognize Prolog by specific text in the first non-empty line; -- require a blank after the '%' because Perl uses "%list" and "%translate" local line = nextnonblank(bufnr, 1) - if - line and line:find(':%-') - or matchregex(line, [[\c\]]) - or findany(line, { '^%s*%%+%s', '^%s*%%+$', '^%s*/%*' }) - then + if line and matchregex(line, [[\c\]]) or findany(line, prolog_patterns) then return 'prolog' else return 'perl' @@ -1232,11 +1230,7 @@ function M.proto(_, bufnr) -- Recognize Prolog by specific text in the first non-empty line; -- require a blank after the '%' because Perl uses "%list" and "%translate" local line = nextnonblank(bufnr, 1) - if - line and line:find(':%-') - or matchregex(line, [[\c\]]) - or findany(line, { '^%s*%%+%s', '^%s*%%+$', '^%s*/%*' }) - then + if line and matchregex(line, [[\c\]]) or findany(line, prolog_patterns) then return 'prolog' end end -- cgit From 60967cd9aac545a5a5f17070d39121d4070e2298 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 27 Jul 2024 16:48:29 +0800 Subject: vim-patch:9.1.0616: filetype: Make syntax highlighting off for MS Makefiles (#29874) Problem: filetype: Make syntax highlighting off for MS Makefiles Solution: Try to detect MS Makefiles and adjust syntax rules to it. (Ken Takata) Highlighting of variable expansion in Microsoft Makefile can be broken. E.g.: https://github.com/vim/vim/blob/2979cfc2627d76a9c09cad46a1647dcd4aa73f5f/src/Make_mvc.mak#L1331 Don't use backslash as escape characters if `make_microsoft` is set. Also fix that `make_no_comments` was not considered if `make_microsoft` was set. Also add description for `make_microsoft` and `make_no_comments` to the documentation and include a very simple filetype test closes: vim/vim#15341 https://github.com/vim/vim/commit/eb4b903c9b238ebcc1d14cfcb207129b4931a33d Co-authored-by: Ken Takata --- runtime/lua/vim/filetype/detect.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 1fe7db0e1f..cb953f9d0c 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -972,6 +972,24 @@ local function m4(contents) end end +--- Check if it is a Microsoft Makefile +--- @type vim.filetype.mapfn +function M.make(_, bufnr) + vim.b.make_microsoft = nil + for _, line in ipairs(getlines(bufnr, 1, 1000)) do + if matchregex(line, [[\c^\s*!\s*\(ifn\=\(def\)\=\|include\|message\|error\)\>]]) then + vim.b.make_microsoft = 1 + break + elseif + matchregex(line, [[^ *ifn\=\(eq\|def\)\>]]) + or findany(line, { '^ *[-s]?%s', '^ *%w+%s*[!?:+]=' }) + then + break + end + end + return 'make' +end + --- @type vim.filetype.mapfn function M.markdown(_, _) return vim.g.filetype_md or 'markdown' -- cgit From e596b6a18d84aa56b5189bb7921feec58279976c Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 28 Jul 2024 22:29:20 +0200 Subject: vim-patch:9.1.0635: filetype: SuperHTML template files not recognized Problem: filetype: SuperHTML template files not recognized Solution: Update the filetype detection code to detect '*.shtml' either as HTML (Server Side Includes) or SuperHTML (template files) (EliSauder) related: vim/vim#15355 related: vim/vim#15367 https://github.com/vim/vim/commit/e57c9a19edc906a96ccb8821ae33fa6a8b20c3cd Co-authored-by: EliSauder <24995216+EliSauder@users.noreply.github.com> --- runtime/lua/vim/filetype/detect.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/lua/vim/filetype') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index cb953f9d0c..1cc81b177f 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -735,6 +735,8 @@ function M.html(_, bufnr) ) then return 'htmldjango' + elseif findany(line, { '' }) then + return 'superhtml' end end return 'html' -- cgit