Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit b354c7f

Browse files
authored
Merge pull request #160 from fsouza/fix-lsp-completion-after-restart
source/lsp: fix check for clients presence
2 parents b3d8cd0 + f22fb9a commit b354c7f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

lua/completion/source/lsp.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,21 @@ M.getCallback = function()
120120
return M.callback
121121
end
122122

123+
local buf_has_clients = function()
124+
-- buf_get_clients() may return an associative table that has numbers as
125+
-- keys. So while using # may work at first, it stops working if the client
126+
-- is restarted.
127+
for _ in pairs(vim.lsp.buf_get_clients()) do
128+
return true
129+
end
130+
return false
131+
end
132+
123133
M.triggerFunction = function(_, params)
124134
local position_param = vim.lsp.util.make_position_params()
125135
M.callback = false
126136
M.items = {}
127-
if #vim.lsp.buf_get_clients() == 0 then
137+
if not buf_has_clients() then
128138
M.callback = true
129139
return
130140
end

0 commit comments

Comments
 (0)