diff options
Diffstat (limited to 'nvim/lua/config/keymaps.lua')
| -rw-r--r-- | nvim/lua/config/keymaps.lua | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..c54247c --- /dev/null +++ b/nvim/lua/config/keymaps.lua | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | local M = {} | ||
| 2 | |||
| 3 | local map = vim.keymap.set | ||
| 4 | |||
| 5 | function M.lsp(buffer, client) | ||
| 6 | local opts = { | ||
| 7 | buffer = buffer, | ||
| 8 | noremap = true, | ||
| 9 | silent = true, | ||
| 10 | } | ||
| 11 | |||
| 12 | map("n", "gd", vim.lsp.buf.definition, opts) | ||
| 13 | map("n", "gD", vim.lsp.buf.declaration, opts) | ||
| 14 | map("n", "gr", vim.lsp.buf.references, opts) | ||
| 15 | map("n", "gi", vim.lsp.buf.implementation, opts) | ||
| 16 | map("n", "K", vim.lsp.buf.hover, opts) | ||
| 17 | map("n", "<leader>rn", vim.lsp.buf.rename, opts) | ||
| 18 | map("n", "<leader>ca", vim.lsp.buf.code_action, opts) | ||
| 19 | map("n", "<leader>cf", function() vim.lsp.buf.format({ async = true; }) end, opts) | ||
| 20 | |||
| 21 | if client and client.name == "clangd" then | ||
| 22 | map("n", "<leader>hs", "<cmd>ClangdSwitchSourceHeader<cr>", opts) | ||
| 23 | end | ||
| 24 | end | ||
| 25 | |||
| 26 | function M.telescope() | ||
| 27 | local opts = { | ||
| 28 | noremap = true, | ||
| 29 | silent = true, | ||
| 30 | } | ||
| 31 | |||
| 32 | map("n", "<leader>ff", function() | ||
| 33 | require("telescope.builtin").find_files() | ||
| 34 | end, opts) | ||
| 35 | |||
| 36 | map("n", "<leader>fg", function() | ||
| 37 | require("telescope.builtin").live_grep() | ||
| 38 | end, opts) | ||
| 39 | |||
| 40 | map("n", "<leader>fb", function() | ||
| 41 | require("telescope.builtin").buffers() | ||
| 42 | end, opts) | ||
| 43 | |||
| 44 | map("n", "<leader>fh", function() | ||
| 45 | require("telescope.builtin").help_tags() | ||
| 46 | end, opts) | ||
| 47 | |||
| 48 | map("n", "<leader>dd", function() | ||
| 49 | require("telescope.builtin").diagnostics() | ||
| 50 | end, opts) | ||
| 51 | end | ||
| 52 | |||
| 53 | function M.global() | ||
| 54 | local opts = { | ||
| 55 | noremap = true, | ||
| 56 | silent = true, | ||
| 57 | } | ||
| 58 | |||
| 59 | map("n", "ö", "}", opts) | ||
| 60 | map("n", "ä", "{", opts) | ||
| 61 | |||
| 62 | map("n", "<leader>K", function() | ||
| 63 | vim.diagnostic.open_float({ scope = "cursor", border = "rounded" }) | ||
| 64 | end, opts) | ||
| 65 | map("n", "<leader>q", vim.diagnostic.setloclist, opts) | ||
| 66 | |||
| 67 | map("n", "[d", function() | ||
| 68 | vim.diagnostic.jump_prev({ wrap = false }) | ||
| 69 | end, opts) | ||
| 70 | |||
| 71 | map("n", "]d", function() | ||
| 72 | vim.diagnostic.jump_next({ wrap = false }) | ||
| 73 | end, opts) | ||
| 74 | |||
| 75 | map("n", "[e", function() | ||
| 76 | vim.diagnostic.jump_prev({ | ||
| 77 | severity = vim.diagnostic.severity.ERROR, | ||
| 78 | wrap = false | ||
| 79 | }) | ||
| 80 | end, opts) | ||
| 81 | |||
| 82 | map("n", "]e", function() | ||
| 83 | vim.diagnostic.jump_next({ | ||
| 84 | severity = vim.diagnostic.severity.ERROR, | ||
| 85 | wrap = false | ||
| 86 | }) | ||
| 87 | end, opts) | ||
| 88 | |||
| 89 | vim.keymap.set("n", "<leader>ts", function() | ||
| 90 | vim.opt_local.spell = not vim.opt_local.spell:get() | ||
| 91 | end, { desc = "Toggle spell checking" }) | ||
| 92 | end | ||
| 93 | |||
| 94 | return M | ||
