From 5977d6a7e180cbab6ec1eed3ecf7aee4ad605bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 26 Mar 2023 18:28:49 +0200 Subject: [PATCH] feat(nvim): add various keybinds --- modules/programs/nvim/default.nix | 2 +- modules/programs/nvim/init.lua | 6 ++---- modules/programs/nvim/keybinds.lua | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 modules/programs/nvim/keybinds.lua diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 2e09fc8..74e0c28 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -44,7 +44,7 @@ in extraLuaConfig = lib.concatLines ( builtins.map builtins.readFile - [ ./options.lua ./init.lua ] + [ ./options.lua ./keybinds.lua ./init.lua ] ); extraPackages = with pkgs; [ alejandra diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index a24dc95..8f97399 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -1,7 +1,5 @@ require("impatient") -local wk = require("which-key") - require("nvim-treesitter.configs").setup({ sync_install = false, auto_install = false, @@ -142,7 +140,7 @@ vim.o.statuscolumn = "%= " .. "%= " -- spacing between end of column and start of text -- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself -wk.register({ +require("which-key").register({ z = { R = { require("ufo").openAllFolds, "Open all folds" }, M = { require("ufo").closeAllFolds, "Close all folds" }, @@ -171,7 +169,7 @@ require("lspsaga").setup({ local lspconfig = require("lspconfig") local on_attach_def = function(_, bufnr) - wk.register({ + require("which-key").register({ K = { "Lspsaga hover_doc ++quiet", "show info" }, [""] = { l = { diff --git a/modules/programs/nvim/keybinds.lua b/modules/programs/nvim/keybinds.lua new file mode 100644 index 0000000..52ae2e2 --- /dev/null +++ b/modules/programs/nvim/keybinds.lua @@ -0,0 +1,21 @@ +-- buffers +require("which-key").register({ + b = { + name = "buffers", + b = { "Telescope buffers", "List buffers" }, + d = { "bd", "Delete buffer" }, + n = { "bnext", "Next buffer" }, + p = { "bprevious", "Previous buffer" }, + }, +}) + +-- Clear search with +require("which-key").register({ + [""] = { "noh", "Escape and clear hlsearch", mode = { "n", "i" } }, +}) + +-- better indenting +require("which-key").register({ + ["<"] = { ""] = { ">gv", "Shift right" }, +}, { mode = "v" })