feat: add lint tool
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
local handler = require("chatgpt_nvim.handler")
|
||||
local lint = require("chatgpt_nvim.tools.lint")
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -8,7 +9,6 @@ local function search_and_replace(original, replacements)
|
||||
for _, r in ipairs(replacements) do
|
||||
local search_str = r.search or ""
|
||||
local replace_str = r.replace or ""
|
||||
-- Here we do a global plain text replacement
|
||||
updated = updated:gsub(search_str, replace_str)
|
||||
end
|
||||
return updated
|
||||
@@ -41,6 +41,17 @@ M.run = function(tool_call, conf, prompt_user_tool_accept, is_subpath, read_file
|
||||
msg[#msg+1] = string.format("<final_file_content path=\"%s\">\n%s\n</final_file_content>", path, updated_data)
|
||||
msg[#msg+1] = "\nIMPORTANT: For any future changes to this file, use the final_file_content shown above as your reference.\n"
|
||||
|
||||
-- 2) Lint check if enabled
|
||||
if conf.auto_lint then
|
||||
local output, err = lint.lint_file(path)
|
||||
if output then
|
||||
msg[#msg+1] = "\n--- Lint Results ---\n"
|
||||
msg[#msg+1] = output
|
||||
else
|
||||
msg[#msg+1] = "\n(Lint) " .. (err or "Could not lint this file.")
|
||||
end
|
||||
end
|
||||
|
||||
return table.concat(msg, "")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user