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' },

View File

@ -1,45 +1,50 @@
return {
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
{ 'WhoIsSethDaniel/mason-tool-installer.nvim' },
config = function()
local mason = require('mason')
local mason_lspconfig = require('mason-lspconfig')
local mason_tool_installer = require('mason-tool-installer')
{
'mason-org/mason.nvim',
dependencies = {
'mason-org/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
},
config = function()
local mason = require('mason')
local mason_lspconfig = require('mason-lspconfig')
local mason_tool_installer = require('mason-tool-installer')
mason.setup({
ui = {
icons = {
package_installed = '',
package_pending = '',
package_uninstalled = '',
mason.setup({
ui = {
icons = {
package_installed = '',
package_pending = '',
package_uninstalled = '',
},
},
},
pip = {
upgrade_pip = true,
},
})
pip = {
upgrade_pip = true,
},
})
mason_lspconfig.setup({
ensure_installed = {
'lua_ls',
'html',
'cssls',
-- 'pyright',
-- 'emmet_ls',
'bashls',
'ts_ls',
},
})
mason_lspconfig.setup({
ensure_installed = {
'lua_ls',
'html',
'cssls',
-- 'pyright',
-- 'emmet_ls',
'bashls',
'ts_ls',
'eslint-lsp',
},
})
mason_tool_installer.setup({
ensure_installed = {
'prettier',
'isort',
-- 'black',
-- 'pylint',
-- 'eslint_d',
},
})
end,
mason_tool_installer.setup({
ensure_installed = {
'prettier',
'isort',
-- 'black',
-- 'pylint',
-- 'eslint_d',
},
})
end,
},
}

View File

@ -8,7 +8,17 @@ return {
local sources = {
null_ls.builtins.formatting.prettier.with({
filetypes = { 'javascript', 'typescript', 'typescriptreact', 'css', 'html', 'json', 'markdown', 'yaml' }
filetypes = {
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
'css',
'html',
'json',
'markdown',
'yaml',
},
}),
-- null_ls.builtins.formatting.black,
-- null_ls.builtins.formatting.djlint,
@ -19,11 +29,6 @@ return {
null_ls.setup({
sources = sources,
-- on_attach = function(client, bufnr)
-- if client.server_capabilities.documentFormattingProvider then
-- vim.
-- end
-- end,
})
local keymap = vim.keymap