mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-13 19:04:36 +02:00
fix(lang.vue): update vue lang extra to work with vue-language-server > 3
adapt vue lang extra to breaking changes in vue-language-server: https://github.com/vuejs/language-tools/wiki/Neovim
This commit is contained in:
parent
25abbf546d
commit
ab539bba04
1 changed files with 37 additions and 18 deletions
|
@ -14,27 +14,12 @@ return {
|
||||||
opts = { ensure_installed = { "vue", "css" } },
|
opts = { ensure_installed = { "vue", "css" } },
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Add LSP servers
|
-- Configure vtsls (the TypeScript plugin host) with @vue/typescript-plugin
|
||||||
{
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
opts = {
|
|
||||||
servers = {
|
|
||||||
volar = {
|
|
||||||
init_options = {
|
|
||||||
vue = {
|
|
||||||
hybridMode = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
vtsls = {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Configure tsserver plugin
|
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
|
opts.servers.vtsls = opts.servers.vtsls or {}
|
||||||
|
opts.servers.vtsls.filetypes = opts.servers.vtsls.filetypes or {}
|
||||||
table.insert(opts.servers.vtsls.filetypes, "vue")
|
table.insert(opts.servers.vtsls.filetypes, "vue")
|
||||||
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
|
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
|
||||||
{
|
{
|
||||||
|
@ -47,4 +32,38 @@ return {
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- Hook vue_ls to forward requests to vtsls
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
opts = {
|
||||||
|
servers = {
|
||||||
|
volar = { -- when LazyVim switches to nvim-lspconfig ≥ v2.2.0 rename this to `vue_ls`
|
||||||
|
on_init = function(client)
|
||||||
|
client.handlers["tsserver/request"] = function(_, result, context)
|
||||||
|
-- find the vtsls client
|
||||||
|
local clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = "vtsls" })
|
||||||
|
if #clients == 0 then
|
||||||
|
vim.notify("Could not find `vtsls` client, Vue LSP features will be disabled", vim.log.levels.ERROR)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local ts_client = clients[1]
|
||||||
|
-- unpack the forwarded request
|
||||||
|
local params = unpack(result)
|
||||||
|
local id, command, payload = unpack(params)
|
||||||
|
-- forward it
|
||||||
|
ts_client:exec_cmd({
|
||||||
|
title = "vue_request_forward",
|
||||||
|
command = "typescript.tsserverRequest",
|
||||||
|
arguments = { command, payload },
|
||||||
|
}, { bufnr = context.bufnr }, function(_, resp)
|
||||||
|
-- send the tsserver/response back to Vue LSP
|
||||||
|
client.notify("tsserver/response", { { id, resp.body } })
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue