diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 6592919d..c743ac0c 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -51,6 +51,29 @@ map({ "n" }, "", "H", { remap = false }) -- Duplicate and comment line map({ "n" }, "yc", '"zyygcc"zp', { remap = true, silent = true, desc = "Duplicate and comment line" }) +local function is_lsp_attached() + local clients = vim.lsp.get_clients({ bufnr = 0 }) + return #clients > 0 +end + +local cptoggle = Snacks.toggle.new({ + name = "Lsp", + -- map = vim.keymap.set, + which_key = true, + get = function() + return not is_lsp_attached() + end, + notify = true, + set = function(state) + if state then + vim.cmd("LspStart") + else + vim.cmd("LspStop") + end + end, +}) +Snacks.toggle.map(cptoggle, "at", { desc = "Toggle Copilot" }) + -- better quit map("n", "", "qa", { desc = "Quit All" })