Show lspkind error message just once
Instead of showing an error message for every symbol in every outline window, show just one error on opening nvim.
This commit is contained in:
@@ -45,6 +45,24 @@ for k, v in pairs(M.kinds) do
|
|||||||
M.str_to_kind[v] = k
|
M.str_to_kind[v] = k
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@return table
|
||||||
|
local function get_lspkind()
|
||||||
|
local has_lspkind, lspkind = pcall(require, 'lspkind')
|
||||||
|
if has_lspkind then
|
||||||
|
return lspkind
|
||||||
|
end
|
||||||
|
vim.notify(
|
||||||
|
'[outline]: icon_source set to lspkind but failed to require lspkind!',
|
||||||
|
vim.log.levels.ERROR
|
||||||
|
)
|
||||||
|
-- return lspkind stub
|
||||||
|
return {
|
||||||
|
symbolic = function(kind, opts) return '' end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local lspkind = get_lspkind()
|
||||||
|
|
||||||
---@param kind string|integer
|
---@param kind string|integer
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return string icon
|
---@return string icon
|
||||||
@@ -66,17 +84,9 @@ function M.icon_from_kind(kind, bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if cfg.o.symbols.icon_source == 'lspkind' then
|
if cfg.o.symbols.icon_source == 'lspkind' then
|
||||||
local has_lspkind, lspkind = pcall(require, 'lspkind')
|
local icon = lspkind.symbolic(kindstr, { with_text = false })
|
||||||
if not has_lspkind then
|
if icon and icon ~= '' then
|
||||||
vim.notify(
|
return icon
|
||||||
'[outline]: icon_source set to lspkind but failed to require lspkind!',
|
|
||||||
vim.log.levels.ERROR
|
|
||||||
)
|
|
||||||
else
|
|
||||||
local icon = lspkind.symbolic(kindstr, { with_text = false })
|
|
||||||
if icon and icon ~= '' then
|
|
||||||
return icon
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user