All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 local ale = require("ale")
5 local diagnostic_severity_map = {
6 E = vim.diagnostic.severity.ERROR,
7 W = vim.diagnostic.severity.WARN,
8 I = vim.diagnostic.severity.INFO
11 -- A map of all possible values that we can consider virtualtext enabled for
12 -- from ALE's setting.
13 local virtualtext_enabled_set = {
23 ---Send diagnostics to the Neovim diagnostics API
24 ---@param buffer number The buffer number to retreive the variable for.
25 ---@param loclist table The loclist array to report as diagnostics.
27 module.send = function(buffer, loclist)
28 local diagnostics = {}
30 -- Convert all the ALE loclist items to the shape that Neovim's diagnostic
32 for _, location in ipairs(loclist) do
33 if location.bufnr == buffer then
36 -- All line numbers from ALE are 1-indexed, but all line
37 -- numbers in the diagnostics API are 0-indexed, so we have to
38 -- subtract 1 to make this work.
40 lnum = location.lnum - 1,
41 -- Ending line number, or if we don't have one, just make
42 -- it the same as the starting line number
43 end_lnum = (location.end_lnum or location.lnum) - 1,
44 -- Which column does the error start on?
45 col = math.max((location.col or 1) - 1, 0),
46 -- end_col does not appear to need 1 subtracted.
47 end_col = location.end_col,
48 -- Which severity: error, warning, or info?
49 severity = diagnostic_severity_map[location.type] or "E",
53 message = location.text,
55 source = location.linter_name,
61 local set_signs = ale.var(buffer, "set_signs")
62 local sign_priority = ale.var(buffer, "sign_priority")
65 if (set_signs == 1 or set_signs == true) and sign_priority then
66 -- If signs are enabled, set the priority for them.
67 local local_cfg = { priority = sign_priority }
68 local global_cfg = vim.diagnostic.config().signs
70 if global_cfg == false or global_cfg == true or global_cfg == nil then
72 elseif type(global_cfg) == "table" then
73 signs = vim.tbl_extend("force", global_cfg, local_cfg)
75 -- If a global function is defined, then define a function
76 -- that calls that function when Neovim calls our function.
78 return vim.tbl_extend("force", global_cfg(...), local_cfg)
84 vim.api.nvim_create_namespace("ale"),
89 virtualtext_enabled_set[vim.g.ale_virtualtext_cursor] ~= nil,