refactor: refactored mason/typescript/vue support

This commit is contained in:
Folke Lemaitre 2024-06-01 08:31:10 +02:00
parent 135150307b
commit 9d999fa210
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
6 changed files with 70 additions and 37 deletions

View file

@ -6,6 +6,9 @@ return {
})
end,
-- depends on the typescript extra
{ import = "lazyvim.plugins.extras.lang.typescript" },
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
@ -15,34 +18,30 @@ return {
end,
},
-- Add LSP servers
{
"neovim/nvim-lspconfig",
opts = {
servers = {
volar = {},
vtsls = {},
},
},
},
-- Configure tsserver plugin
{
"neovim/nvim-lspconfig",
opts = function(_, opts)
local vue_typescript_plugin = require("mason-registry").get_package("vue-language-server"):get_install_path()
.. "/node_modules/@vue/language-server"
.. "/node_modules/@vue/typescript-plugin"
opts.servers = vim.tbl_deep_extend("force", opts.servers, {
volar = {},
-- Volar 2.0 has discontinued their "take over mode" which in previous version provided support for typescript in vue files.
-- The new approach to get typescript support involves using the typescript language server along side volar.
vtsls = {
filetypes = {
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript",
"typescriptreact",
"typescript.tsx",
"vue",
},
},
})
table.insert(opts.servers.vtsls.filetypes, "vue")
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
name = "@vue/typescript-plugin",
location = vue_typescript_plugin,
languages = { "vue" },
configNamespace = "typescript",
{
name = "@vue/typescript-plugin",
location = LazyVim.get_pkg_path("vue-language-server", "/node_modules/@vue/language-server"),
languages = { "vue" },
configNamespace = "typescript",
enableForWorkspaceTypeScriptVersions = true,
},
})
end,
},