icons disable for diagnostic 🎄

pull/268/head
ray-x 2 years ago
parent 5bc1f93fb1
commit 45a88c08a9

@ -239,6 +239,9 @@ local diag_hdlr = function(err, result, ctx, config)
else
v.severity = 2
end
if not _NgConfigValues.icons.icons then
head = ''
end
if v.relatedInformation and v.relatedInformation[1] then
local info = v.relatedInformation[1]
-- trace(info)
@ -251,6 +254,11 @@ local diag_hdlr = function(err, result, ctx, config)
end
local bufnr1 = vim.uri_to_bufnr(uri)
local loaded = api.nvim_buf_is_loaded(bufnr1)
local ic = _NgConfigValues.icons.diagnostic_head_description
if not _NgConfigValues.icons.icons then
ic = ''
end
if _NgConfigValues.diagnostic_load_files then
-- print('load buffers')
if not loaded then
@ -260,12 +268,12 @@ local diag_hdlr = function(err, result, ctx, config)
local row = pos.line
local line = (api.nvim_buf_get_lines(bufnr1, row, row + 1, false) or { '' })[1]
if line ~= nil then
item.text = head .. line .. _NgConfigValues.icons.diagnostic_head_description .. v.message
item.text = head .. line .. ic .. v.message
else
error('diagnostic result empty line', v, row, bufnr1)
end
else
item.text = head .. _NgConfigValues.icons.diagnostic_head_description .. v.message
item.text = head .. ic .. v.message
end
if v.releated_msg then
@ -547,9 +555,12 @@ function M.config(cfg)
local default_cfg = {
underline = true,
virtual_text = true,
signs = { _NgConfigValues.icons.diagnostic_err },
update_in_insert = false,
}
if _NgConfigValues.icons then
default_cfg.signs = { _NgConfigValues.icons.diagnostic_err }
end
cfg = vim.tbl_extend('keep', cfg, default_cfg)
vim.diagnostic.config(cfg)
end

@ -19,9 +19,12 @@ function M.diagnositc_config_sign()
vim.fn.sign_define(sign_name, { text = icons.code_lens_action_icon, texthl = 'LspDiagnosticsSignHint' })
end
if not icons.icons then
return
end
local e, w, i, h = icons.diagnostic_err, icons.diagnostic_warn, icons.diagnostic_info, icons.diagnostic_hint
local t = vim.fn.sign_getdefined('DiagnosticSignWarn')
if vim.tbl_isempty(t) or t[1].text == 'W ' and icons.icons == true then
if vim.tbl_isempty(t) or t[1].text == 'W ' then
vim.fn.sign_define('DiagnosticSignError', { text = e, texthl = 'DiagnosticError', linehl = '', numhl = '' })
vim.fn.sign_define('DiagnosticSignWarn', { text = w, texthl = 'DiagnosticWarn', linehl = '', numhl = '' })
vim.fn.sign_define('DiagnosticSignInfo', { text = i, texthl = 'DiagnosticInfo', linehl = '', numhl = '' })

Loading…
Cancel
Save