Files
LazyVim/lua/lazyvim/plugins/extras/lang/vue.lua
Ray Guo 4b0f720457 feat(vue): enabled hybrid mode to avoid 2 typescript lsp running at same time (#3908)
## What is this PR for?

At the moment, the config for vue set hybrid mode to `false` which volar
will run a typescript server under the hook. ( hybrid mode false is the
takeover mode in v1, was introduced in `2.0.7` see more information
here: https://github.com/vuejs/language-tools/pull/4119 ).

However, another vtsls with vue language plugin also attached to vue
files, this will cause two typescript server running at the same time.
It can be very easily observed with tools like `htop` volar and vtsls
will have similar memory usage which is abnormal because volar should be
very light by itself. This will introduce issues like duplicate
diagnostics, see
https://github.com/vuejs/language-tools/issues/4159#issuecomment-2208101079

In this pull request, I set the hybrid mode to true as default because
the hybrid mode is the "correct" way moving forward, thus it would be
more stable. Let me know if you feel it should stay as `false` to be
default.

## Does this PR fix an existing issue?

No existing issue.

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-07-05 16:12:04 +02:00

51 lines
1.1 KiB
Lua

return {
recommended = function()
return LazyVim.extras.wants({
ft = "vue",
root = { "vue.config.js" },
})
end,
-- depends on the typescript extra
{ import = "lazyvim.plugins.extras.lang.typescript" },
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "vue" } },
},
-- Add LSP servers
{
"neovim/nvim-lspconfig",
opts = {
servers = {
volar = {
init_options = {
vue = {
hybridMode = true,
},
},
},
vtsls = {},
},
},
},
-- Configure tsserver plugin
{
"neovim/nvim-lspconfig",
opts = function(_, opts)
table.insert(opts.servers.vtsls.filetypes, "vue")
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
{
name = "@vue/typescript-plugin",
location = LazyVim.get_pkg_path("vue-language-server", "/node_modules/@vue/language-server"),
languages = { "vue" },
configNamespace = "typescript",
enableForWorkspaceTypeScriptVersions = true,
},
})
end,
},
}