From 0264870c0aa50fd4e34fb8a6b3c3c3cd88a22db7 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 9 Oct 2024 09:44:15 +0200 Subject: vim-patch:9.1.0769: filetype: MLIR files are not recognized Problem: filetype: MLIR files are not recognized Solution: Detect '*.mlir' files as mlir filetype, include a mlir filetype plugin (Wu, Zhenyu) closes: vim/vim#15826 https://github.com/vim/vim/commit/347d43bd33519ab537f77d1a8fa8ab8f9196bcb9 Co-authored-by: Wu, Zhenyu --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index d3910e26eb..3d3b2a2ea1 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -752,6 +752,7 @@ local extension = { mib = 'mib', mix = 'mix', mixal = 'mix', + mlir = 'mlir', mm = detect.mm, nb = 'mma', wl = 'mma', -- cgit From 79c036747a6cde1e38adcd19ed89b9295b2af1e3 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 11 Oct 2024 08:31:06 +0200 Subject: vim-patch:9.1.0773: filetype: some Apache files are not recognized Problem: filetype: some Apache files are not recognized Solution: Detect more config files from the Apache source distribution as filetype apache (nisbet-hubbard) closes: vim/vim#15810 https://github.com/vim/vim/commit/e58e9015cc431b79d88af4daec838519a8e296d6 Co-authored-by: nisbet-hubbard <87453615+nisbet-hubbard@users.noreply.github.com> --- runtime/lua/vim/filetype.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 3d3b2a2ea1..445281deca 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2185,6 +2185,8 @@ local pattern = { ['^apache%.conf'] = detect_apache_dotconf, ['^apache2%.conf'] = detect_apache_dotconf, ['^httpd%.conf'] = detect_apache_dotconf, + ['^httpd%-.*%.conf'] = detect_apache_dotconf, + ['^proxy%-html%.conf'] = detect_apache_dotconf, ['^srm%.conf'] = detect_apache_dotconf, ['asterisk/.*%.conf'] = starsetf('asterisk'), ['asterisk.*/.*voicemail%.conf'] = starsetf('asteriskvm'), -- cgit From 06625f9b3af22a2971cbd21274138c9653f2f723 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 12 Oct 2024 17:28:56 +0200 Subject: vim-patch:9.1.0777: filetype: Some upstream php files are not recognized Problem: filetype: Some upstream php files are not recognized Solution: Detect more config files from the PHP source distribution as filetype ini (nisbet-hubbard). closes: vim/vim#15840 https://github.com/vim/vim/commit/367499c5c39057bca267716d9aad20554d4d83fd Co-authored-by: nisbet-hubbard <87453615+nisbet-hubbard@users.noreply.github.com> --- runtime/lua/vim/filetype.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 445281deca..25e4dd33f7 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2296,6 +2296,8 @@ local pattern = { ['^crontab%.'] = starsetf('crontab'), ['^cvs%d+$'] = 'cvs', ['^php%.ini%-'] = 'dosini', + ['^php%-fpm%.conf'] = 'dosini', + ['^www%.conf'] = 'dosini', ['^drac%.'] = starsetf('dracula'), ['/dtrace/.*%.d$'] = 'dtrace', ['esmtprc$'] = 'esmtprc', -- cgit From 15aa27bc1f999adac3f4d69742ca31992fb5f837 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 13 Oct 2024 19:33:25 +0200 Subject: vim-patch:9.1.0778: filetype: lf config files are not recognized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: filetype: lf config files are not recognized Solution: detect lfrc files as lf filetype, include a syntax script for lf files (Andis Spriņķis). References: - https://github.com/gokcehan/lf closes: vim/vim#15859 https://github.com/vim/vim/commit/0f146b7925178a5bdfdc8e07642976f0b76d9612 Co-authored-by: Andis Spriņķis --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 25e4dd33f7..3b641898a3 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1611,6 +1611,7 @@ local filename = { ['ldaprc'] = 'ldapconf', ['.ldaprc'] = 'ldapconf', ['ldap.conf'] = 'ldapconf', + ['lfrc'] = 'lf', ['lftp.conf'] = 'lftp', ['.lftprc'] = 'lftp', ['/.libao'] = 'libao', -- cgit From d04d7bf65de8e77a8ea3aea59506abc328d77cd1 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 13 Oct 2024 19:43:04 +0200 Subject: vim-patch:9.1.0779: filetype: neomuttlog files are not recognized Problem: filetype: neomuttlog files are not recognized Solution: detect '*.neomuttdebug' file as neomuttlog filetype, include neomuttlog syntax script (Richard Russon) closes: vim/vim#15858 https://github.com/vim/vim/commit/a2aa921f767da17d4b619f41b7a1210c762c91e2 Co-authored-by: Richard Russon Co-authored-by: AvidSeeker --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 3b641898a3..a166397bfd 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2264,6 +2264,7 @@ local pattern = { ['^%.?neomuttrc'] = detect_neomuttrc, ['/%.neomutt/neomuttrc'] = detect_neomuttrc, ['^Neomuttrc'] = detect_neomuttrc, + ['%.neomuttdebug'] = 'neomuttlog', }, ['^%.'] = { ['^%.cshrc'] = detect.csh, -- cgit From 3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 16 Oct 2024 17:03:48 +0100 Subject: perf(validate): use lighter version - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number. --- runtime/lua/vim/filetype.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index a166397bfd..280d665fea 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2736,9 +2736,7 @@ end --- filetype specific buffer variables). The function accepts a buffer number as --- its only argument. function M.match(args) - vim.validate({ - arg = { args, 't' }, - }) + vim.validate('arg', args, 'table') if not (args.buf or args.filename or args.contents) then error('At least one of "buf", "filename", or "contents" must be given') -- cgit From b7779aad41dada52cf08aecbe2ca941edd2ecd59 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 22 Oct 2024 00:14:43 +0200 Subject: vim-patch:9.1.0795: filetype: Vivado memory info file are not recognized Problem: filetype: Vivado memory info file are not recognized Solution: detect '*.mmi' memory info file as xml filetype (Wu, Zhenyu) References: https://docs.amd.com/r/en-US/ug1580-updatemem/MMI-File-Syntax closes: vim/vim#15906 https://github.com/vim/vim/commit/0887e62bce3f46c20d2fa5f8ece1ca001e44ce63 Co-authored-by: Wu, Zhenyu --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 280d665fea..b824b60536 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1304,6 +1304,7 @@ local extension = { xpfm = 'xml', spfm = 'xml', bxml = 'xml', + mmi = 'xml', xcu = 'xml', xlb = 'xml', xlc = 'xml', -- cgit From a6d1165771781732cb8ff6105df6f0429c46cde1 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 22 Oct 2024 00:16:48 +0200 Subject: vim-patch:9.1.0796: filetype: libtool files are not recognized Problem: filetype: libtool files are not recognized Solution: detect '*.{lo,la,lai}' as sh filetype (Wu, Zhenyu) closes: vim/vim#15751 https://github.com/vim/vim/commit/bfe568d8c49662c3a3485834066c0a4c32ded56b Co-authored-by: Wu, Zhenyu --- runtime/lua/vim/filetype.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index b824b60536..2e7c95f85c 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1068,6 +1068,9 @@ local extension = { envrc = detect.sh, ksh = detect.ksh, sh = detect.sh, + lo = 'sh', + la = 'sh', + lai = 'sh', mdd = 'sh', sieve = 'sieve', siv = 'sieve', -- cgit From 02749de7d5ffa9b0c809f93744d179d508c31206 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 23 Oct 2024 09:32:07 +0200 Subject: vim-patch:9.1.0809: filetype: petalinux config files not recognized Problem: filetype: petalinux config files not recognized Solution: detect 'project-spec/*.conf' files as bitbake filetype (Wu, Zhenyu) References: https://www.amd.com/en/products/software/adaptive-socs-and-fpgas/embedded-software/petalinux-sdk.html closes: vim/vim#15926 https://github.com/vim/vim/commit/626b6ab48682b211c22ede5a6e63513c85f93e58 Co-authored-by: Wu, Zhenyu --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 2e7c95f85c..aa74a67968 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2112,6 +2112,7 @@ local pattern = { ['/build/conf/.*%.conf$'] = 'bitbake', ['/meta%-.*/conf/.*%.conf$'] = 'bitbake', ['/meta/conf/.*%.conf$'] = 'bitbake', + ['/project%-spec/configs/.*%.conf$'] = 'bitbake', ['/%.cabal/config$'] = 'cabalconfig', ['/cabal/config$'] = 'cabalconfig', ['/%.aws/config$'] = 'confini', -- cgit From 82e5066a7f8606dc677271049ead4829eb57935a Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 31 Oct 2024 09:50:10 +0100 Subject: vim-patch:9.1.0823: filetype: Zephyr overlay files not recognized Problem: filetype: Zephyr overlay files not recognized Solution: detect '*.overlay' files as dts filetype, include syntax tests for DTS files (Xudong Zheng) Reference: https://docs.zephyrproject.org/latest/build/dts/howtos.html closes: vim/vim#15963 https://github.com/vim/vim/commit/a68bd6f089239a51ba90026b18109707e601b107 Co-authored-by: Xudong Zheng <7pkvm5aw@slicealias.com> --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index aa74a67968..f6928c6428 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -402,6 +402,7 @@ local extension = { dtso = 'dts', its = 'dts', keymap = 'dts', + overlay = 'dts', dylan = 'dylan', intr = 'dylanintr', lid = 'dylanlid', -- cgit From db46b58569bc518967b73bf7d6ed92f8f5548c90 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 2 Nov 2024 16:09:23 +0100 Subject: vim-patch:9.1.0826: filetype: sway files are not recognized Problem: filetype: sway files are not recognized Solution: detect '*.sw' files as sway filetype, include a filetype plugin (Riley Bruins) References: https://github.com/FuelLabs/sway. Comments taken from their syntax documentation. File extension taken from the same documentation/GitHub's own recognition of these file types closes: vim/vim#15973 https://github.com/vim/vim/commit/84b5b1c660beb2f9e27de70687e41d39a023ae81 Co-authored-by: Riley Bruins --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index f6928c6428..057a99123b 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1151,6 +1151,7 @@ local extension = { sface = 'surface', svelte = 'svelte', svg = 'svg', + sw = 'sway', swift = 'swift', swiftinterface = 'swift', swig = 'swig', -- cgit From 65b9499e4a761e4e76e0e1e60cb507c4d6232bd9 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 4 Nov 2024 21:52:04 +0100 Subject: vim-patch:9.1.0840: filetype: idris2 files are not recognized Problem: filetype: idris2 files are not recognized Solution: detect '*.idr' files as idris2, '*.lidr' files as lidris2 and '*.ipkg' files as ipkg filetype (Serhii Khoma) closes: vim/vim#15987 https://github.com/vim/vim/commit/c04bc64ba61f2386fafb086b47f16f122a0c779a Co-authored-by: Serhii Khoma --- runtime/lua/vim/filetype.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 057a99123b..588a07b5d7 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -588,6 +588,7 @@ local extension = { ibi = 'ibasic', icn = 'icon', idl = detect.idl, + idr = 'idris2', inc = detect.inc, inf = 'inform', INF = 'inform', @@ -595,6 +596,7 @@ local extension = { inko = 'inko', inp = detect.inp, ms = detect_seq(detect.nroff, 'xmath'), + ipkg = 'ipkg', iss = 'iss', mst = 'ist', ist = 'ist', @@ -674,6 +676,7 @@ local extension = { ['l++'] = 'lex', l = 'lex', lhs = 'lhaskell', + lidr = 'lidris2', ll = 'lifelines', ly = 'lilypond', ily = 'lilypond', -- cgit From ba40a6dbe3a1c98a9f75e56c7cd08ecd522d27dd Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 4 Nov 2024 20:03:10 +0100 Subject: vim-patch:9.1.0839: filetype: leo files are not recognized Problem: filetype: leo files are not recognized Solution: detect '*.leo' files as leo filetype, include a filetype plugin (Riley Bruins) References: https://github.com/ProvableHQ/leo closes: vim/vim#15988 https://github.com/vim/vim/commit/93f65a4ab8168c766e4d3794607762b52762ef82 Co-authored-by: Riley Bruins --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 588a07b5d7..6caf25c588 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -670,6 +670,7 @@ local extension = { journal = 'ledger', ldg = 'ledger', ledger = 'ledger', + leo = 'leo', less = 'less', lex = 'lex', lxx = 'lex', -- cgit From ff575b38864022b0b27527f11636c49107acd1bc Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 7 Nov 2024 11:42:08 +0000 Subject: perf(filetype): optimize internal data structures This changes the type for the sorted pattern table from `vim.filetype.mapping[]` to `vim.filetype.mapping.sorted[]` E.g. instead of: ```lua { { ['/debian/changelog$'] = {'debchangelog', { parent = '/debian/' } }, { ['%.git/'] = { detect.git , { parent = 'git/', priority = -1 } }, } ``` It is now: ```lua { { '/debian/, '/debian/changelog$', 'debchangelog' }, { 'git/' , '%.git/' , detect.git , -1 }, } ``` Overall this should roughly cut the amount of tables used by 3, and replaces lots of hash indexes with array indexes. --- runtime/lua/vim/filetype.lua | 95 +++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 45 deletions(-) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 6caf25c588..eda4c6a479 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -4,15 +4,22 @@ local fn = vim.fn local M = {} --- @alias vim.filetype.mapfn fun(path:string,bufnr:integer, ...):string?, fun(b:integer)? ---- @alias vim.filetype.mapopts { parent: string, priority: number } +--- @alias vim.filetype.mapopts { priority: number } --- @alias vim.filetype.maptbl [string|vim.filetype.mapfn, vim.filetype.mapopts] --- @alias vim.filetype.mapping.value string|vim.filetype.mapfn|vim.filetype.maptbl --- @alias vim.filetype.mapping table +--- @class vim.filetype.mapping.sorted +--- @nodoc +--- @field [1] string parent pattern +--- @field [2] string pattern +--- @field [3] string|vim.filetype.mapfn +--- @field [4] integer priority + --- @param ft string|vim.filetype.mapfn ---- @param opts? vim.filetype.mapopts +--- @param priority? integer --- @return vim.filetype.maptbl -local function starsetf(ft, opts) +local function starsetf(ft, priority) return { function(path, bufnr) -- Note: when `ft` is a function its return value may be nil. @@ -27,11 +34,8 @@ local function starsetf(ft, opts) end end, { - -- Allow setting "parent" to be reused in closures, but don't have default as it will be - -- assigned later from grouping - parent = opts and opts.parent, -- Starset matches should have lowest priority by default - priority = (opts and opts.priority) or -math.huge, + priority = priority or -math.huge, }, } end @@ -1874,11 +1878,10 @@ local filename = { } -- Re-use closures as much as possible -local detect_apache_diretc = starsetf('apache', { parent = '/etc/' }) -local detect_apache_dotconf = starsetf('apache', { parent = '%.conf' }) -local detect_muttrc = starsetf('muttrc', { parent = 'utt' }) -local detect_neomuttrc = starsetf('neomuttrc', { parent = 'utt' }) -local detect_xkb = starsetf('xkb', { parent = '/usr/' }) +local detect_apache = starsetf('apache') +local detect_muttrc = starsetf('muttrc') +local detect_neomuttrc = starsetf('neomuttrc') +local detect_xkb = starsetf('xkb') ---@type table local pattern = { @@ -1895,14 +1898,14 @@ local pattern = { ['/etc/asound%.conf$'] = 'alsaconf', ['/etc/apache2/sites%-.*/.*%.com$'] = 'apache', ['/etc/httpd/.*%.conf$'] = 'apache', - ['/etc/apache2/.*%.conf'] = detect_apache_diretc, - ['/etc/apache2/conf%..*/'] = detect_apache_diretc, - ['/etc/apache2/mods%-.*/'] = detect_apache_diretc, - ['/etc/apache2/sites%-.*/'] = detect_apache_diretc, - ['/etc/httpd/conf%..*/'] = detect_apache_diretc, - ['/etc/httpd/conf%.d/.*%.conf'] = detect_apache_diretc, - ['/etc/httpd/mods%-.*/'] = detect_apache_diretc, - ['/etc/httpd/sites%-.*/'] = detect_apache_diretc, + ['/etc/apache2/.*%.conf'] = detect_apache, + ['/etc/apache2/conf%..*/'] = detect_apache, + ['/etc/apache2/mods%-.*/'] = detect_apache, + ['/etc/apache2/sites%-.*/'] = detect_apache, + ['/etc/httpd/conf%..*/'] = detect_apache, + ['/etc/httpd/conf%.d/.*%.conf'] = detect_apache, + ['/etc/httpd/mods%-.*/'] = detect_apache, + ['/etc/httpd/sites%-.*/'] = detect_apache, ['/etc/proftpd/.*%.conf'] = starsetf('apachestyle'), ['/etc/proftpd/conf%..*/'] = starsetf('apachestyle'), ['/etc/cdrdao%.conf$'] = 'cdrdaoconf', @@ -2193,13 +2196,13 @@ local pattern = { }, ['%.conf'] = { ['^proftpd%.conf'] = starsetf('apachestyle'), - ['^access%.conf'] = detect_apache_dotconf, - ['^apache%.conf'] = detect_apache_dotconf, - ['^apache2%.conf'] = detect_apache_dotconf, - ['^httpd%.conf'] = detect_apache_dotconf, - ['^httpd%-.*%.conf'] = detect_apache_dotconf, - ['^proxy%-html%.conf'] = detect_apache_dotconf, - ['^srm%.conf'] = detect_apache_dotconf, + ['^access%.conf'] = detect_apache, + ['^apache%.conf'] = detect_apache, + ['^apache2%.conf'] = detect_apache, + ['^httpd%.conf'] = detect_apache, + ['^httpd%-.*%.conf'] = detect_apache, + ['^proxy%-html%.conf'] = detect_apache, + ['^srm%.conf'] = detect_apache, ['asterisk/.*%.conf'] = starsetf('asterisk'), ['asterisk.*/.*voicemail%.conf'] = starsetf('asteriskvm'), ['^dictd.*%.conf$'] = 'dictdconf', @@ -2372,7 +2375,7 @@ local pattern = { ['/app%-defaults/'] = starsetf('xdefaults'), ['^Xresources'] = starsetf('xdefaults'), -- Increase priority to run before the pattern below - ['^XF86Config%-4'] = starsetf(detect.xfree86_v4, { priority = -math.huge + 1 }), + ['^XF86Config%-4'] = starsetf(detect.xfree86_v4, -math.huge + 1), ['^XF86Config'] = starsetf(detect.xfree86_v3), ['Xmodmap$'] = 'xmodmap', ['xmodmap'] = starsetf('xmodmap'), @@ -2398,8 +2401,10 @@ local pattern = { --- @type table local pattern_lookup = {} +--- @param a vim.filetype.mapping.sorted +--- @param b vim.filetype.mapping.sorted local function compare_by_priority(a, b) - return a[next(a)][2].priority > b[next(b)][2].priority + return a[4] > b[4] end --- @param pat string @@ -2409,30 +2414,30 @@ local function parse_pattern(pat) end --- @param t table ---- @return vim.filetype.mapping[] ---- @return vim.filetype.mapping[] +--- @return vim.filetype.mapping.sorted[] +--- @return vim.filetype.mapping.sorted[] local function sort_by_priority(t) -- Separate patterns with non-negative and negative priority because they -- will be processed separately - local pos = {} --- @type vim.filetype.mapping[] - local neg = {} --- @type vim.filetype.mapping[] + local pos = {} --- @type vim.filetype.mapping.sorted[] + local neg = {} --- @type vim.filetype.mapping.sorted[] for parent, ft_map in pairs(t) do pattern_lookup[parent] = pattern_lookup[parent] or parse_pattern(parent) for pat, maptbl in pairs(ft_map) do - local ft = type(maptbl) == 'table' and maptbl[1] or maptbl + local ft_or_fun = type(maptbl) == 'table' and maptbl[1] or maptbl assert( - type(ft) == 'string' or type(ft) == 'function', + type(ft_or_fun) == 'string' or type(ft_or_fun) == 'function', 'Expected string or function for filetype' ) -- Parse pattern for common data and cache it once pattern_lookup[pat] = pattern_lookup[pat] or parse_pattern(pat) - local opts = (type(maptbl) == 'table' and type(maptbl[2]) == 'table') and maptbl[2] or {} - opts.parent = opts.parent or parent - opts.priority = opts.priority or 0 + --- @type vim.filetype.mapopts? + local opts = (type(maptbl) == 'table' and type(maptbl[2]) == 'table') and maptbl[2] or nil + local priority = opts and opts.priority or 0 - table.insert(opts.priority >= 0 and pos or neg, { [pat] = { ft, opts } }) + table.insert(priority >= 0 and pos or neg, { parent, pat, ft_or_fun, priority }) end end @@ -2643,7 +2648,8 @@ local function match_pattern(name, path, tail, pat, try_all_candidates) if some_env_missing then return nil end - pat, has_slash = expanded, expanded:find('/') ~= nil + pat = expanded + has_slash = has_slash or expanded:find('/') ~= nil end -- Try all possible candidates to make parent patterns not depend on slash presence @@ -2665,14 +2671,13 @@ end --- @param name string --- @param path string --- @param tail string ---- @param pattern_sorted vim.filetype.mapping[] +--- @param pattern_sorted vim.filetype.mapping.sorted[] --- @param parent_matches table --- @param bufnr integer? local function match_pattern_sorted(name, path, tail, pattern_sorted, parent_matches, bufnr) - for i = 1, #pattern_sorted do - local pat, ft_data = next(pattern_sorted[i]) + for _, p in ipairs(pattern_sorted) do + local parent, pat, ft_or_fn = p[1], p[2], p[3] - local parent = ft_data[2].parent local parent_is_matched = parent_matches[parent] if parent_is_matched == nil then parent_matches[parent] = match_pattern(name, path, tail, parent, true) ~= nil @@ -2682,7 +2687,7 @@ local function match_pattern_sorted(name, path, tail, pattern_sorted, parent_mat if parent_is_matched then local matches = match_pattern(name, path, tail, pat, false) if matches then - local ft, on_detect = dispatch(ft_data[1], path, bufnr, matches) + local ft, on_detect = dispatch(ft_or_fn, path, bufnr, matches) if ft then return ft, on_detect end -- cgit From 295f98c8e0d991bdf336d1300abafaa4cad841d1 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 11 Nov 2024 22:30:04 +0100 Subject: vim-patch:9.1.0853: filetype: kubernetes config file not recognized Problem: filetype: kubernetes config file not recognized Solution: detect '/.kube/config' file as yaml filetype (Jonathan Lopez) closes: vim/vim#11076 https://github.com/vim/vim/commit/6fbf63de865001dedafc227465e651926cf6f6dc Co-authored-by: Jonathan Lopez --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index eda4c6a479..f22d814647 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2148,6 +2148,7 @@ local pattern = { ['/sway/config$'] = 'swayconfig', ['/%.cargo/config$'] = 'toml', ['/%.bundle/config$'] = 'yaml', + ['/%.kube/config$'] = 'yaml', }, ['/%.'] = { ['/%.aws/credentials$'] = 'confini', -- cgit From fbbb9d6f7bc8fd3ed309d195d723894572549cf8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 16 Nov 2024 08:42:12 +0800 Subject: vim-patch:9.1.0866: filetype: LLVM IR files are not recognized (#31228) Problem: filetype: LLVM IR files are not recognized Solution: detect '*.ll' files either as lifelines or llvm filetype (Wu, Zhenyu) closes: vim/vim#15824 https://github.com/vim/vim/commit/bc32bbddcfc2671158a4780838766ed2d1e14fa6 N/A patch: vim-patch:7e4b861: runtime(filetype): remove duplicated *.org file pattern Co-authored-by: Wu, Zhenyu --- runtime/lua/vim/filetype.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index f22d814647..3b3c4481f2 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -682,7 +682,6 @@ local extension = { l = 'lex', lhs = 'lhaskell', lidr = 'lidris2', - ll = 'lifelines', ly = 'lilypond', ily = 'lilypond', liquid = 'liquid', @@ -697,6 +696,7 @@ local extension = { lt = 'lite', lite = 'lite', livemd = 'livebook', + ll = detect.ll, log = detect.log, Log = detect.log, LOG = detect.log, -- cgit From c12be1249f5e44289acdfeaf0f059c7942593275 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 19 Nov 2024 08:41:02 +0100 Subject: vim-patch:9.1.0873: filetype: Vivado files are not recognized Problem: filetype: Vivado files are not recognized Solution: detect '*.mss' files as 'mss' filetype (Wu, Zhenyu) references: https://docs.amd.com/r/2020.2-English/ug1400-vitis-embedded/Microprocessor-Software-Specification-MSS closes: vim/vim#15907 https://github.com/vim/vim/commit/a87462a498a883e12ad7699b26bd28f4600b68c6 Co-authored-by: Wu, Zhenyu --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 3b3c4481f2..e1e73d63fe 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -792,6 +792,7 @@ local extension = { mof = 'msidl', odl = 'msidl', msql = 'msql', + mss = 'mss', mu = 'mupad', mush = 'mush', mustache = 'mustache', -- cgit