Large keymapping overhaul

This commit is contained in:
Martin Larsson 2025-05-30 13:57:11 +02:00
parent 11af8c9452
commit 9fb6438efa
9 changed files with 27 additions and 81 deletions

View file

@ -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
})