diff options
| author | git-bruh <prathamIN@proton.me> | 2024-04-07 01:16:43 +0530 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2024-04-11 10:40:08 +0200 |
| commit | 435559d6ff94ba861c67a486736af5c506348326 (patch) | |
| tree | 214f4a0760482c9ca2f20998d223052d9c107567 /init.lua | |
| parent | d36c417bc662a720a0bfdd60cbc8c1dc6c915041 (diff) | |
| download | vis-lspc-435559d6ff94ba861c67a486736af5c506348326.tar.gz vis-lspc-435559d6ff94ba861c67a486736af5c506348326.zip | |
lspc, init: add different diagnostic styles for each type
Diffstat (limited to 'init.lua')
| -rw-r--r-- | init.lua | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -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 |
