aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2026-09-30 13:12:14 +0200
committerMatěj Cepl <mcepl@cepl.eu>2026-09-30 13:14:23 +0200
commitff764eed4ca67cff8016d971f07de696cfbc3ff4 (patch)
treeb3187edfcd5ea183dd7447bd9f5d06536ac1a9ed /init.lua
parentc54c24b2639c8e9f9b3dd03d7a4fe556da328a76 (diff)
downloadvis-lspc-ff764eed4ca67cff8016d971f07de696cfbc3ff4.tar.gz
vis-lspc-ff764eed4ca67cff8016d971f07de696cfbc3ff4.zip
support feature detection for vis ui styling API
In builds of vis packaged without a git tree (such as openSUSE OBS RPM builds), vis.API defaults to 0. Checking `vis.API > 3215` therefore fails even when the new vis.ui styling API is present. Check for the existence of `vis.ui.style_define` and `vis.ui.style_push` directly, and accept an optional window object in util.style_define for backward compatibility with older versions.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 8002e62..6f46895 100644
--- a/init.lua
+++ b/init.lua
@@ -594,7 +594,7 @@ end
local function lspc_highlight_server_diagnostics(win, server_diagnostics, style)
if not style then
if not lspc.diagnostic_style_id then
- if vis.API and vis.API > 3215 then
+ if (vis.API and vis.API > 3215) or (vis.ui and vis.ui.style_push) then
lspc.diagnostic_style_id = vis.ui:style_push()
else
lspc.diagnostic_style_id = win.STYLE_LEXER_MAX
@@ -612,7 +612,7 @@ local function lspc_highlight_server_diagnostics(win, server_diagnostics, style)
for _, diagnostic in ipairs(server_diagnostics) do
local diagnostic_style = level_mapping[diagnostic.severity] or level_mapping[1]
- assert(util.style_define(style, diagnostic_style))
+ assert(util.style_define(style, diagnostic_style, win))
if lspc.highlight_diagnostics == 'range' then
local range = diagnostic.vis_range