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

Can't get all features working in neovim lsp #3791

Open
marcelbusch opened this issue Dec 11, 2023 · 4 comments
Open

Can't get all features working in neovim lsp #3791

marcelbusch opened this issue Dec 11, 2023 · 4 comments

Comments

@marcelbusch
Copy link

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
@last-partizan
Copy link

last-partizan commented Apr 28, 2024

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 #3925

@codymikol
Copy link
Contributor

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.

@last-partizan
Copy link

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?

@codymikol
Copy link
Contributor

Prior to 2.0.x it used to be a requirement, but it no longer is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants