From 47fc70a18a1ed2f4e79485be5d55e0e5a32115af Mon Sep 17 00:00:00 2001 From: Gabriel Scaranello Date: Wed, 29 May 2024 15:29:02 -0300 Subject: [PATCH] feat(vue): configure volar as tsserver plugin --- lua/astrocommunity/pack/vue/init.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lua/astrocommunity/pack/vue/init.lua b/lua/astrocommunity/pack/vue/init.lua index 182b5d42a..9dc75fbe8 100644 --- a/lua/astrocommunity/pack/vue/init.lua +++ b/lua/astrocommunity/pack/vue/init.lua @@ -1,4 +1,5 @@ return { + { import = "astrocommunity.pack.typescript" }, { "AstroNvim/astrolsp", optional = true, @@ -37,6 +38,33 @@ return { }, }, }, + vtsls = { + settings = { + vtsls = { + tsserver = { + globalPlugins = {}, + }, + }, + }, + before_init = function(_, config) + local astrocore_ok, astrocore = pcall(require, "astrocore") + local registry_ok, registry = pcall(require, "mason-registry") + if not astrocore_ok or not registry_ok then return end + + local volar_install_path = registry.get_package("vue-language-server"):get_install_path() + .. "/node_modules/@vue/language-server" + + local vue_plugin_config = { + name = "@vue/typescript-plugin", + location = volar_install_path, + languages = { "vue" }, + configNamespace = "typescript", + enableForWorkspaceTypeScriptVersions = true, + } + + astrocore.list_insert_unique(config.settings.vtsls.tsserver.globalPlugins, { vue_plugin_config }) + end, + }, }, }, },