-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
Version 2 stop working with nvim lsp #3925
Comments
After 2.0, typescript support is fully implemented through typescript plugin. For IDEs other than VSCode, you need to install I'm not sure how nvim configures the typescript plugin, if nvim can't configure it, you need to install @vue/typescript-plugin to the project or globally, and then configure it in tsconfig. {
"compilerOptions": {
"plugins": [{ "name": "@vue/typescript-plugin" }]
}
} |
This comment was marked as outdated.
This comment was marked as outdated.
Hey, I'm also facing the exact same issues. None of the lsp functionality works, even though it is able to attach successfully. I can also say that previously, the last version I had before updating was working without any issue |
Same here, the language server is running and attached to my vue file, but completely nonfunctional. Like @RayGuo-ergou, I've downgraded to 1.8.27 for now. @johnsoncodehk I'm not clear on how the vue language server works, but for most neovim users, volar is installed globally with Mason, a sort of package manager for language servers. It installs a specific version of |
Upgrading the LSP to 2.0.3 on neovim works for me. Note that the 2.0.0 release was broken, so be sure to install the latest patch version. To confirm that the LSP is working, I opened a SFC and removed a |
I have installed Is it loaded automatically by the LSP? Any documentation/guide/example would be most welcome. |
export type VueInitializationOptions = InitializationOptions & {
typescript: {
tsdk: string;
}
vue?: {
/**
* @example ['vue1', 'vue2']
*/
additionalExtensions?: string[];
};
}; The export interface InitializationOptions {
l10n?: {
location: string; // uri
};
diagnosticModel?: DiagnosticModel;
maxFileSize?: number;
/**
* Extra semantic token types and modifiers that are supported by the client.
*/
semanticTokensLegend?: vscode.SemanticTokensLegend;
codegenStack?: boolean;
} The only relevant thing that I see is the |
This comment was marked as outdated.
This comment was marked as outdated.
I have not tried a javascript project yet. I tried a typescript project, and error diagnostics only show up for the html template portion, but not for typescript code. |
I was able to get everything working with 2.0.3. Here is my config (note, I use neoconf to tell lspconfig I'm using a volar project). I am also using typescript-tools instead of tsserver. {
"neovim/nvim-lspconfig",
dependencies = {
"pmizio/typescript-tools.nvim",
},
opts = {
servers = {
tsservercontext = {},
},
setup = {
tsservercontext = function(_, opts)
local neoconf = require("neoconf")
local lspconfig = require("lspconfig")
if neoconf.get("is-volar-project") then
lspconfig["volar"].setup({
server = opts,
settings = {},
})
require("typescript-tools").setup({
server = opts,
settings = {
tsserver_plugins = {
"@vue/typescript-plugin",
},
},
filetypes = {
"javascript",
"typescript",
"vue",
},
})
else
require("typescript-tools").setup({
server = opts,
})
end
return true
end,
},
},
} Note specifically: tsserver_plugins = {
"@vue/typescript-plugin",
} This works fine, however, volar still tries to fetch definitions in |
My thoughts are the same as yours: typescript-tools.nvim is used for handling ts and js files, while volar is used for handling vue files. However, it seems that there are currently issues with volar. |
This comment was marked as outdated.
This comment was marked as outdated.
Oh, I had assumed that "typescript plugin" meant "a plugin that adds typescript support to this language server". Did I misunderstand this and "typescript plugin" is a actually plugin for I'm a bit confused about volar's role if that's the case. If the typescript plugin gives tsserver the ability to handle vue code, why do I still need to keep around volar? |
I believe that volar provides language server support inside template tags and is also required by the vue typescript plugin. |
I installed I'm taking a pretty straightforward approach here: tsserver = {
-- I installed @vue/typescript-plugin inside this container:
cmd = lsp_containers.command("tsserver"),
settings = {
tsserver_plugins = {
"@vue/typescript-plugin",
},
},
filetypes = {
"javascript",
"typescript",
"vue",
},
}, For regular typescript files,
|
|
Does |
you must use |
What I've found (and I spent way too much time on this yesterday) is that tsserver doesn't (at least for me) load the vue typescript plugin. You can try for yourself. Look at the tsserver docs https://github.com/typescript-language-server/typescript-language-server/blob/master/docs/configuration.md .. You can specify plugin settings under |
Sounds like loading plugins via tsserver is problematic or non-trivial. But the devs here must have figured out a way to load the plugin to test it and use it themselves. typescript-tools.nvim is neovim-specific, I don't think they'd target that exclusively. |
Oh, actually, what I'm using is typescript-language-server, not tsserver. |
Apparently the |
Are you saying that there currently is no way to make it work with I would rather not switch to software which warns about its early beta stage just yet. |
I think it's entirely probable that I am just not initializing tsserver correctly--which I think is a documentation issue. As @johnsoncodehk said, non-VSCode editors have to handle this manually. |
Setting the location did not work for me either. Check out this issue which suggests that you can also just put anything in there like so:
That did not work either. |
I made it work! 🎉 tsserver = {
cmd = lsp_containers.command("tsserver"),
init_options = {
plugins = {
{
name = "@vue/typescript-plugin",
location = "/usr/local/lib/node_modules/@vue/typescript-plugin",
languages = {"typescript", "vue"},
},
},
},
filetypes = {
"javascript",
"typescript",
"vue",
},
}, This shows error diagnostics on the |
null-ls format working properly? |
Interesting. I had not tried installing the plugin globally. I'd rather not have to do that but I'll give it a shot. |
No, it's a plain old vue 2 project, no typescript at all. |
There is some official documentation for what config is necessary for fixing this issue. Seems like the TLDR. I've added this to my local lspconfig = require("lspconfig")
-- Allows volar to run embedded tsserver
lspconfig.volar.setup({
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
init_options = {
vue = {
hybridMode = false,
},
},
}) Edit: Actually, this gave me some LSP capabilities but not all. I found another suggested config in nvim-lspconfig documentation that seems to be working. You will have to install @vue/typescript-plugin globally and edit the location for your case. -- init.lua
local lspconfig = require("lspconfig")
lspconfig.volar.setup({})
lspconfig.tsserver.setup({
init_options = {
plugins = {
{
name = "@vue/typescript-plugin",
location = "C:\\Users\\wcheek\\AppData\\Roaming\\npm\\node_modules\\@vue\\typescript-plugin\\",
languages = { "javascript", "typescript", "vue" },
},
},
},
filetypes = {
"javascript",
"typescript",
"vue",
},
}) |
I have a bunch of projects with both Vue2 and Vue3 and got the default tsserver working well with Mason and Neoconf. I installed In all of my Vue2 projects, I disable both {
"lspconfig": {
"tsserver": false,
"volar": false
}
} Then in all of my Vue3 projects, I disable {
"is-volar-project": true,
"lspconfig": {
"vuels": false
}
} I globally install the latest Then in my neovim lua config, I use require("mason-lspconfig").setup_handlers {
function(server_name)
require("lspconfig")[server_name].setup {
capabilities = lsp_capabilities,
}
end,
["tsserver"] = function()
local neoconf = require("neoconf")
local init_options = {}
if neoconf.get("is-volar-project") then
init_options = {
plugins = {
{
name = "@vue/typescript-plugin",
location = "/path/to/global/node_modules/@vue/typescript-plugin",
languages = {"javascript", "typescript", "vue"},
},
},
}
end
require("lspconfig").tsserver.setup {
filetypes = { "vue", "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
compilerOptions = {
noErrorTruncate = true
},
init_options = init_options,
}
end
} This is working well for me. Vue2 projects use the |
I'm not a major fan of polluting and bloating my hard disk and hence did not want to resort to installing neither Any way, looks like the Vue projects requires both I'm pretty sure there might be some caveats to the way I've configure Neovim (for now) but I couldn't find time to investigate further. Regardless, I guess as long as it works as I expect it to I will keep procrastinating! 😆 |
Did it still fully work? Here is my config: https://github.com/k0mpreni/nvim-lua/blob/7c130638d2f2d55f7dfd6bf3ebbbb154853481fb/after/plugin/lsp.lua#L18 Using mason: I tried the readme config and the setup from catgoose, without success. edit: added plugin versions |
@k0mpreni try adding these lines to your Neovim config: lspconfig.volar.setup({
filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'},
init_options = {
vue = {
hybridMode = false
},
}
}) It is based on the recommended configurations which you would find in the README (see my previous comment for source). |
Tried it as well @Jarmos-san , unfortunately same result, the type definition are from the shims and not from the component itself. |
Is this what are you referring to?
One thing i can think of is: are the files included in btw if you want to set |
Exactly to those. It also seems that you have the shims as types no?
Yes, it's in the tsconfig.json indeed. I also have it working in vscode with hybridMode on (had to put a specific tsdk as my project is not using typescript v5 yet). |
defineProps({
msg: {
type: String,
required: true,
},
})
This might be the reason, the tsdk running on LSP does nothing to your project, as a LSP is just a stand along server maybe give |
Ok so it seems that it's just a ts version issue. |
If you are using hybrid mode, the option |
Ok so this is also doing the trick meanwhile I upgrade my project to v5. Can ditch vscode again thanks a lot! For future reference: If it's compatible, you don't need to override |
Context: This is a Vue 3 project without typescript. This worked for me: Notice I'm using some custom on_attach with -- Using Lspsaga If you like to ignore this, comment `on_attach = on_attach`
local on_attach = function(client, bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename
vim.keymap.set("n", "K", "<cmd>Lspsaga hover_doc")
end
-- No need to set `hybridMode` to `true` as it's the default value
lspconfig.volar.setup({
on_attach = on_attach,
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
init_options = {
vue = {
hybridMode = false,
},
},
}) |
I am using vetur for vue2 project and volar for vue3 project. Using a simple function to detect the vue version. config = function()
local capabilities = require("mini.completion").completefunc_lsp()
local lspconfig = require("lspconfig")
local util = require("lspconfig.util")
local mason_registry = require("mason-registry")
local vue_language_server_path = mason_registry.get_package("vue-language-server"):get_install_path()
.. "/node_modules/@vue/language-server"
-- js, ts
lspconfig.ts_ls.setup({
init_options = {
plugins = {
{
name = "@vue/typescript-plugin",
location = vue_language_server_path,
languages = { "vue" },
},
},
},
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
})
-- vue
local function get_vue_version()
local root_dir = util.find_git_ancestor(vim.fn.getcwd()) or vim.fn.getcwd()
local package_json = root_dir .. "/package.json"
if vim.fn.filereadable(package_json) == 1 then
local package_data = vim.fn.json_decode(vim.fn.readfile(package_json))
local vue_version = package_data["dependencies"] and package_data["dependencies"]["vue"]
or package_data["devDependencies"] and package_data["devDependencies"]["vue"]
if vue_version then
-- Strip any non-numeric characters like ^ or ~ from the version string
local cleaned_version = vim.fn.matchstr(vue_version, [[\v\d+]])
local version = tonumber(cleaned_version)
return version
end
end
return nil
end
local vue_version = get_vue_version()
if vue_version == 3 then
-- use volar for vue 3
lspconfig.volar.setup({
capabilities = capabilities,
})
else
-- use vetur (vuels) for vue 2
lspconfig.vuels.setup({
capabilities = capabilities,
filetypes = { "vue" },
root_dir = lspconfig.util.root_pattern("package.json", ".git"),
})
end
end, |
Volar is not able to run and have all capabilities no matter what. Use "typescript-tools" and |
I'm trying to set up the Vue and TypeScript language servers in Neovim, but it’s not working as expected. ConfigurationHere’s my local mason_registry = require('mason-registry')
local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. '/node_modules/@vue/language-server'
lspconfig.ts_ls.setup {
init_options = {
plugins = {
{
name = "@vue/typescript-plugin",
location = vue_language_server_path,
languages = { "vue" },
},
},
},
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
}
lspconfig.volar.setup {}
lspconfig.cssls.setup {}
lspconfig.phpactor.setup {}
lspconfig.yamlls.setup {}
lspconfig.html.setup {}
lspconfig.tailwindcss.setup {} Active LSP InformationCommand:
LogsCommand: Errors in LSP logs:
|
It's most likely due to since you are using |
Thank you for your reply! Unfortunately, it's still not working for me. Here’s the updated logs:
|
The errors are likely come from One reason quickly come to my mind is your typescript version is below |
Thank you for the quick response! Here's the updated information after checking my setup:
My logs with info level:
|
Hi @yuzhen1024 I think you had the similar issue, are you able to help here? How did you figured out a solution? |
@RayGuo-ergou |
Unsuccessful :/ |
Update: check readme.
tldr:
Hi,
I am having issue to run
volar@2.0.1
with neovimlsp
.cmd:
vue-language-server --stdio
With
1.8.27
:With
2.0.1
:The text was updated successfully, but these errors were encountered: