@@ -12,12 +12,14 @@ M.context = {
12
12
13
13
-- attachments
14
14
mentioned_files = nil ,
15
- selections = nil
15
+ selections = nil ,
16
+ linter_errors = nil
16
17
}
17
18
18
19
function M .unload_attachments ()
19
20
M .context .mentioned_files = nil
20
21
M .context .selections = nil
22
+ M .context .linter_errors = nil
21
23
end
22
24
23
25
function M .load ()
@@ -27,6 +29,7 @@ function M.load()
27
29
28
30
M .context .current_file = current_file
29
31
M .context .cursor_data = cursor_data
32
+ M .context .linter_errors = M .check_linter_errors ()
30
33
end
31
34
32
35
local current_selection = M .get_current_selection ()
@@ -40,6 +43,23 @@ function M.load()
40
43
end
41
44
end
42
45
46
+ function M .check_linter_errors ()
47
+ local diagnostics = vim .diagnostic .get (0 , { severity = vim .diagnostic .severity .ERROR })
48
+ if # diagnostics == 0 then
49
+ return nil
50
+ end
51
+
52
+ local message = " Found " .. # diagnostics .. " error" .. (# diagnostics > 1 and " s" or " " ) .. " :"
53
+
54
+ for i , diagnostic in ipairs (diagnostics ) do
55
+ local line_number = diagnostic .lnum + 1 -- Convert to 1-based line numbers
56
+ local short_message = diagnostic .message :gsub (" %s+" , " " ):gsub (" ^%s" , " " ):gsub (" %s$" , " " )
57
+ message = message .. " \n Line " .. line_number .. " : " .. short_message
58
+ end
59
+
60
+ return message
61
+ end
62
+
43
63
function M .new_selection (file , content , lines )
44
64
return {
45
65
file = file ,
0 commit comments