From e3c3ab74d2ad0b1e47b52ecd6005ee1917df2872 Mon Sep 17 00:00:00 2001 From: Daiki Noda Date: Wed, 31 Jan 2024 15:07:01 +0900 Subject: refactor: improve get_clients_from_cmd_args (#2943) improve the get_clients_from_cmd_args for better readability and consistency. - replace unnecessary dictionary-based approaches with array-based ones. - use the '#' to improve code readability. - use the '#' for an empty check. --- plugin/lspconfig.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugin') diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index 8eb368d8..d730d2b8 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -40,12 +40,12 @@ end local get_clients_from_cmd_args = function(arg) local result = {} for id in (arg or ''):gmatch '(%d+)' do - result[id] = lsp.get_client_by_id(tonumber(id)) + result[#result + 1] = lsp.get_client_by_id(tonumber(id)) end - if vim.tbl_isempty(result) then + if #result == 0 then return require('lspconfig.util').get_managed_clients() end - return vim.tbl_values(result) + return result end for group, hi in pairs { -- cgit v1.2.3-70-g09d2