From 9eb1fa38b5146b32c2dfb84c5987666e957e4e03 Mon Sep 17 00:00:00 2001 From: GR3YH4TT3R93 <76727386+GR3YH4TT3R93@users.noreply.github.com> Date: Tue, 5 Aug 2025 18:15:52 -0700 Subject: fix(vue_ls): correctly check if ts_clients exist #3987 Currently, `on_init` tries to use `or` to combine two function calls that return tables and returns truthy on the first value but an empty table is considered truthy in lua causing an error when using `vtsls`. This properly checks if either `ts_ls` or `vtsls` exists and extends the `clients` list for proper error handling. --- lsp/vue_ls.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lsp/vue_ls.lua b/lsp/vue_ls.lua index 99758bc2..97c49fc6 100644 --- a/lsp/vue_ls.lua +++ b/lsp/vue_ls.lua @@ -24,8 +24,13 @@ return { 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 = 'ts_ls' }) - or vim.lsp.get_clients({ bufnr = context.bufnr, name = 'vtsls' }) + local ts_clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = 'ts_ls' }) + local vtsls_clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = 'vtsls' }) + local clients = {} + + vim.list_extend(clients, ts_clients) + vim.list_extend(clients, vtsls_clients) + if #clients == 0 then vim.notify('Could not find `ts_ls` or `vtsls` lsp client, required by `vue_ls`.', vim.log.levels.ERROR) return -- cgit v1.2.3-70-g09d2