diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index be3d4dea9..8d8229ab1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,7 @@ jobs: with: crate: stylua features: lua54 + - run: stylua --version - run: stylua --check ./lua/ ./plugin/ luacheck: name: Lint Lua diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index 3f67210bf..44eb65539 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -173,6 +173,13 @@ local function transform_result_content(original_content, result_content, code_l local i = 1 while i <= #result_lines do local line_content = result_lines[i] + if line_content:match(".+") then + local filepath = line_content:match("(.+)") + if filepath then + table.insert(transformed_lines, string.format("Filepath: %s", filepath)) + goto continue + end + end if line_content == "" then is_searching = true local next_line = result_lines[i + 1] @@ -355,6 +362,8 @@ local function extract_code_snippets_map(response_content) if line:match("^%s*```") then if in_code_block then if start_line ~= nil and end_line ~= nil then + local filepath = lines[start_line_in_response_buf - 2] + if filepath:match("^[Ff]ilepath:") then filepath = filepath:match("^[Ff]ilepath:%s*(.+)") end local snippet = { range = { start_line, end_line }, content = table.concat(current_snippet, "\n"), @@ -362,7 +371,7 @@ local function extract_code_snippets_map(response_content) explanation = explanation, start_line_in_response_buf = start_line_in_response_buf, end_line_in_response_buf = idx, - filepath = lines[start_line_in_response_buf - 2], + filepath = filepath, } table.insert(snippets, snippet) end @@ -558,6 +567,7 @@ function Sidebar:apply(current_cursor) end vim.defer_fn(function() + api.nvim_set_current_win(self.code.winid) for filepath, snippets in pairs(selected_snippets_map) do local bufnr = Utils.get_or_create_buffer_with_filepath(filepath) insert_conflict_contents(bufnr, snippets) diff --git a/lua/avante/templates/planning.avanterules b/lua/avante/templates/planning.avanterules index 74b2e318e..1cc13ef0c 100644 --- a/lua/avante/templates/planning.avanterules +++ b/lua/avante/templates/planning.avanterules @@ -45,7 +45,7 @@ ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*! Here are the *SEARCH/REPLACE* blocks: -mathweb/flask/app.py +mathweb/flask/app.py from flask import Flask @@ -68,7 +68,7 @@ def factorial(n): -mathweb/flask/app.py +mathweb/flask/app.py return str(factorial(n)) @@ -86,7 +86,7 @@ mathweb/flask/app.py Here are the *SEARCH/REPLACE* blocks: -hello.py +hello.py @@ -96,7 +96,7 @@ def hello(): print("hello") -main.py +main.py def hello(): "print a greeting" diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index ecf8ccc46..f5d8e8920 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -272,7 +272,9 @@ end ---@param msg string|string[] ---@param opts? LazyNotifyOpts function M.notify(msg, opts) - if vim.in_fast_event() then return vim.schedule(function() M.notify(msg, opts) end) end + if vim.in_fast_event() then + return vim.schedule(function() M.notify(msg, opts) end) + end opts = opts or {} if type(msg) == "table" then