2024-05-13 03:10:32 +07:00
|
|
|
return {
|
2024-05-18 14:39:20 +02:00
|
|
|
recommended = function()
|
|
|
|
return LazyVim.extras.wants({
|
|
|
|
ft = "vue",
|
|
|
|
root = { "vue.config.js" },
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
|
2024-06-01 08:31:10 +02:00
|
|
|
-- depends on the typescript extra
|
|
|
|
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
|
|
|
|
2024-05-13 03:10:32 +07:00
|
|
|
{
|
|
|
|
"nvim-treesitter/nvim-treesitter",
|
2024-09-18 14:22:05 +08:00
|
|
|
opts = { ensure_installed = { "vue", "css" } },
|
2024-05-13 03:10:32 +07:00
|
|
|
},
|
|
|
|
|
2025-07-08 16:24:23 +02:00
|
|
|
-- Configure vtsls (the TypeScript plugin host) with @vue/typescript-plugin
|
2024-06-01 08:31:10 +02:00
|
|
|
{
|
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
opts = function(_, opts)
|
2025-07-08 16:24:23 +02:00
|
|
|
opts.servers.vtsls = opts.servers.vtsls or {}
|
|
|
|
opts.servers.vtsls.filetypes = opts.servers.vtsls.filetypes or {}
|
2024-06-01 08:31:10 +02:00
|
|
|
table.insert(opts.servers.vtsls.filetypes, "vue")
|
2024-05-31 20:53:44 +02:00
|
|
|
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
|
2024-06-01 08:31:10 +02:00
|
|
|
{
|
|
|
|
name = "@vue/typescript-plugin",
|
|
|
|
location = LazyVim.get_pkg_path("vue-language-server", "/node_modules/@vue/language-server"),
|
|
|
|
languages = { "vue" },
|
|
|
|
configNamespace = "typescript",
|
|
|
|
enableForWorkspaceTypeScriptVersions = true,
|
|
|
|
},
|
2024-05-31 13:52:41 +02:00
|
|
|
})
|
2024-05-13 03:10:32 +07:00
|
|
|
end,
|
|
|
|
},
|
2025-07-08 16:24:23 +02:00
|
|
|
|
|
|
|
-- 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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-05-13 03:10:32 +07:00
|
|
|
}
|