summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2023-09-08 23:44:48 +0100
committerw0rp <devw0rp@gmail.com>2023-09-08 23:54:16 +0100
commite4411276a5fd5683a4e78bbd3280c4479fed346d (patch)
tree10a072f795c736624eb0c23357566046abfa3245 /lua
parentdadc7784512ab26a84970cf0b49eb8ebaf1013dd (diff)
downloadale-e4411276a5fd5683a4e78bbd3280c4479fed346d.zip
#4442 Configure signs in Neovim diagnostics
Respect ALE's options to enable/disable signs in Neovim diagnostics, and use ALE's priority setting.
Diffstat (limited to 'lua')
-rw-r--r--lua/diagnostics.lua33
1 files changed, 31 insertions, 2 deletions
diff --git a/lua/diagnostics.lua b/lua/diagnostics.lua
index aa2ec92d..55b50d6a 100644
--- a/lua/diagnostics.lua
+++ b/lua/diagnostics.lua
@@ -6,6 +6,18 @@ local ale_type_to_diagnostic_severity = {
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)
local diagnostics = {}
@@ -38,13 +50,30 @@ module.sendAleResultsToDiagnostics = function(buffer, loclist)
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.api.nvim_create_namespace('ale'),
buffer,
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