From 435559d6ff94ba861c67a486736af5c506348326 Mon Sep 17 00:00:00 2001 From: git-bruh Date: Sun, 7 Apr 2024 01:16:43 +0530 Subject: lspc, init: add different diagnostic styles for each type --- init.lua | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 54ea67a..8fe950f 100644 --- a/init.lua +++ b/init.lua @@ -580,7 +580,17 @@ local function lspc_highlight_diagnostics(win, diagnostics, style) style = lspc.diagnostic_style_id end + local level_mapping = { + [1] = lspc.diagnostic_styles.error, + [2] = lspc.diagnostic_styles.warning, + [3] = lspc.diagnostic_styles.information, + [4] = lspc.diagnostic_styles.hint + } + for _, diagnostic in ipairs(diagnostics) do + local diagnostic_style = level_mapping[diagnostic.severity] or level_mapping[1] + assert(win:style_define(lspc.diagnostic_style_id, diagnostic_style)) + if lspc.highlight_diagnostics == 'range' then local range = diagnostic.vis_range @@ -1585,8 +1595,6 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) if lspc.autostart and win.syntax then ls_start_server(win.syntax) end - - assert(win:style_define(lspc.diagnostic_style_id, lspc.diagnostic_style)) end) vis.events.subscribe(vis.events.WIN_HIGHLIGHT, function(win) @@ -1640,5 +1648,21 @@ vis:option_register('lspc-message-level', 'number', function(value) return true end, 'Message level to show in UI (for server messages)') +vis:option_register('lspc-diagnostic-style-error', 'string', function(value) + lspc.diagnostic_styles.error = value +end, 'Style for diagnostic errors') + +vis:option_register('lspc-diagnostic-style-warning', 'string', function(value) + lspc.diagnostic_styles.warning = value +end, 'Style for diagnostic warnings') + +vis:option_register('lspc-diagnostic-style-information', 'string', function(value) + lspc.diagnostic_styles.information = value +end, 'Style for diagnostic information') + +vis:option_register('lspc-diagnostic-style-hint', 'string', function(value) + lspc.diagnostic_styles.hint = value +end, 'Style for diagnostic hints') + dofile(source_path .. 'bindings.lua') return lspc -- cgit v1.2.3