Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue): properly configure hybrid mode #1071

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 43 additions & 54 deletions lua/astrocommunity/pack/vue/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,58 @@ return {
"AstroNvim/astrolsp",
optional = true,
---@type AstroLSPOpts
opts = {
---@diagnostic disable: missing-fields
config = {
volar = {
init_options = {
vue = {
hybridMode = false,
},
},
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 },
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 = {
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",
Expand Down
Loading