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 | |
| parent | d36c417bc662a720a0bfdd60cbc8c1dc6c915041 (diff) | |
| download | vis-lspc-435559d6ff94ba861c67a486736af5c506348326.tar.gz vis-lspc-435559d6ff94ba861c67a486736af5c506348326.zip | |
lspc, init: add different diagnostic styles for each type
| -rw-r--r-- | init.lua | 28 | ||||
| -rw-r--r-- | lspc.lua | 11 |
2 files changed, 34 insertions, 5 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 @@ -35,9 +35,14 @@ local lspc = { highlight_diagnostics = false, -- style id used by lspc to register the style used to highlight diagnostics diagnostic_style_id = 64, -- 64 is the last style id available for the lexer styles. See vis/ui.h. - -- style used by lspc to highlight the diagnostic range - -- 60% solarized red - diagnostic_style = 'back:#e3514f', + -- styles used by lspc to highlight the diagnostic range + -- must be set by the user + diagnostic_styles = { + error = 'fore:default,back:default', + warning = 'fore:default,back:default', + information = 'fore:default,back:default', + hint = 'fore:default,back:default', + }, -- restore the position of the primary curser after applying a workspace edit workspace_edit_remember_cursor = true, |
