return { { "neovim/nvim-lspconfig", config = function() -- Reserve a space in the gutter vim.opt.signcolumn = 'yes' vim.api.nvim_create_autocmd('LspAttach', { desc = 'LSP actions', callback = function(event) local opts = { buffer = event.buffer, remap = false } local client = vim.lsp.get_client_by_id(event.data.client_id) -- Enable built-in completion if supported if client and client.supports_method('textDocument/completion') then vim.lsp.completion.enable(true, client.id, event.buf, { autotrigger = true }) end -- LSP keybindings vim.keymap.set('n', 'gd', function() vim.lsp.buf.definition() end, opts) vim.keymap.set('n', 'k', function() vim.lsp.buf.hover() end, opts) vim.keymap.set('n', 'r', function() vim.lsp.buf.rename() end, opts) vim.keymap.set('n', 'a', function() vim.lsp.buf.code_action() end, opts) vim.keymap.set('n', 'gr', function() vim.lsp.buf.references() end, opts) vim.keymap.set('n', 'd', function() vim.diagnostic.open_float() end, opts) vim.keymap.set('n', '[d', function() vim.diagnostic.goto_prev() end, opts) vim.keymap.set('n', ']d', function() vim.diagnostic.goto_next() end, opts) vim.keymap.set('n', 'Q', function() vim.diagnostic.set_qflist() end, opts) vim.keymap.set('n', 'F', function() vim.lsp.buf.format() end, opts) -- Built-in completion keybindings vim.keymap.set('i', '', '', opts) vim.keymap.set('i', '', function() if vim.fn.pumvisible() == 1 then return '' else return '' end end, { buffer = event.buffer, expr = true }) end, }) vim.lsp.config('rust_analyzer', { settings = { ["rust-analyzer"] = { checkOnSave = { allFeatures = true, command = { "clippy" }, }, procMacro = { enable = true, ignored = { leptos_macro = { "server" }, }, }, cargo = { allFeatures = true, autoreload = true, }, rustfmt = { overrideCommand = { "leptosfmt", "--stdin", "--rustfmt" }, }, callInfo = { full = true }, lens = { enable = true, references = true, implementations = true, enumVariantReferences = true, methodReferences = true, }, inlayHints = { enable = true, typeHints = true, parameterHints = true, }, hoverActions = { enable = true, }, } } }) vim.lsp.enable('rust_analyzer') vim.lsp.enable('pylsp') vim.lsp.enable('ruff') vim.lsp.enable('ts_ls') vim.lsp.enable('oxlint') -- Workaround for rust_analyzer diagnostic issue for _, method in ipairs({ 'textDocument/diagnostic', 'workspace/diagnostic' }) do local default_diagnostic_handler = vim.lsp.handlers[method] vim.lsp.handlers[method] = function(err, result, context, config) if err ~= nil and err.code == -32802 then return end return default_diagnostic_handler(err, result, context, config) end end end, } }