Change nvim lspconfig to work with mason and vue

This commit is contained in:
Nico
2025-10-24 19:21:22 +02:00
parent f60bf4608f
commit 2224c25e2b
8 changed files with 186 additions and 71 deletions

View File

@@ -1,32 +1,69 @@
return {
'neovim/nvim-lspconfig',
dependencies = { 'saghen/blink.cmp' },
config = function(_,_)
-- example using `opts` for defining servers
opts = {
servers = {
lua_ls = {},
nil_ls = {},
vue_ls = {},
-- rust_analyzer = {},
-- gopls = {},
local vue_language_server_path = vim.fn.expand '$MASON/packages' .. '/vue-language-server' .. '/node_modules/@vue/language-server'
local tsserver_filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }
local vue_plugin = {
name = '@vue/typescript-plugin',
location = vue_language_server_path,
languages = { 'vue' },
configNamespace = 'typescript',
}
},
config = function(_, opts)
local lspconfig = require('lspconfig')
for server, config in pairs(opts.servers) do
-- passing config.capabilities to blink.cmp merges with the capabilities in your
-- `opts[server].capabilities, if you've defined it
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
lspconfig[server].setup(config)
end
local vtsls_config = {
settings = {
vtsls = {
tsserver = {
globalPlugins = {
vue_plugin,
},
},
},
},
filetypes = tsserver_filetypes,
}
local ts_ls_config = {
init_options = {
plugins = {
vue_plugin,
},
},
filetypes = tsserver_filetypes,
}
-- If you are on most recent `nvim-lspconfig`
local vue_ls_config = {}
-- nvim 0.11 or above
vim.lsp.config('vtsls', vtsls_config)
vim.lsp.config('vue_ls', vue_ls_config)
vim.lsp.config('lua_ls', {})
vim.lsp.enable({'vtsls', 'vue_ls', 'lua_ls'})
end
-- -- example calling setup directly for each LSP
-- config = function()
-- local capabilities = require('blink.cmp').get_lsp_capabilities()
-- local lspconfig = require('lspconfig')
--
-- lspconfig['lua_ls'].setup({ capabilities = capabilities })
-- end
-- opts = {
-- servers = {
-- lua_ls = {},
-- nil_ls = {},
-- vstls = {},
-- vue_ls = {},
-- -- rust_analyzer = {},
-- -- gopls = {},
-- }
-- },
-- config = function(_, opts)
-- for server, config in pairs(opts.servers) do
-- config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
--
-- -- Verwende `vim.lsp.config` um die Konfiguration anzupassen
-- vim.lsp.config(server, config)
--
-- -- Aktiviere die Konfiguration
-- vim.lsp.enable(server)
-- end
-- end
}