language-tools
language-tools copied to clipboard
Can't get all features working in neovim lsp
Hi there,
I installed volar through Mason, it's added through nvim-lspconfig but I can't figure out how to enable some of its features. I don't get autocompletion for imported packages and no hover documentation for example. I tried attaching tsserver as an extra but it won't do anything in SFC files even though it is loaded (also tried getting documentation and completion for the same package in a js/ts file with tsserver and that works). Is this just not implemented for volar or am I missing something? Also tried nvim-lspconfigs default config and this one, neither work:
local tspath = vim.fn.stdpath "data" .. "mason/packages/vue-language-server/node_modules/typescript/lib"
require("lspconfig").volar.setup({
on_attach = on_attach,
capabilities = capabilities,
init_options = {
typescript = {
tsdk = tspath
},
languageFeatures = {
references = true,
definition = true,
typeDefinition = true,
callHierarchy = true,
hover = true,
rename = true,
signatureHelp = true,
codeAction = true,
completion = {
defaultTagNameCase = "both",
defaultAttrNameCase = "kebabCase",
},
schemaRequestService = true,
documentHighlight = true,
codeLens = true,
semanticTokens = true,
diagnostics = true,
},
},
})
Versions:
NVIM v0.9.4
Volar 1.8.25
For me, no features was working at all.
- No error reporting
- No documentation
- No autoimport
Resolved by downgrading from 2.1.6 to 1.8.27
upd: Probably unrelated to this, found fix https://github.com/vuejs/language-tools/issues/3925
Try this
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"
local lspconfig = require("lspconfig")
lspconfig.tsserver.setup({
init_options = {
plugins = {
{
name = "@vue/typescript-plugin",
location = vue_language_server_path,
languages = { "vue" },
},
},
},
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" },
})
lspconfig.volar.setup({})
If that works, add your volar setup options one by one and see if one of them causes it to break.
Thanks, it works!
At first I was getting errors like Cannot find module "./Component.vue", but fixed it by updating local vue-tsc to latest version.
Btw, what's the benefit of running separate tsserver (with default hybridMode=true), vs hybridMode=false?
Prior to 2.0.x it used to be a requirement, but it no longer is.
Try this
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" local lspconfig = require("lspconfig") lspconfig.tsserver.setup({ init_options = { plugins = { { name = "@vue/typescript-plugin", location = vue_language_server_path, languages = { "vue" }, }, }, }, filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" }, }) lspconfig.volar.setup({})If that works, add your volar setup options one by one and see if one of them causes it to break.
ty sooo much. you made my day 👍
@mactanxin @codymikol Should this be documented somewhere?
I'm pretty sure I pulled it out of the README and just made it a package, sorry it's been a minute 😅