Skip to content

Commit

Permalink
tbl_islist deprecated. better fallback of diag.config.signs
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-x committed May 21, 2024
1 parent 40c6bb3 commit 1c68f33
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
6 changes: 4 additions & 2 deletions lua/navigator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -353,6 +354,7 @@ M.setup = function(cfg)
end,
})
end

vim.defer_fn(function()
require('navigator.lazyloader').init()
require('navigator.lspclient.clients').setup(_NgConfigValues)
Expand Down
4 changes: 2 additions & 2 deletions lua/navigator/definition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
Expand Down Expand Up @@ -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 = {}
Expand Down
25 changes: 17 additions & 8 deletions lua/navigator/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 1c68f33

Please sign in to comment.