feat: cwd ad project root (#1517)

This commit is contained in:
yetone
2025-03-07 11:53:09 +08:00
committed by GitHub
parent dbe31a866a
commit 6c7c5464ca
2 changed files with 6 additions and 0 deletions

View File

@@ -319,6 +319,7 @@ M._defaults = {
minimize_diff = true,
enable_token_counting = true,
enable_cursor_planning_mode = false,
use_cwd_as_project_root = false,
},
history = {
max_tokens = 4096,

View File

@@ -1,5 +1,6 @@
-- COPIED and MODIFIED from https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/root.lua
local Utils = require("avante.utils")
local Config = require("avante.config")
---@class avante.utils.root
---@overload fun(): string
@@ -112,6 +113,10 @@ M.cache = {}
---@param opts? {normalize?:boolean, buf?:number}
---@return string
function M.get(opts)
if Config.behaviour.use_cwd_as_project_root then
local cwd = vim.uv.cwd()
if cwd and cwd ~= "" then return cwd end
end
opts = opts or {}
local buf = opts.buf or vim.api.nvim_get_current_buf()
local ret = M.cache[buf]