fix(style): add parentheses (#471)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-09-03 05:12:07 -04:00
committed by GitHub
parent 8cc674f1da
commit 0d8098e4eb
25 changed files with 213 additions and 214 deletions

View File

@@ -1,8 +1,8 @@
local fn, api = vim.fn, vim.api
local Utils = require "avante.utils"
local Path = require "plenary.path"
local Scan = require "plenary.scandir"
local Config = require "avante.config"
local Utils = require("avante.utils")
local Path = require("plenary.path")
local Scan = require("plenary.scandir")
local Config = require("avante.config")
---@class avante.Path
---@field history_path Path
@@ -75,26 +75,26 @@ N.get = function(bufnr)
if not P.available() then error("Make sure to build avante (missing avante_templates)", 2) end
-- get root directory of given bufnr
local directory = Path:new(Utils.root.get { buf = bufnr })
local directory = Path:new(Utils.root.get({ buf = bufnr }))
---@cast directory Path
---@type Path
local cache_prompt_dir = P.cache_path:joinpath(directory)
if not cache_prompt_dir:exists() then cache_prompt_dir:mkdir { parents = true } end
if not cache_prompt_dir:exists() then cache_prompt_dir:mkdir({ parents = true }) end
local scanner = Scan.scan_dir(directory:absolute(), { depth = 1, add_dirs = true })
for _, entry in ipairs(scanner) do
local file = Path:new(entry)
if entry:find "planning" and N.templates.planning == nil then
if entry:find("planning") and N.templates.planning == nil then
N.templates.planning = file:read()
elseif entry:find "editing" and N.templates.editing == nil then
elseif entry:find("editing") and N.templates.editing == nil then
N.templates.editing = file:read()
elseif entry:find "suggesting" and N.templates.suggesting == nil then
elseif entry:find("suggesting") and N.templates.suggesting == nil then
N.templates.suggesting = file:read()
end
end
Path:new(debug.getinfo(1).source:match("@?(.*/)"):gsub("/lua/avante/path.lua$", "") .. "templates")
:copy { destination = cache_prompt_dir, recursive = true }
:copy({ destination = cache_prompt_dir, recursive = true })
vim.iter(N.templates):filter(function(_, v) return v ~= nil end):each(function(k, v)
local f = cache_prompt_dir:joinpath(H.get_mode_file(k))
@@ -120,11 +120,11 @@ P.prompts = N
P.setup = function()
local history_path = Path:new(Config.history.storage_path)
if not history_path:exists() then history_path:mkdir { parents = true } end
if not history_path:exists() then history_path:mkdir({ parents = true }) end
P.history_path = history_path
local cache_path = Path:new(vim.fn.stdpath "cache" .. "/avante")
if not cache_path:exists() then cache_path:mkdir { parents = true } end
local cache_path = Path:new(vim.fn.stdpath("cache") .. "/avante")
if not cache_path:exists() then cache_path:mkdir({ parents = true }) end
P.cache_path = cache_path
vim.defer_fn(function()
@@ -138,6 +138,6 @@ end
P.available = function() return templates ~= nil end
P.clear = function() P.cache_path:rm { recursive = true } end
P.clear = function() P.cache_path:rm({ recursive = true }) end
return P