From 51df129f131608f88726916d25ff330e15b0d1a8 Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Tue, 22 Jul 2025 20:37:40 -0400 Subject: [PATCH] Update to use nvim 0.11 lsp configs --- lazy-lock.json | 10 ++-- lua/config/opts.lua | 2 +- lua/plugins/lsp.lua | 111 ++++++++++++++------------------------------ 3 files changed, 41 insertions(+), 82 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 3eefca2..96e6b26 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,16 +1,14 @@ { - "claudecode.nvim": { "branch": "main", "commit": "da78309eaa2ca29fd38b22ed6155697ae1e65dc4" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, + "claudecode.nvim": { "branch": "main", "commit": "91357d810ccf92f6169f3754436901c6ff5237ec" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-lspconfig": { "branch": "master", "commit": "7ad4a11cc5742774877c529fcfb2702f7caf75e4" }, + "nvim-lspconfig": { "branch": "master", "commit": "f47cd681d7cb6048876a2e908b6d8ba1e530d152" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, - "tree-sitter-rstml": { "branch": "main", "commit": "4ab78c0bb76735dbf4e1bd1a2ec43e953949edb7" }, - "vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" }, + "tree-sitter-rstml": { "branch": "main", "commit": "2d4c2bc84a40d99a4e099ff7c6cf7f1bc5dc7806" }, + "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, "vim-gitgutter": { "branch": "main", "commit": "85ca3a087204e3a32cb2faa5d9d0451524e08720" } } diff --git a/lua/config/opts.lua b/lua/config/opts.lua index 1b75b4e..9ca3e0d 100644 --- a/lua/config/opts.lua +++ b/lua/config/opts.lua @@ -1,7 +1,7 @@ vim.g.mapleader = " " -- basic UI -vim.o.background = 'dark' +vim.o.background = 'light' vim.o.termguicolors = true -- enable 24 bit colors in TUI vim.g.syntax = true vim.wo.number = true diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 2e3a222..54bc39b 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,86 +1,45 @@ return { - -- Autocompletion { - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', + "neovim/nvim-lspconfig", config = function() - local cmp = require('cmp') - - cmp.setup({ - sources = { - {name = 'nvim_lsp'}, - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [''] = cmp.mapping.abort(), - }), - snippet = { - expand = function(args) - vim.snippet.expand(args.body) - end, - }, - }) - end - }, - - -- LSP - { - 'neovim/nvim-lspconfig', - cmd = 'LspInfo', - event = {'BufReadPre', 'BufNewFile'}, - dependencies = { - {'hrsh7th/cmp-nvim-lsp'}, - }, - init = function() -- Reserve a space in the gutter - -- This will avoid an annoying layout shift in the screen vim.opt.signcolumn = 'yes' - end, - config = function() - local lsp_defaults = require('lspconfig').util.default_config - - -- Add cmp_nvim_lsp capabilities settings to lspconfig - -- This should be executed before you configure any language server - lsp_defaults.capabilities = vim.tbl_deep_extend( - 'force', - lsp_defaults.capabilities, - require('cmp_nvim_lsp').default_capabilities() - ) - - -- LspAttach is where you enable features that only work - -- if there is a language server active in the file vim.api.nvim_create_autocmd('LspAttach', { desc = 'LSP actions', callback = function(event) - local opts = { buffer = event.buffer, remap = false } + 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 - 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) + -- 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, }) - local lsp = require('lspconfig') - - -- require('lspconfig').gleam.setup({}) - -- require('lspconfig').ocamllsp.setup({}) - - lsp.rust_analyzer.setup({ + vim.lsp.config('rust_analyzer', { settings = { ["rust-analyzer"] = { checkOnSave = { @@ -117,12 +76,14 @@ return { } } }) + vim.lsp.enable('rust_analyzer') - lsp.pylsp.setup({}) - lsp.ruff.setup({}) - + vim.lsp.enable('pylsp') + vim.lsp.enable('ruff') + vim.lsp.enable('ts_ls') + vim.lsp.enable('oxlint') - -- Workaround for rust_analzyer issue + -- 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)