aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp.lua13
-rw-r--r--runtime/lua/vim/treesitter/query.lua15
2 files changed, 24 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 554b5f0bfa..0e72aae188 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -739,13 +739,18 @@ function lsp.start(config, opts)
end
config.name = config.name or (config.cmd[1] and vim.fs.basename(config.cmd[1])) or nil
local bufnr = api.nvim_get_current_buf()
- for _, client in pairs(lsp.get_active_clients()) do
- if reuse_client(client, config) then
- lsp.buf_attach_client(bufnr, client.id)
- return client.id
+ for _, clients in ipairs({ uninitialized_clients, lsp.get_active_clients() }) do
+ for _, client in pairs(clients) do
+ if reuse_client(client, config) then
+ lsp.buf_attach_client(bufnr, client.id)
+ return client.id
+ end
end
end
local client_id = lsp.start_client(config)
+ if client_id == nil then
+ return nil -- lsp.start_client will have printed an error
+ end
lsp.buf_attach_client(bufnr, client_id)
return client_id
end
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index 0cc2b6d2a4..103e85abfd 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -221,6 +221,9 @@ end
local predicate_handlers = {
['eq?'] = function(match, _, source, predicate)
local node = match[predicate[2]]
+ if not node then
+ return true
+ end
local node_text = M.get_node_text(node, source)
local str
@@ -241,6 +244,9 @@ local predicate_handlers = {
['lua-match?'] = function(match, _, source, predicate)
local node = match[predicate[2]]
+ if not node then
+ return true
+ end
local regex = predicate[3]
return string.find(M.get_node_text(node, source), regex)
end,
@@ -265,6 +271,9 @@ local predicate_handlers = {
return function(match, _, source, pred)
local node = match[pred[2]]
+ if not node then
+ return true
+ end
local regex = compiled_vim_regexes[pred[3]]
return regex:match_str(M.get_node_text(node, source))
end
@@ -272,6 +281,9 @@ local predicate_handlers = {
['contains?'] = function(match, _, source, predicate)
local node = match[predicate[2]]
+ if not node then
+ return true
+ end
local node_text = M.get_node_text(node, source)
for i = 3, #predicate do
@@ -285,6 +297,9 @@ local predicate_handlers = {
['any-of?'] = function(match, _, source, predicate)
local node = match[predicate[2]]
+ if not node then
+ return true
+ end
local node_text = M.get_node_text(node, source)
-- Since 'predicate' will not be used by callers of this function, use it