fix nvim config

This commit is contained in:
Johannes Knopp
2026-02-22 17:06:22 +01:00
parent 4093701fca
commit 545f8ab328
10 changed files with 95 additions and 120 deletions

View File

@ -5,11 +5,17 @@ return {
'williamboman/mason.nvim',
'hrsh7th/cmp-nvim-lsp',
{ 'antosha417/nvim-lsp-file-operations', config = true },
{ 'folke/neodev.nvim', opts = {} },
{
'folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
},
},
},
},
config = function()
local lspconfig = vim.lsp
local mason_lspconfig = require('mason-lspconfig')
local cmp_nvim_lsp = require('cmp_nvim_lsp')
local keymap = vim.keymap
local wk = require('which-key')
@ -37,98 +43,40 @@ return {
end,
})
-- Apply default capabilities to all servers
local capabilities = cmp_nvim_lsp.default_capabilities()
mason_lspconfig.setup_handlers({
-- default handler for installed servers
function(server_name)
lspconfig.enable(server_name, {
capabilities = capabilities,
})
end,
-- TODO add lsp configs
['lua_ls'] = function()
lspconfig.enable('lua_ls', {
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { 'vim' },
},
completion = {
callSnippet = 'Replace'
},
}
}
})
end,
['emmet_ls'] = function()
-- capabilities.textDocument.completion.completionItem.snippetSupport = true
lspconfig.enable('emmet_ls', {
capabilities = capabilities,
filetypes = {
'html',
'css',
'sass',
'scss',
'less',
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
'svelte',
'vue',
}
})
end,
['ts_ls'] = function()
lspconfig.enable('ts_ls', {
capabilities = capabilities,
cmd = { "typescript-language-server", "--stdio" },
init_options = {
hostInfo = "neovim",
-- preferences = {
-- includePackagesJsonAutoImports = "on",
-- }
}
})
end,
['hyprls'] = function ()
lspconfig.hyprls.setup({
capabilities = capabilities,
cmd = { "hyprls" },
root_dir = function(fname)
return vim.fn.getcwd()
end,
})
end,
-- ['pyright'] = function()
-- lspconfig['pyright'].setup({
-- -- cmd = { "pyright-langserver", "--stdio" },
-- -- filetypes = { "python" },
-- -- root_dir = function(filename)
-- -- return util.root_pattern(unpack(root_files))(filename) or util.path.dirname(filename)
-- -- end,
-- -- settings = {
-- -- python = {
-- -- analysis = {
-- -- autoSearchPaths = true,
-- -- diagnosticMode = "workspace",
-- -- useLibraryCodeForTypes = true
-- -- }
-- -- }
-- -- }
-- capabilities = capabilities,
-- settings = {
-- python = {
-- analysis = {
-- useLibraryCodeForTypes = true,
-- typeCheckingMode = "basic",
-- -- configPath = vim.fn.expand('./pyrightconfig.json')
-- }
-- }
-- },
-- })
-- end,
vim.lsp.config('*', { capabilities = capabilities })
-- lua_ls: suppress vim global warnings, improve completion
vim.lsp.config('lua_ls', {
settings = {
Lua = {
diagnostics = {
globals = { 'vim' },
},
completion = {
callSnippet = 'Replace',
},
},
},
})
end
-- ts_ls: explicit host info
vim.lsp.config('ts_ls', {
cmd = { 'typescript-language-server', '--stdio' },
init_options = {
hostInfo = 'neovim',
},
})
-- hyprls: not managed by mason, enable manually
vim.lsp.config('hyprls', {
cmd = { 'hyprls' },
filetypes = { 'hyprlang' },
root_dir = function(fname)
return vim.fn.getcwd()
end,
})
vim.lsp.enable('hyprls')
end,
}

View File

@ -1,6 +1,6 @@
return {
{ 'williamboman/mason.nvim', commit = '4da89f3' },
{ 'williamboman/mason-lspconfig.nvim', commit = '1a31f82' },
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
{ 'WhoIsSethDaniel/mason-tool-installer.nvim' },
config = function()
local mason = require('mason')
@ -10,14 +10,14 @@ return {
mason.setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
package_installed = '',
package_pending = '',
package_uninstalled = '',
},
},
pip = {
upgrade_pip = true,
}
},
})
mason_lspconfig.setup({
@ -39,7 +39,7 @@ return {
-- 'black',
-- 'pylint',
-- 'eslint_d',
}
},
})
end,
}