From a17b06256c3f7909fbfc9f6fa70f1d75c0decfd5 Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 28 Nov 2024 15:06:23 +0900 Subject: [PATCH] fix: consider the original config for signs --- lua/ale/diagnostics.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lua/ale/diagnostics.lua b/lua/ale/diagnostics.lua index 21f81e2af4..93f9485937 100644 --- a/lua/ale/diagnostics.lua +++ b/lua/ale/diagnostics.lua @@ -61,11 +61,25 @@ module.sendAleResultsToDiagnostics = function(buffer, loclist) [1] = true, } - local signs = module.aleVar(buffer, 'set_signs') == 1 + local set_signs = module.aleVar(buffer, 'set_signs') + local sign_priority = module.aleVar(buffer, 'sign_priority') + local signs - if signs then + if set_signs == 1 and sign_priority then -- If signs are enabled, set the priority for them. - signs = {priority = vim.g.ale_sign_priority } + local local_cfg = { priority = sign_priority } + local global_cfg = vim.diagnostic.config().signs + + if type(global_cfg) == 'boolean' then + signs = local_cfg + elseif type(global_cfg) == 'table' then + signs = vim.tbl_extend('force', global_cfg, local_cfg) + else + signs = function(...) + local calculated = global_cfg(...) + return vim.tbl_extend('force', calculated, local_cfg) + end + end end vim.diagnostic.set( @@ -73,8 +87,8 @@ module.sendAleResultsToDiagnostics = function(buffer, loclist) buffer, diagnostics, { - virtual_text = virtualtext_enabled_set[vim.g.ale_virtualtext_cursor] ~= nil, - signs = signs, + virtual_text = virtualtext_enabled_set[vim.g.ale_virtualtext_cursor] ~= nil, + signs = signs, } ) end