From 64361811de7fb26f2a78cfa996dbea15e2fb32c3 Mon Sep 17 00:00:00 2001 From: sha1n Date: Tue, 6 Oct 2026 15:22:54 +0300 Subject: [PATCH] fix(nvim): highlight bash files and keep regex highlighting without a query Co-Authored-By: Claude Opus 5.5 (1M context) --- config/nvim/init.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 48d6a1d..55057df 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -175,12 +175,15 @@ vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iag -- Treesitter Config -- :ProfileSync installs these; nothing compiles at startup. -local parsers = { "c", "cpp", "go", "lua", "python", "rust", "tsx", "typescript", "vimdoc", "vim" } +local parsers = { "bash", "c", "cpp", "go", "lua", "python", "rust", "tsx", "typescript", "vimdoc", "vim" } vim.api.nvim_create_autocmd('FileType', { - callback = function() - -- Fails for filetypes without an installed parser; those keep regex highlighting. - if pcall(vim.treesitter.start) then + callback = function(args) + -- vim.treesitter.start turns off regex highlighting even when no highlights query exists, + -- as with a parser left behind by the old nvim-treesitter master layout. Those keep regex highlighting. + local lang = vim.treesitter.language.get_lang(args.match) + local ok, highlights = pcall(vim.treesitter.query.get, lang or '', 'highlights') + if ok and highlights and pcall(vim.treesitter.start, args.buf, lang) then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end end,