summaryrefslogtreecommitdiff
path: root/nvim/lsp/vue_ls.lua
diff options
context:
space:
mode:
authoranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
committeranand <anand.panchdhari@gmail.com>2025-12-17 15:57:55 +0530
commitb7ef29a8886a57aadb787807a7c6cf74c1f0ed3a (patch)
tree366a68240fbc9da6b1d567bd6c46d1350ad814de /nvim/lsp/vue_ls.lua
Nixos
Diffstat (limited to 'nvim/lsp/vue_ls.lua')
-rwxr-xr-xnvim/lsp/vue_ls.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/nvim/lsp/vue_ls.lua b/nvim/lsp/vue_ls.lua
new file mode 100755
index 0000000..3900802
--- /dev/null
+++ b/nvim/lsp/vue_ls.lua
@@ -0,0 +1,50 @@
+---@brief
+---
+--- https://github.com/vuejs/language-tools/tree/master/packages/language-server
+---
+--- The official language server for Vue
+---
+--- It can be installed via npm:
+--- ```sh
+--- npm install -g @vue/language-server
+--- ```
+---
+--- The language server only supports Vue 3 projects by default.
+--- For Vue 2 projects, [additional configuration](https://github.com/vuejs/language-tools/blob/master/extensions/vscode/README.md?plain=1#L19) are required.
+---
+--- The Vue language server works in "hybrid mode" that exclusively manages the CSS/HTML sections.
+--- You need the `vtsls` server with the `@vue/typescript-plugin` plugin to support TypeScript in `.vue` files.
+--- See `vtsls` section and https://github.com/vuejs/language-tools/wiki/Neovim for more information.
+---
+--- NOTE: Since v3.0.0, the Vue Language Server [no longer supports takeover mode](https://github.com/vuejs/language-tools/pull/5248).
+
+return {
+ cmd = { 'vue-language-server', '--stdio' },
+ filetypes = { 'vue' },
+ root_markers = { 'package.json' },
+ on_init = function(client)
+ client.handlers['tsserver/request'] = function(_, result, context)
+ local clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = 'vtsls' })
+ if #clients == 0 then
+ vim.notify('Could not find `vtsls` lsp client, required by `vue_ls`.', vim.log.levels.ERROR)
+ return
+ end
+ local ts_client = clients[1]
+
+ local param = unpack(result)
+ local id, command, payload = unpack(param)
+ ts_client:exec_cmd({
+ title = 'vue_request_forward', -- You can give title anything as it's used to represent a command in the UI, `:h Client:exec_cmd`
+ command = 'typescript.tsserverRequest',
+ arguments = {
+ command,
+ payload,
+ },
+ }, { bufnr = context.bufnr }, function(_, r)
+ local response_data = { { id, r and r.body } }
+ ---@diagnostic disable-next-line: param-type-mismatch
+ client:notify('tsserver/response', response_data)
+ end)
+ end
+ end,
+}