From a74b9bbf5fe90f37da3c50e21a2bc593e3ebd00e Mon Sep 17 00:00:00 2001 From: zhaown <51357674+chaozwn@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:19:54 +0800 Subject: [PATCH 1/3] fix: hybridMode = false open two tsserver were started. Now this latest version should be, tsserver supports vue, then enable hybridMode, volar provides the template prompt. --- lua/astrocommunity/pack/vue/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/astrocommunity/pack/vue/init.lua b/lua/astrocommunity/pack/vue/init.lua index 9dc75fbe8..d57e079af 100644 --- a/lua/astrocommunity/pack/vue/init.lua +++ b/lua/astrocommunity/pack/vue/init.lua @@ -10,7 +10,7 @@ return { volar = { init_options = { vue = { - hybridMode = false, + hybridMode = true, }, }, settings = { From 92e5937f275b6a56c1241dc090fa0a47463740a7 Mon Sep 17 00:00:00 2001 From: zhaown <51357674+chaozwn@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:22:17 +0800 Subject: [PATCH 2/3] Update init.lua --- lua/astrocommunity/pack/vue/init.lua | 33 ++++++++-------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/lua/astrocommunity/pack/vue/init.lua b/lua/astrocommunity/pack/vue/init.lua index d57e079af..1f2d159e2 100644 --- a/lua/astrocommunity/pack/vue/init.lua +++ b/lua/astrocommunity/pack/vue/init.lua @@ -13,32 +13,17 @@ return { hybridMode = true, }, }, - settings = { - typescript = { - updateImportsOnFileMove = { enabled = "always" }, - inlayHints = { - parameterNames = { enabled = "all" }, - parameterTypes = { enabled = true }, - variableTypes = { enabled = true }, - propertyDeclarationTypes = { enabled = true }, - functionLikeReturnTypes = { enabled = true }, - enumMemberValues = { enabled = true }, - }, - }, - javascript = { - updateImportsOnFileMove = { enabled = "always" }, - inlayHints = { - parameterNames = { enabled = "literals" }, - parameterTypes = { enabled = true }, - variableTypes = { enabled = true }, - propertyDeclarationTypes = { enabled = true }, - functionLikeReturnTypes = { enabled = true }, - enumMemberValues = { enabled = true }, - }, - }, - }, }, vtsls = { + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + "vue", + }, settings = { vtsls = { tsserver = { From f18136d944a8826ba21fddd72686e25c78233838 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Mon, 8 Jul 2024 07:54:54 -0400 Subject: [PATCH 3/3] refactor(vue): make vue config more robust --- lua/astrocommunity/pack/vue/init.lua | 84 +++++++++++++++------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/lua/astrocommunity/pack/vue/init.lua b/lua/astrocommunity/pack/vue/init.lua index 1f2d159e2..9b8493d22 100644 --- a/lua/astrocommunity/pack/vue/init.lua +++ b/lua/astrocommunity/pack/vue/init.lua @@ -4,54 +4,58 @@ return { "AstroNvim/astrolsp", optional = true, ---@type AstroLSPOpts - opts = { - ---@diagnostic disable: missing-fields - config = { - volar = { - init_options = { - vue = { - hybridMode = true, + opts = function(_, opts) + local astrocore = require "astrocore" + local vtsls_ft = astrocore.list_insert_unique(vim.tbl_get(opts, "config", "vtsls", "filetypes") or { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, { "vue" }) + return astrocore.extend_tbl(opts, { + ---@diagnostic disable: missing-fields + config = { + volar = { + init_options = { + vue = { + hybridMode = true, + }, }, }, - }, - vtsls = { - filetypes = { - "javascript", - "javascriptreact", - "javascript.jsx", - "typescript", - "typescriptreact", - "typescript.tsx", - "vue", - }, - settings = { - vtsls = { - tsserver = { - globalPlugins = {}, + vtsls = { + filetypes = vtsls_ft, + 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 + before_init = function(_, config) + local registry_ok, registry = pcall(require, "mason-registry") + if not registry_ok then return end + local vuels = registry.get_package "vue-language-server" - local volar_install_path = registry.get_package("vue-language-server"):get_install_path() - .. "/node_modules/@vue/language-server" + if vuels:is_installed() then + local volar_install_path = vuels: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, - } + 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, + astrocore.list_insert_unique(config.settings.vtsls.tsserver.globalPlugins, { vue_plugin_config }) + end + end, + }, }, - }, - }, + }) + end, }, { "nvim-treesitter/nvim-treesitter",