diff --git a/nvim/lua/core/keymaps.lua b/nvim/lua/core/keymaps.lua index dae48d6..cb50cc8 100644 --- a/nvim/lua/core/keymaps.lua +++ b/nvim/lua/core/keymaps.lua @@ -18,6 +18,21 @@ local map = function(modes, lhs, rhs, opts) vim.keymap.set(mode, lhs, rhs, options) end end + +local copilot_toggle_opts = { + name = "Copilot Completion", + get = function() + return not require("copilot.client").is_disabled() + end, + set = function(state) + if state then + require("copilot.command").enable() + else + require("copilot.command").disable() + end + end, +} + -- stylua: ignore start -- better up/down @@ -73,27 +88,15 @@ map("n", "dg", function() utils.telescope_diff_from_history() end, { des -- toggle options utils.toggle_global_boolean("autoformat", "Autoformat"):map("ta") +snacks.toggle(copilot_toggle_opts):map("tc") snacks.toggle.option("spell", { name = "Spelling" }):map("us") snacks.toggle.option("wrap", { name = "Wrap" }):map("tw") snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("tL") snacks.toggle.diagnostics():map("td") snacks.toggle.line_number():map("tl") -snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("tc") +snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("tC") snacks.toggle.treesitter():map("tT") if vim.lsp.inlay_hint then snacks.toggle.inlay_hints():map("th") end -snacks.toggle({ - name = "Copilot Completion", - get = function() - return not require("copilot.client").is_disabled() - end, - set = function(state) - if state then - require("copilot.command").enable() - else - require("copilot.command").disable() - end - end, -}):map("tc") -- browse to git repo map("n", "gb", function() snacks.gitbrowse() end, { desc = "Git Browse" })