From b947312bfc8e0d987deca392961a833e3ac7be1e Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Thu, 14 Sep 2023 07:48:13 -0600 Subject: lua: filetype: use alt_name field to alias to other lexers This obviously draws on the alt_name parameter used in scintillua but rather then passing it all the way up to the chain to lexers.load() we will just handle it in set_filetype(). 8a420ec accidently readded detection for the removed git-commit lexer which somehow went unnoticed until we readded caching for the new lexers. Instead of just removing it we can alias to the diff filetype and only set the colorcolumn for commit messages. This fixes the incorrect behaviour of adding a colorcolumn to diff and patch files and thus completely reverts 0cc684f. --- lua/plugins/filetype.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lua') diff --git a/lua/plugins/filetype.lua b/lua/plugins/filetype.lua index aa00dc3..23c3600 100644 --- a/lua/plugins/filetype.lua +++ b/lua/plugins/filetype.lua @@ -99,8 +99,7 @@ vis.ftdetect.filetypes = { ext = { "%.desktop$" }, }, diff = { - ext = { "%.diff$", "%.patch$", "%.rej$", "^COMMIT_EDITMSG$" }, - cmd = { "set colorcolumn 72" }, + ext = { "%.diff$", "%.patch$", "%.rej$" }, }, dmd = { ext = { "%.d$", "%.di$" }, @@ -168,6 +167,7 @@ vis.ftdetect.filetypes = { ext = { "%.feature$" }, }, ['git-commit'] = { + alt_name = "diff", ext = { "^COMMIT_EDITMSG$" }, cmd = { "set colorcolumn 72" }, }, @@ -504,9 +504,10 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) end if not vis.lexers.property then return end local path = vis.lexers.property['lexer.lpeg.home']:gsub(';', '/?.lua;') .. '/?.lua' - local lexpath = package.searchpath('lexers/'..syntax, path) + local lexname = filetype.alt_name or syntax + local lexpath = package.searchpath('lexers/'..lexname, path) if lexpath ~= nil then - win:set_syntax(syntax) + win:set_syntax(lexname) else win:set_syntax(nil) end -- cgit v1.2.3