summaryrefslogtreecommitdiff
path: root/lua/diagnostics.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/diagnostics.lua')
-rw-r--r--lua/diagnostics.lua46
1 files changed, 24 insertions, 22 deletions
diff --git a/lua/diagnostics.lua b/lua/diagnostics.lua
index 9a3e1e4e..aa2ec92d 100644
--- a/lua/diagnostics.lua
+++ b/lua/diagnostics.lua
@@ -12,28 +12,30 @@ module.sendAleResultsToDiagnostics = function(buffer, loclist)
-- Convert all the ALE loclist items to the shape that Neovim's diagnostic
-- API is expecting.
for _, location in ipairs(loclist) do
- table.insert(
- diagnostics,
- -- All line numbers from ALE are 1-indexed, but all line numbers
- -- in the diagnostics API are 0-indexed, so we have to subtract 1
- -- to make this work.
- {
- lnum = location.lnum - 1,
- -- Ending line number, or if we don't have one, just make it the same
- -- as the starting line number
- end_lnum = (location.end_lnum or location.lnum) - 1,
- -- Which column does the error start on?
- col = math.max((location.col or 1) - 1, 0),
- -- end_col does *not* appear to need 1 subtracted, so we don't.
- end_col = location.end_col,
- -- Which severity: error, warning, or info?
- severity = ale_type_to_diagnostic_severity[location.type] or "E",
- -- The error message
- message = location.text,
- -- e.g. "rubocop"
- source = location.linter_name,
- }
- )
+ if location.bufnr == buffer then
+ table.insert(
+ diagnostics,
+ -- All line numbers from ALE are 1-indexed, but all line numbers
+ -- in the diagnostics API are 0-indexed, so we have to subtract 1
+ -- to make this work.
+ {
+ lnum = location.lnum - 1,
+ -- Ending line number, or if we don't have one, just make it the same
+ -- as the starting line number
+ end_lnum = (location.end_lnum or location.lnum) - 1,
+ -- Which column does the error start on?
+ col = math.max((location.col or 1) - 1, 0),
+ -- end_col does *not* appear to need 1 subtracted, so we don't.
+ end_col = location.end_col,
+ -- Which severity: error, warning, or info?
+ severity = ale_type_to_diagnostic_severity[location.type] or "E",
+ -- The error message
+ message = location.text,
+ -- e.g. "rubocop"
+ source = location.linter_name,
+ }
+ )
+ end
end
local virtualtext_enabled_set = {['all'] = true, ['2'] = true, [2] = true, ['current'] = true, ['1'] = true, [1] = true}