diff options
| author | GR3YH4TT3R93 <76727386+GR3YH4TT3R93@users.noreply.github.com> | 2025-08-05 18:15:52 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-05 18:15:52 -0700 |
| commit | 9eb1fa38b5146b32c2dfb84c5987666e957e4e03 (patch) | |
| tree | fd15855f716b15973af9f97c0707671024dd04d1 | |
| parent | feat(vue_ls): support ts_ls #3986 (diff) | |
| download | nvim-lspconfig-9eb1fa38b5146b32c2dfb84c5987666e957e4e03.tar nvim-lspconfig-9eb1fa38b5146b32c2dfb84c5987666e957e4e03.tar.gz nvim-lspconfig-9eb1fa38b5146b32c2dfb84c5987666e957e4e03.tar.bz2 nvim-lspconfig-9eb1fa38b5146b32c2dfb84c5987666e957e4e03.tar.lz nvim-lspconfig-9eb1fa38b5146b32c2dfb84c5987666e957e4e03.tar.xz nvim-lspconfig-9eb1fa38b5146b32c2dfb84c5987666e957e4e03.tar.zst nvim-lspconfig-9eb1fa38b5146b32c2dfb84c5987666e957e4e03.zip | |
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.
| -rw-r--r-- | lsp/vue_ls.lua | 9 |
1 files 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 |
