fix neovim LSP issues

This commit is contained in:
Johannes Knopp
2026-03-16 23:44:52 +01:00
parent 545f8ab328
commit 9fbffb7558
7 changed files with 132 additions and 78 deletions

View File

@ -2,7 +2,8 @@ return {
'neovim/nvim-lspconfig',
event = { 'BufReadPre', 'BufNewFile' },
dependencies = {
'williamboman/mason.nvim',
'mason-org/mason.nvim',
'mason-org/mason-lspconfig.nvim',
'hrsh7th/cmp-nvim-lsp',
{ 'antosha417/nvim-lsp-file-operations', config = true },
{
@ -27,13 +28,12 @@ return {
return { desc = desc, buffer = ev.buf, silent = true }
end
keymap.set('n', 'gr', vim.lsp.buf.rename, opts('Rename'))
keymap.set('n', 'K', vim.lsp.buf.hover, opts('Show documentation'))
keymap.set('n', 'gR', '<cmd>Telescope lsp_references<cr>', opts('Show LSP references'))
keymap.set('n', 'gd', '<cmd>Telescope lsp_definitions<cr>', opts('Go to definition'))
keymap.set('n', 'gr', '<cmd>Telescope lsp_references<cr>', opts('Show LSP references'))
keymap.set('n', 'gD', vim.lsp.buf.declaration, opts('Go to declaration'))
keymap.set('n', 'gd', '<cmd>Telescope lsp_definitions<cr>', opts('Show LSP definitions'))
keymap.set('n', 'gi', '<cmd>Telescope lsp_implementations<cr>', opts('Show LSP implementations'))
keymap.set('n', 'gt', '<cmd>Telescope lsp_type_definitions<cr>', opts('Show LSP type definitions'))
keymap.set('n', 'K', vim.lsp.buf.hover, opts('Show documentation'))
keymap.set('n', 'gE', vim.diagnostic.open_float, opts('Show diagnostics'))
keymap.set({ 'n', 'v' }, 'ga', vim.lsp.buf.code_action, opts('Show available code actions'))
wk.add({
@ -61,14 +61,32 @@ return {
},
})
-- ts_ls: explicit host info
-- ts_ls: TypeScript/JavaScript/JSX/TSX
vim.lsp.config('ts_ls', {
cmd = { 'typescript-language-server', '--stdio' },
filetypes = {
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
},
init_options = {
hostInfo = 'neovim',
},
})
-- eslint: linting for JS/TS/React projects
vim.lsp.config('eslint', {
settings = {
workingDirectories = { mode = 'auto' },
},
})
-- Explicitly enable all mason-managed servers.
-- This is belt-and-suspenders alongside mason-lspconfig's automatic_enable,
-- ensuring servers start regardless of mason-lspconfig version.
vim.lsp.enable({ 'lua_ls', 'html', 'cssls', 'bashls', 'ts_ls', 'eslint' })
-- hyprls: not managed by mason, enable manually
vim.lsp.config('hyprls', {
cmd = { 'hyprls' },