-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support @vue/typescript-plugin #148
Comments
It looks like volar monkey patched the vscode typescript extension to make it work for vue files: So this is technically not a issue for vtsls. But I also think there is no better way for volar because the supported languages are hard coded in the extension. I'll try to add a way to let user add custom language ids. |
@mcchrish Could you test the version Lines 136 to 152 in 6cdfdac
|
It's working! Amazing, thanks for the quick response! |
Code action doesn't seem to work:
|
@mcchrish Did you see the |
Just FYI: The Vue language support seems to be suffering problems right now, as you can look into its issues and vuejs/language-tools#4119. So I would not merge the feature until it is stabilized so that we could see lesser such issue which is probably not caused by vtsls. Currently I recommend to stick to takeover mode (takeover mode is reintroduced from volar 2.0.7): williamboman/mason-lspconfig.nvim#371 (comment). |
Yes, it's the only item I can see. It's definitely very broken at the moment and went to downgrade to volar v1.8 instead. Thanks a lot for the support! |
How does this work with nvim-lspconfig. I tried the suggested settings based on the tsserver settings for the vue plugin, but it seems to crash the lsp. local util = require("lsp.util")
require("lspconfig").vtsls.setup({
on_attach = util.on_attach,
capabilities = util.capabilities,
init_options = {
vtsls = {
tsserver = {
globalPlugins = {
{
name = "@vue/typescript-plugin",
location = "/home/jordy/.npm-packages/lib/node_modules/@vue/typescript-plugin",
languages = { "typescript", "javascript", "vue" },
enableForWorkspaceTypeScriptVersions = true,
configNamespace = "typescript",
},
},
},
},
},
filetypes = {
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript",
"typescriptreact",
"typescript.tsx",
"vue",
},
}) I'm getting the following error message in my logs: |
@jordycoding My example config: lspconfig.volar.setup {
on_attach = on_attach,
capabilities = capabilities,
}
lspconfig.vtsls.setup {
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
settings = {
vtsls = {
-- autoUseWorkspaceTsdk = true,
tsserver = {
globalPlugins = {
{
name = '@vue/typescript-plugin',
location = vue_language_server_path,
languages = { 'vue' },
configNamespace = "typescript",
enableForWorkspaceTypeScriptVersions = true,
},
},
},
},
},
on_attach = on_attach,
capabilities = capabilities,
} |
For anyone looking for a LazyVim spec: return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "typescript", "tsx" })
end
end,
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
table.insert(opts.ensure_installed, "vue-language-server")
require("mason").setup()
end,
},
{
"neovim/nvim-lspconfig",
opts = function(_, opts)
opts.servers["volar"] = {
enabled = true,
}
opts.servers["vtsls"] = {
enabled = true,
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
settings = {
vtsls = {
tsserver = {
globalPlugins = {
{
name = "@vue/typescript-plugin",
location = require("mason-registry").get_package("vue-language-server"):get_install_path()
.. "/node_modules/@vue/language-server",
languages = { "vue" },
configNamespace = "typescript",
enableForWorkspaceTypeScriptVersions = true,
},
},
},
},
},
}
end,
},
} |
Some already made it work with project local settings? I get the error My config: lspconfig.vtsls.setup {
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
capabilities = capabilities,
settings = {
vtsls = { tsserver = { globalPlugins = {} } },
},
on_init = function(client)
local result = vim.system(
{ "npm", "query", ":root" },
{ cwd = client.workspace_folders[1].name, text = true }
):wait()
if result.stdout ~= "[]" then
local vuePluginConfig = {
name = "@vue/typescript-plugin",
location = require("mason-registry").get_package("vue-language-server"):get_install_path()
.. "/node_modules/@vue/language-server",
languages = { "vue" },
configNamespace = "typescript",
enableForWorkspaceTypeScriptVersions = true,
}
client.config.settings.vtsls.tsserver.globalPlugins = { vuePluginConfig }
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end,
on_attach = function(client)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
} |
@mcchrish Try to use lspconfig.vtsls.setup {
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
capabilities = capabilities,
settings = {
vtsls = { tsserver = { globalPlugins = {} } },
},
before_init = function(_, config)
local result = vim.system(
{ "npm", "query", ":root" },
{ cwd = client.workspace_folders[1].name, text = true }
):wait()
if result.stdout ~= "[]" then
local vuePluginConfig = {
name = "@vue/typescript-plugin",
location = require("mason-registry").get_package("vue-language-server"):get_install_path()
.. "/node_modules/@vue/language-server",
languages = { "vue" },
configNamespace = "typescript",
enableForWorkspaceTypeScriptVersions = true,
}
config.settings.vtsls.tsserver.globalPlugins = { vuePluginConfig }
end
end
} New language providers could not be correctly registered with new plugins updated from |
lspconfig.vtsls.setup {
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
settings = {
vtsls = { tsserver = { globalPlugins = {} } },
},
before_init = function(params, config)
local result = vim.system(
{ "npm", "query", "#vue" },
{ cwd = params.workspaceFolders[1].name, text = true }
):wait()
if result.stdout ~= "[]" then
local vuePluginConfig = {
name = "@vue/typescript-plugin",
location = require("mason-registry").get_package("vue-language-server"):get_install_path()
.. "/node_modules/@vue/language-server",
languages = { "vue" },
configNamespace = "typescript",
enableForWorkspaceTypeScriptVersions = true,
}
table.insert(config.settings.vtsls.tsserver.globalPlugins, vuePluginConfig)
end
end,
} Thanks @yioneko! This now works. For anyone interested, this setup checks whether vue is installed before adding the plugin. |
One issue I get is when I add
vue
to thefiletypes
table:I get the error:
Which blocks further attempts to try integrating the vue typescript plugin.
The text was updated successfully, but these errors were encountered: