Update to use nvim 0.11 lsp configs

main
Nick Zana 1 day ago
parent e9a703bf43
commit 51df129f13

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

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

@ -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({
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
['<C-e>'] = 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', '<leader>k', function() vim.lsp.buf.hover() end, opts)
vim.keymap.set('n', '<leader>r', function() vim.lsp.buf.rename() end, opts)
vim.keymap.set('n', '<leader>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', '<leader>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', '<leader>Q', function() vim.diagnostic.set_qflist() end, opts)
vim.keymap.set('n', '<leader>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', '<leader>k', function() vim.lsp.buf.hover() end, opts)
vim.keymap.set('n', '<leader>r', function() vim.lsp.buf.rename() end, opts)
vim.keymap.set('n', '<leader>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', '<leader>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', '<leader>Q', function() vim.diagnostic.set_qflist() end, opts)
vim.keymap.set('n', '<leader>F', function() vim.lsp.buf.format() end, opts)
-- Built-in completion keybindings
vim.keymap.set('i', '<C-Space>', '<C-x><C-o>', opts)
vim.keymap.set('i', '<C-n>', function()
if vim.fn.pumvisible() == 1 then
return '<C-n>'
else
return '<C-x><C-o>'
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)

Loading…
Cancel
Save