diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 4398c40a..ec2f0a19 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim Last change: 2025 October 09 +*LazyVim.txt* For Neovim Last change: 2025 October 10 ============================================================================== Table of Contents *LazyVim-table-of-contents* diff --git a/lua/lazyvim/plugins/extras/ai/sidekick.lua b/lua/lazyvim/plugins/extras/ai/sidekick.lua index 52597b0e..5b2c0976 100644 --- a/lua/lazyvim/plugins/extras/ai/sidekick.lua +++ b/lua/lazyvim/plugins/extras/ai/sidekick.lua @@ -74,6 +74,11 @@ return { -- require("sidekick.cli").select({ filter = { installed = true } }) desc = "Select CLI", }, + { + "ad", + function() require("sidekick.cli").close() end, + desc = "Detach a CLI Session", + }, { "at", function() require("sidekick.cli").send({ msg = "{this}" }) end, diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 78f1b3b2..5106da4e 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -21,12 +21,13 @@ return { event = { "LazyFile", "VeryLazy" }, cmd = { "TSUpdate", "TSInstall", "TSLog", "TSUninstall" }, opts_extend = { "ensure_installed" }, + ---@alias lazyvim.TSFeat { enable?: boolean, disable?: string[] } ---@class lazyvim.TSConfig: TSConfig opts = { -- LazyVim config for treesitter - indent = { enable = true }, - highlight = { enable = true }, - folds = { enable = true }, + indent = { enable = true }, ---@type lazyvim.TSFeat + highlight = { enable = true }, ---@type lazyvim.TSFeat + folds = { enable = true }, ---@type lazyvim.TSFeat ensure_installed = { "bash", "c", @@ -99,22 +100,32 @@ return { vim.api.nvim_create_autocmd("FileType", { group = vim.api.nvim_create_augroup("lazyvim_treesitter", { clear = true }), callback = function(ev) - if not LazyVim.treesitter.have(ev.match) then + local ft, lang = ev.match, vim.treesitter.language.get_lang(ev.match) + if not LazyVim.treesitter.have(ft) then return end + ---@param feat string + ---@param query string + local function enabled(feat, query) + local f = opts[feat] or {} ---@type lazyvim.TSFeat + return f.enable ~= false + and not (type(f.disable) == "table" and vim.tbl_contains(f.disable, lang)) + and LazyVim.treesitter.have(ft, query) + end + -- highlighting - if vim.tbl_get(opts, "highlight", "enable") ~= false then + if enabled("highlight", "highlights") then pcall(vim.treesitter.start) end -- indents - if vim.tbl_get(opts, "indent", "enable") ~= false and LazyVim.treesitter.have(ev.match, "indents") then + if enabled("indent", "indents") then LazyVim.set_default("indentexpr", "v:lua.LazyVim.treesitter.indentexpr()") end -- folds - if vim.tbl_get(opts, "folds", "enable") ~= false and LazyVim.treesitter.have(ev.match, "folds") then + if enabled("folds", "folds") then if LazyVim.set_default("foldmethod", "expr") then LazyVim.set_default("foldexpr", "v:lua.LazyVim.treesitter.foldexpr()") end