From 0982ebf3349f62e060954f3ae4c9a880a7e4e17b Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sat, 25 Nov 2023 14:13:26 +0200 Subject: [PATCH] Move plugin keymaps to lazy keys option --- home/.config/nvim/lua/plugins/neoformat.lua | 12 ++++--- home/.config/nvim/lua/plugins/noice.lua | 19 ++++------ home/.config/nvim/lua/plugins/nvim-tree.lua | 2 +- home/.config/nvim/lua/plugins/statuscol.lua | 2 +- home/.config/nvim/lua/plugins/telescope.lua | 38 ++++++++++++-------- home/.config/nvim/lua/plugins/treesitter.lua | 4 ++- home/.config/nvim/lua/plugins/which-key.lua | 7 ++-- 7 files changed, 46 insertions(+), 38 deletions(-) diff --git a/home/.config/nvim/lua/plugins/neoformat.lua b/home/.config/nvim/lua/plugins/neoformat.lua index 988eef3..cc63e23 100644 --- a/home/.config/nvim/lua/plugins/neoformat.lua +++ b/home/.config/nvim/lua/plugins/neoformat.lua @@ -1,9 +1,11 @@ -- Formatter plugin return { "sbdchd/neoformat", - config = function() - require("which-key").register({ - f = { "Neoformat", "Format with Neoformat" }, - }, { prefix = "" }) - end, + keys = { + { + desc = "Format with Neoformat", + "f", + "Neoformat", + }, + }, } diff --git a/home/.config/nvim/lua/plugins/noice.lua b/home/.config/nvim/lua/plugins/noice.lua index d4dbcaf..cf869a8 100644 --- a/home/.config/nvim/lua/plugins/noice.lua +++ b/home/.config/nvim/lua/plugins/noice.lua @@ -19,16 +19,11 @@ return { lsp_doc_border = true, }, }, - config = function(_, opts) - require("noice").setup(opts) - - require("which-key").register({ - d = { - function() - vim.cmd("NoiceDismiss") - end, - "Dismiss notifications", - }, - }, { prefix = "" }) - end, + keys = { + { + desc = "Dismiss notifications", + "d", + "NoiceDismiss", + }, + }, } diff --git a/home/.config/nvim/lua/plugins/nvim-tree.lua b/home/.config/nvim/lua/plugins/nvim-tree.lua index 760c96f..8646ec4 100644 --- a/home/.config/nvim/lua/plugins/nvim-tree.lua +++ b/home/.config/nvim/lua/plugins/nvim-tree.lua @@ -17,9 +17,9 @@ return { }, keys = { { + desc = "Open/close nvim-tree", "o", "NvimTreeToggle", - desc = "Open/close nvim-tree", }, }, } diff --git a/home/.config/nvim/lua/plugins/statuscol.lua b/home/.config/nvim/lua/plugins/statuscol.lua index 8e0c947..05d010c 100644 --- a/home/.config/nvim/lua/plugins/statuscol.lua +++ b/home/.config/nvim/lua/plugins/statuscol.lua @@ -3,7 +3,7 @@ return { dependencies = { { "lewis6991/gitsigns.nvim", - opts = {}, + config = true, }, }, config = function() diff --git a/home/.config/nvim/lua/plugins/telescope.lua b/home/.config/nvim/lua/plugins/telescope.lua index b1f877e..70d4dd6 100644 --- a/home/.config/nvim/lua/plugins/telescope.lua +++ b/home/.config/nvim/lua/plugins/telescope.lua @@ -54,27 +54,35 @@ return { }, }, }, + keys = { + { + desc = "Open Telescope", + "", + "Telescope", + }, + { + desc = "Change directories", + "cd", + "Telescope cder", + }, + { + desc = "Find files", + "", + "Telescope find_files", + }, + { + desc = "Grep files", + "", + "Telescope live_grep", + }, + }, config = function(_, opts) local telescope = require("telescope") telescope.setup(opts) - -- Add extensions + -- Load extensions telescope.load_extension("fzf") telescope.load_extension("ui-select") telescope.load_extension("cder") - - -- Keybinds - local builtin = require("telescope.builtin") - require("which-key").register({ - cd = { - function() - vim.cmd("Telescope cder") - end, - "Change directories", - }, - [""] = { vim.cmd.Telescope, "Open Telescope" }, - [""] = { builtin.find_files, "Telescope find files" }, - [""] = { builtin.live_grep, "Telescope live grep" }, - }) end, } diff --git a/home/.config/nvim/lua/plugins/treesitter.lua b/home/.config/nvim/lua/plugins/treesitter.lua index 35fc532..71c5d00 100644 --- a/home/.config/nvim/lua/plugins/treesitter.lua +++ b/home/.config/nvim/lua/plugins/treesitter.lua @@ -3,7 +3,9 @@ return { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", init = function(plugin) - require("nvim-treesitter.install").update({ with_sync = true }) + require("nvim-treesitter.install").update({ + with_sync = true, + }) end, ---@type TSConfig ---@diagnostic disable-next-line: missing-fields diff --git a/home/.config/nvim/lua/plugins/which-key.lua b/home/.config/nvim/lua/plugins/which-key.lua index 643b2c7..51c2226 100644 --- a/home/.config/nvim/lua/plugins/which-key.lua +++ b/home/.config/nvim/lua/plugins/which-key.lua @@ -1,4 +1,5 @@ -- Display possible keybinds +-- Here I have also defined some generic keybinds -- Plugin specific keybinds are set up in plugin configuration file return { "folke/which-key.nvim", @@ -7,12 +8,12 @@ return { wk.setup() wk.register({ - h = { "nohlsearch", "Turn off search highlight" }, + h = { "nohlsearch", "Turn off search highlight" }, }, { prefix = "" }) wk.register({ - [""] = { "bnext", "Next buffer" }, - [""] = { "bprevious", "Previous buffer" }, + [""] = { "bnext", "Next buffer" }, + [""] = { "bprevious", "Previous buffer" }, }) -- Exit terminal insert mode with esc