diff --git a/nvim/lsp/clangd.lua b/nvim/lsp/clangd.lua index f242c06..67d7144 100644 --- a/nvim/lsp/clangd.lua +++ b/nvim/lsp/clangd.lua @@ -48,7 +48,7 @@ return { }, on_attach = function() utils.set_keymap_list({ - { "ko", switch_source_header, }, + { "h", switch_source_header, }, }) end, } diff --git a/nvim/lua/format_handler.lua b/nvim/lua/format_handler.lua index 6d103bc..b37242f 100644 --- a/nvim/lua/format_handler.lua +++ b/nvim/lua/format_handler.lua @@ -1,4 +1,3 @@ -local utils = require("utils") local M = {} M.format_on_save = true @@ -21,16 +20,11 @@ function M.setup() local user_commands = { { "FormatEnable", "lua require('format_handler').format_enable()" }, { "FormatDisable", "lua require('format_handler').format_disable()" }, + { "Format", "lua require('format_handler').format(true)" }, } for _, cmd in ipairs(user_commands) do vim.api.nvim_command("command! " .. cmd[1] .. " " .. cmd[2]) end - - utils.set_keymap_list({ - { "ff", function() M.format(true) end }, - { "fe", function() M.format_enable() end }, - { "fd", function() M.format_disable() end }, - }) end return M diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 236ec9a..deac34b 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -11,13 +11,12 @@ utils.foreach({ { "n", { - -- Using lspsaga for hover doc { "K", "", }, - -- Using lspsaga finder with gr which does references - { "grr", "", }, - { "gra", "", }, { "grn", "", }, + { "gra", "", }, + { "grr", "", }, { "gri", "", }, + { "gO", "", }, -- Navigation { "", "h", }, { "", "j", }, diff --git a/nvim/lua/lspsetup.lua b/nvim/lua/lspsetup.lua index 32ffb1b..ec309cd 100644 --- a/nvim/lua/lspsetup.lua +++ b/nvim/lua/lspsetup.lua @@ -1,6 +1,5 @@ local utils = require("utils") -local inlay_hints_handler = require("inlay_hints_handler") -local format_handler = require("format_handler") +local lsplib = require("lsplib") vim.lsp.config("*", { root_markers = { ".git" }, @@ -18,28 +17,6 @@ vim.api.nvim_create_autocmd("LspAttach", { local bufnr = args.buf assert(client, "LspAttach: client is nil") - inlay_hints_handler.add_buffer(bufnr) - - if client.server_capabilities.documentFormattingProvider then - vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 }) - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - callback = function() - format_handler.format() - end, - }) - end - - -- Built-in LSP completion. - -- Could switch to this if they just appeared automatically when typing, and didn't - -- only rely on showing when the servers completionCharacters are typed. - -- if client:supports_method("textDocument/completion") then - -- vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true }) - -- end - - utils.set_keymap_list({ - { "gd", function() vim.lsp.buf.definition({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } }, - { "gD", function() vim.lsp.buf.declaration({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } }, - }) + lsplib.configure_generic_client(client, bufnr) end }) diff --git a/nvim/lua/plugs/codecompanion.lua b/nvim/lua/plugs/codecompanion.lua index 289b112..b197d2e 100644 --- a/nvim/lua/plugs/codecompanion.lua +++ b/nvim/lua/plugs/codecompanion.lua @@ -44,18 +44,6 @@ return { roles = { user = "Martin", }, - keymaps = { - send = { - modes = { - i = { "", "" }, - }, - }, - completion = { - modes = { - i = "", - }, - }, - }, slash_commands = { ["buffer"] = { opts = { diff --git a/nvim/lua/plugs/neogit.lua b/nvim/lua/plugs/neogit.lua index 8f171d5..bb0c176 100644 --- a/nvim/lua/plugs/neogit.lua +++ b/nvim/lua/plugs/neogit.lua @@ -16,6 +16,6 @@ return { lazy = true, opts = {}, keys = { - { "g", function() require("neogit").open() end } + { "v", function() require("neogit").open() end } }, } diff --git a/nvim/lua/plugs/rustaceanvim.lua b/nvim/lua/plugs/rustaceanvim.lua index 9dc473c..ba13dbf 100644 --- a/nvim/lua/plugs/rustaceanvim.lua +++ b/nvim/lua/plugs/rustaceanvim.lua @@ -1,7 +1,3 @@ -local utils = require("utils") -local inlay_hints_handler = require("inlay_hints_handler") -local format_handler = require("format_handler") - return { "mrcjkb/rustaceanvim", version = "^5", @@ -17,24 +13,7 @@ return { }, }, server = { - on_attach = function(client, bufnr) - inlay_hints_handler.add_buffer(bufnr) - - if client.server_capabilities.documentFormattingProvider then - vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 }) - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - callback = function() - format_handler.format() - end, - }) - end - - utils.set_keymap_list({ - { "gd", function() vim.lsp.buf.definition({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } }, - { "gD", function() vim.lsp.buf.declaration({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } }, - }) - end, + on_attach = require("lsplib").configure_generic_client, } } end, diff --git a/nvim/lua/plugs/snacks.lua b/nvim/lua/plugs/snacks.lua index 8b3e16b..7876c0a 100644 --- a/nvim/lua/plugs/snacks.lua +++ b/nvim/lua/plugs/snacks.lua @@ -60,17 +60,26 @@ return { }, }, keys = { - { "gB", function() Snacks.gitbrowse() end, }, + { "gB", function() Snacks.gitbrowse() end, }, - { "z", function() Snacks.zen() end, }, + { "z", function() Snacks.zen() end, }, - { "f", function() Snacks.picker.smart({ multi = { "buffers", "files" } }) end, }, - { "g", function() Snacks.picker.grep() end, }, - { "l", function() Snacks.picker.git_log_file() end, }, - { "s", function() Snacks.picker.lsp_workspace_symbols() end, }, - { "n", function() Snacks.picker.notifications() end }, - { "rf", function() Snacks.rename.rename_file({}) end }, + { "f", function() Snacks.picker.smart({ multi = { "buffers", "files" } }) end, }, + { "g", function() Snacks.picker.grep() end, }, + { "l", function() Snacks.picker.git_log_file() end, }, + { "s", function() Snacks.picker.lsp_workspace_symbols() end, }, + { "o", function() Snacks.picker.lsp_symbols() end, }, + { "n", function() Snacks.picker.notifications() end }, + { "d", function() Snacks.picker.diagnostics() end }, + + { "e", function() Snacks.rename.rename_file({}) end }, + + { "gd", function() Snacks.picker.lsp_definitions() end, }, + { "gD", function() Snacks.picker.lsp_declarations() end, }, + { "gr", function() Snacks.picker.lsp_references() end, nowait = true, }, + { "gi", function() Snacks.picker.lsp_implementations() end, }, + { "gt", function() Snacks.picker.lsp_type_definitions() end, }, }, init = function() vim.api.nvim_create_autocmd("User", { diff --git a/nvim/lua/terminal.lua b/nvim/lua/terminal.lua index c95e852..15ca3f2 100644 --- a/nvim/lua/terminal.lua +++ b/nvim/lua/terminal.lua @@ -36,7 +36,7 @@ local function toggle_terminal() vim.api.nvim_command("startinsert") end -vim.keymap.set("n", "h", function() +vim.keymap.set("n", "t", function() toggle_terminal() require("window_management").autosize_windows() end)