mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 05:24:46 +08:00
#4442 Configure signs in Neovim diagnostics
Respect ALE's options to enable/disable signs in Neovim diagnostics, and use ALE's priority setting.
This commit is contained in:
@@ -2106,6 +2106,10 @@ g:ale_set_signs *g:ale_set_signs*
|
|||||||
When this option is set to `1`, the |sign| column will be populated with
|
When this option is set to `1`, the |sign| column will be populated with
|
||||||
signs marking where problems appear in the file.
|
signs marking where problems appear in the file.
|
||||||
|
|
||||||
|
When |g:ale_use_neovim_diagnostics_api| is `1`, the only other setting that
|
||||||
|
will be respected for signs is |g:ale_sign_priority|. No other settings,
|
||||||
|
highlights, text, or behaviors will apply.
|
||||||
|
|
||||||
ALE will use the following highlight groups for problems:
|
ALE will use the following highlight groups for problems:
|
||||||
|
|
||||||
|ALEErrorSign| - Items with `'type': 'E'`
|
|ALEErrorSign| - Items with `'type': 'E'`
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ local ale_type_to_diagnostic_severity = {
|
|||||||
I = vim.diagnostic.severity.INFO
|
I = vim.diagnostic.severity.INFO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Equivalent to ale#Var, only we can't error on missing global keys.
|
||||||
|
module.aleVar = function(buffer, key)
|
||||||
|
key = "ale_" .. key
|
||||||
|
local exists, value = pcall(vim.api.nvim_buf_get_var, buffer, key)
|
||||||
|
|
||||||
|
if exists then
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.g[key]
|
||||||
|
end
|
||||||
|
|
||||||
module.sendAleResultsToDiagnostics = function(buffer, loclist)
|
module.sendAleResultsToDiagnostics = function(buffer, loclist)
|
||||||
local diagnostics = {}
|
local diagnostics = {}
|
||||||
|
|
||||||
@@ -38,13 +50,30 @@ module.sendAleResultsToDiagnostics = function(buffer, loclist)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local virtualtext_enabled_set = {['all'] = true, ['2'] = true, [2] = true, ['current'] = true, ['1'] = true, [1] = true}
|
local virtualtext_enabled_set = {
|
||||||
|
['all'] = true,
|
||||||
|
['2'] = true,
|
||||||
|
[2] = true,
|
||||||
|
['current'] = true,
|
||||||
|
['1'] = true,
|
||||||
|
[1] = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
local signs = module.aleVar(buffer, 'set_signs') == 1
|
||||||
|
|
||||||
|
if signs then
|
||||||
|
-- If signs are enabled, set the priority for them.
|
||||||
|
signs = {priority = vim.g.ale_sign_priority }
|
||||||
|
end
|
||||||
|
|
||||||
vim.diagnostic.set(
|
vim.diagnostic.set(
|
||||||
vim.api.nvim_create_namespace('ale'),
|
vim.api.nvim_create_namespace('ale'),
|
||||||
buffer,
|
buffer,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
{ virtual_text = virtualtext_enabled_set[vim.g.ale_virtualtext_cursor] ~= nil}
|
{
|
||||||
|
virtual_text = virtualtext_enabled_set[vim.g.ale_virtualtext_cursor] ~= nil,
|
||||||
|
signs = signs,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user