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

Commit 5491d82

Browse files
committed
lsp: simplify check for clients presence
Back in #160, I implemented the check with a loop because I didn't realize vim.tbl_isempty existed. Now that I know about it, I want to make sure we use it :)
1 parent 52ccd7c commit 5491d82

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lua/completion/source/lsp.lua

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,11 @@ M.getCallback = function()
128128
return M.callback
129129
end
130130

131-
local buf_has_clients = function()
132-
-- buf_get_clients() may return an associative table that has numbers as
133-
-- keys. So while using # may work at first, it stops working if the client
134-
-- is restarted.
135-
for _ in pairs(vim.lsp.buf_get_clients()) do
136-
return true
137-
end
138-
return false
139-
end
140-
141131
M.triggerFunction = function(_, params)
142132
local position_param = vim.lsp.util.make_position_params()
143133
M.callback = false
144134
M.items = {}
145-
if not buf_has_clients() then
135+
if vim.tbl_isempty(vim.lsp.buf_get_clients()) then
146136
M.callback = true
147137
return
148138
end

0 commit comments

Comments
 (0)