From d47c1d6385fbe4f8854e32402bbe84566737e3a7 Mon Sep 17 00:00:00 2001 From: winkee Date: Sat, 30 Apr 2022 12:30:43 +0800 Subject: [PATCH 1/5] feat(ISSUE #229): Concatenate all lsp client names found by GetLspClient --- lua/galaxyline/provider_lsp.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/galaxyline/provider_lsp.lua b/lua/galaxyline/provider_lsp.lua index 0ae84cf..419cdf6 100644 --- a/lua/galaxyline/provider_lsp.lua +++ b/lua/galaxyline/provider_lsp.lua @@ -6,13 +6,19 @@ local get_lsp_client = function (msg) return msg end + local client_name = '' for _,client in ipairs(clients) do local filetypes = client.config.filetypes if filetypes and vim.fn.index(filetypes,buf_ft) ~= -1 then - return client.name + client_name = client_name .. client.name .. ', ' end end - return msg + local len = client_name:len() + if len > 1 then + return client_name:sub(0, len - 2) + else + return msg + end end return { From de5c93b6b7a370b6e83a6d7593c8ab7c67f21b0c Mon Sep 17 00:00:00 2001 From: winkee Date: Sat, 30 Apr 2022 13:31:29 +0800 Subject: [PATCH 2/5] fix: remove space after , --- lua/galaxyline/provider_lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/galaxyline/provider_lsp.lua b/lua/galaxyline/provider_lsp.lua index 419cdf6..ed1daad 100644 --- a/lua/galaxyline/provider_lsp.lua +++ b/lua/galaxyline/provider_lsp.lua @@ -10,7 +10,7 @@ local get_lsp_client = function (msg) for _,client in ipairs(clients) do local filetypes = client.config.filetypes if filetypes and vim.fn.index(filetypes,buf_ft) ~= -1 then - client_name = client_name .. client.name .. ', ' + client_name = client_name .. client.name .. ',' end end local len = client_name:len() From 912ecdbefe60adb08e955d216547d2c3b8c66bdf Mon Sep 17 00:00:00 2001 From: winkee Date: Sat, 30 Apr 2022 13:34:54 +0800 Subject: [PATCH 3/5] fix index --- lua/galaxyline/provider_lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/galaxyline/provider_lsp.lua b/lua/galaxyline/provider_lsp.lua index ed1daad..31e7601 100644 --- a/lua/galaxyline/provider_lsp.lua +++ b/lua/galaxyline/provider_lsp.lua @@ -15,7 +15,7 @@ local get_lsp_client = function (msg) end local len = client_name:len() if len > 1 then - return client_name:sub(0, len - 2) + return client_name:sub(0, len - 1) else return msg end From d6322ebaa69f35d4e0a33da9e954bd3b9528e9da Mon Sep 17 00:00:00 2001 From: winkee Date: Sat, 30 Apr 2022 14:35:56 +0800 Subject: [PATCH 4/5] fix: remove duplicate client names --- lua/galaxyline/provider_lsp.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lua/galaxyline/provider_lsp.lua b/lua/galaxyline/provider_lsp.lua index 31e7601..db88202 100644 --- a/lua/galaxyline/provider_lsp.lua +++ b/lua/galaxyline/provider_lsp.lua @@ -1,3 +1,12 @@ +function pconcat(tab) + local ctab, n = {}, 1 + for k, _ in pairs(tab) do + ctab[n] = k + n = n + 1 + end + return table.concat(ctab, ',') +end + local get_lsp_client = function (msg) msg = msg or 'No Active Lsp' local buf_ft = vim.api.nvim_buf_get_option(0,'filetype') @@ -6,16 +15,17 @@ local get_lsp_client = function (msg) return msg end - local client_name = '' + local tbl_names = {} for _,client in ipairs(clients) do local filetypes = client.config.filetypes if filetypes and vim.fn.index(filetypes,buf_ft) ~= -1 then - client_name = client_name .. client.name .. ',' + tbl_names[client.name] = true end end - local len = client_name:len() - if len > 1 then - return client_name:sub(0, len - 1) + + client_name = pconcat(tbl_names) + if client_name:len() > 0 then + return client_name else return msg end From c0b67b8ec8497d999fbd27315da9d739823a9fae Mon Sep 17 00:00:00 2001 From: winkee Date: Tue, 10 May 2022 15:36:10 +0800 Subject: [PATCH 5/5] fix: vim.lsp.diagnostic.get_count is deprecated. replaced with vim.diagnostic.get() --- lua/galaxyline/provider_diagnostic.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/galaxyline/provider_diagnostic.lua b/lua/galaxyline/provider_diagnostic.lua index cebd3bc..78b767c 100644 --- a/lua/galaxyline/provider_diagnostic.lua +++ b/lua/galaxyline/provider_diagnostic.lua @@ -21,7 +21,7 @@ local function get_nvim_lsp_diagnostic(diag_type) local count = 0 for _, client in ipairs(active_clients) do - count = count + lsp.diagnostic.get_count(api.nvim_get_current_buf(),diag_type,client.id) + count = count + table.getn(vim.diagnostic.get(api.nvim_get_current_buf(),{ severity = diag_type })) end if count ~= 0 then return count .. ' ' end @@ -32,7 +32,7 @@ function M.get_diagnostic_error() if vim.fn.exists('*coc#rpc#start_server') == 1 then return get_coc_diagnostic('error') elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then - return get_nvim_lsp_diagnostic('Error') + return get_nvim_lsp_diagnostic(vim.diagnostic.severity.ERROR) end return '' end @@ -41,7 +41,7 @@ function M.get_diagnostic_warn() if vim.fn.exists('*coc#rpc#start_server') == 1 then return get_coc_diagnostic('warning') elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then - return get_nvim_lsp_diagnostic('Warning') + return get_nvim_lsp_diagnostic(vim.diagnostic.severity.WARN) end return '' end @@ -50,7 +50,7 @@ function M.get_diagnostic_hint() if vim.fn.exists('*coc#rpc#start_server') == 1 then return get_coc_diagnostic('hint') elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then - return get_nvim_lsp_diagnostic('Hint') + return get_nvim_lsp_diagnostic(vim.diagnostic.severity.HINT) end return '' end @@ -59,7 +59,7 @@ function M.get_diagnostic_info() if vim.fn.exists('*coc#rpc#start_server') == 1 then return get_coc_diagnostic('information') elseif not vim.tbl_isempty(lsp.buf_get_clients(0)) then - return get_nvim_lsp_diagnostic('Information') + return get_nvim_lsp_diagnostic(vim.diagnostic.severity.INFO) end return '' end