From d03b02e2caf4b856d5ea164e998859128a954403 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Thu, 26 Jun 2025 00:18:00 -0400 Subject: [PATCH] nvim: Fix LSP tab/enter; Fix multi-LSP formatting; Add ruff and neocmakelsp --- nvim/.config/nvim/lua/lsp.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index c0a7aa7..7d672b4 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -20,6 +20,24 @@ vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + -- Make Tab accept the selected completion + vim.keymap.set('i', '', function() + if vim.fn.pumvisible() == 1 then + return '' + else + return '' + end + end, { expr = true }) + + -- Make Enter just insert a newline (don't accept completion) + vim.keymap.set('i', '', function() + if vim.fn.pumvisible() == 1 then + return '' + else + return '' + end + end, { expr = true }) + -- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y| if client:supports_method('textDocument/completion') then -- Trigger autocompletion on EVERY keypress. May be slow! @@ -30,10 +48,10 @@ vim.api.nvim_create_autocmd('LspAttach', { end vim.keymap.set('n', '', - function() vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) end, + function() vim.lsp.buf.format({ bufnr = args.buf, timeout_ms = 1000 }) end, { desc = "Format" }) vim.keymap.set('i', '', - function() vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) end, + function() vim.lsp.buf.format({ bufnr = args.buf, timeout_ms = 1000 }) end, { desc = "Format" }) -- if client:supports_method('textDocument/implementation') then