From 7281a640933497292817e27d1f32680bf5d0792f Mon Sep 17 00:00:00 2001 From: Alexander Goussas Date: Sun, 23 Feb 2025 21:03:54 -0500 Subject: [PATCH] add lsp keybindings --- nvim/.config/nvim/init.lua | 40 ++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index e70aada..5da0c0f 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -105,23 +105,24 @@ require("lazy").setup({ { "neovim/nvim-lspconfig", config = function() - -- Some mappings that LSP sets by default - -- grn -> rename - -- gra -> code action - -- grr -> references - -- gO -> document symbol - -- C-S -> signature help - local lspconfig = require('lspconfig') -- Language servers lspconfig.gopls.setup({}) lspconfig.pylsp.setup({}) + lspconfig.svelte.setup({}) -- npm install -g typescript typescript-language-server lspconfig.ts_ls.setup({}) + -- npm install -g @elm-tooling/elm-language-server + -- npm install -g elm elm-test elm-format + -- npm install -g elm-review + lspconfig.elmls.setup({}) + + lspconfig.gleam.setup({}) + -- brew install rust-analyzer lspconfig.rust_analyzer.setup({}) @@ -134,10 +135,7 @@ require("lazy").setup({ vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) local client = vim.lsp.get_client_by_id(args.data.client_id) - -- TODO: Check from which version is this API available - -- if client:supports_method('textDocument/completion') then - -- vim.lsp.completion.enable(true, client.id, args.buf, {autotrigger = true}) - -- end + if client:supports_method('textDocument/formatting') then vim.api.nvim_create_autocmd('BufWritePre', { buffer = args.buf, @@ -146,6 +144,16 @@ require("lazy").setup({ end, }) end + + vim.keymap.set('n', 'e', vim.diagnostic.open_float, { buffer = args.buf }) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { buffer = args.buf }) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, { buffer = args.buf }) + vim.keymap.set('n', 'rr', vim.lsp.buf.references, { buffer = args.buf }) + vim.keymap.set( + 'n', + 'tih', + function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, + { buffer = args.buf }) end, }) end @@ -164,16 +172,6 @@ require("lazy").setup({ top_down = false, render = "wrapped-compact", }) - - require("noice").setup({ - presets = { - bottom_search = true, - command_palette = true, - long_message_to_split = true, - inc_rename = false, - lsp_doc_border = false, - }, - }) end } }, -- 2.43.0