From 1c68f33ef2b3e77ab1df80799d92acbd8a970dba Mon Sep 17 00:00:00 2001 From: ray-x Date: Tue, 21 May 2024 12:19:38 +1000 Subject: [PATCH] tbl_islist deprecated. better fallback of diag.config.signs --- lua/navigator.lua | 6 ++++-- lua/navigator/definition.lua | 4 ++-- lua/navigator/diagnostics.lua | 25 +++++++++++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lua/navigator.lua b/lua/navigator.lua index 8cb4d3b..8e290c4 100644 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -247,9 +247,10 @@ M.deprecated = function(cfg) warn('ts_fold option changed, refer to README for more details') cfg.ts_fold = { enable = cfg.ts_fold } end - local has_nvim_011 = vim.fn.has('nvim-0.11.0') - if not has_nvim_011 then + local has_nvim_010 = vim.fn.has('nvim-0.10') + if not has_nvim_010 then vim.lsp.get_clients = vim.lsp.get_active_clients + vim.islist = vim.tbl_islist end end @@ -353,6 +354,7 @@ M.setup = function(cfg) end, }) end + vim.defer_fn(function() require('navigator.lazyloader').init() require('navigator.lspclient.clients').setup(_NgConfigValues) diff --git a/lua/navigator/definition.lua b/lua/navigator/definition.lua index 1e07ed6..7e40fa4 100644 --- a/lua/navigator/definition.lua +++ b/lua/navigator/definition.lua @@ -29,7 +29,7 @@ local definition_hdlr = function(err, locations, ctx, _) locations = util.dedup(locations) log(locations) log('found ' .. #locations .. ' locations') - if vim.tbl_islist(locations) then + if vim.islist(locations) then if #locations > 1 then local items = locations_to_items(locations) gui.new_list_view({ items = items, api = 'Definition', title = 'Definition' }) @@ -69,7 +69,7 @@ local function def_preview(timeout_ms, method) end log(result) - if not vim.tbl_islist(result) then + if not vim.islist(result) then return end local data = {} diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index 278da93..0da3ea7 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -327,14 +327,19 @@ local function diag_signs() text[k] = v end end - if vim.tbl_isempty(t) or (t[1] and t[1].text:find('W')) then - local signs = { + -- text must have at least one sign + local signs_valid = false + for _, v in pairs(text) do + if v then + signs_valid = true + break + end + end + if vim.tbl_isempty(t) or (t[1] and t[1].text and t[1].text:find('W')) and signs_valid == true then + log('set signs ', text) + return { text = text, - linehl = { - [vim.diagnostic.severity.ERROR] = 'ErrorMsg', - }, } - return signs end end end @@ -348,6 +353,8 @@ function M.setup(cfg) if diagnostic_cfg ~= nil and diagnostic_cfg.float ~= nil then return end + + local signs = diag_signs() diagnostic_cfg = { -- Enable underline, use default values underline = _NgConfigValues.lsp.diagnostic.underline, @@ -357,8 +364,10 @@ function M.setup(cfg) update_in_insert = _NgConfigValues.lsp.diagnostic.update_in_insert or false, severity_sort = _NgConfigValues.lsp.diagnostic.severity_sort, float = _NgConfigValues.lsp.diagnostic.float, - signs = diag_signs(), } + if type(signs) == 'table' then + diagnostic_cfg.signs = signs + end diagnostic_cfg.virtual_text = _NgConfigValues.lsp.diagnostic.virtual_text if type(_NgConfigValues.lsp.diagnostic.virtual_text) == 'table' and _NgConfigValues.icons.icons @@ -373,7 +382,7 @@ function M.setup(cfg) if _NgConfigValues.lsp.diagnostic_scrollbar_sign then api.nvim_create_autocmd({ 'WinScrolled' }, { - group = api.nvim_create_augroup('NGWinScrolledGroup', {}), + group = api.nvim_create_augroup('NGWinScrolledGroup', { clear = false }), pattern = '*', callback = function() require('navigator.diagnostics').update_err_marker()