Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consider the original config for signs #4872

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions lua/ale/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,40 @@ 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 }
-- NOTE: vim.diagnostic.config() -- retrieving the current config values
-- fails in Neovim older than v0.7.0.
local ok, diag_cfg = pcall(vim.diagnostic.config)
if not ok or not diag_cfg then
diag_cfg = { signs = {} }
end
local global_cfg = diag_cfg.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(
vim.api.nvim_create_namespace('ale'),
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
Expand Down
Loading