chore: prefer not to use function assignment (#1381)
This commit is contained in:
@@ -24,12 +24,12 @@ M.did_setup = false
|
||||
|
||||
local H = {}
|
||||
|
||||
H.load_path = function()
|
||||
function H.load_path()
|
||||
local ok, LazyConfig = pcall(require, "lazy.core.config")
|
||||
|
||||
if ok then
|
||||
local name = "avante.nvim"
|
||||
local load_path = function() require("avante_lib").load() end
|
||||
local function load_path() require("avante_lib").load() end
|
||||
|
||||
if LazyConfig.plugins[name] and LazyConfig.plugins[name]._.loaded then
|
||||
vim.schedule(load_path)
|
||||
@@ -54,7 +54,7 @@ H.load_path = function()
|
||||
end
|
||||
end
|
||||
|
||||
H.keymaps = function()
|
||||
function H.keymaps()
|
||||
vim.keymap.set({ "n", "v" }, "<Plug>(AvanteAsk)", function() require("avante.api").ask() end, { noremap = true })
|
||||
vim.keymap.set(
|
||||
{ "n", "v" },
|
||||
@@ -180,17 +180,17 @@ end
|
||||
---@class ApiCaller
|
||||
---@operator call(...): any
|
||||
|
||||
H.api = function(fun)
|
||||
function H.api(fun)
|
||||
return setmetatable({ api = true }, {
|
||||
__call = function(...) return fun(...) end,
|
||||
}) --[[@as ApiCaller]]
|
||||
end
|
||||
|
||||
H.signs = function() vim.fn.sign_define("AvanteInputPromptSign", { text = Config.windows.input.prefix }) end
|
||||
function H.signs() vim.fn.sign_define("AvanteInputPromptSign", { text = Config.windows.input.prefix }) end
|
||||
|
||||
H.augroup = api.nvim_create_augroup("avante_autocmds", { clear = true })
|
||||
|
||||
H.autocmds = function()
|
||||
function H.autocmds()
|
||||
api.nvim_create_autocmd("TabEnter", {
|
||||
group = H.augroup,
|
||||
pattern = "*",
|
||||
@@ -293,7 +293,7 @@ end
|
||||
M.toggle = { api = true }
|
||||
|
||||
---@param opts? AskOptions
|
||||
M.toggle_sidebar = function(opts)
|
||||
function M.toggle_sidebar(opts)
|
||||
opts = opts or {}
|
||||
if opts.ask == nil then opts.ask = true end
|
||||
|
||||
@@ -308,14 +308,14 @@ M.toggle_sidebar = function(opts)
|
||||
return sidebar:toggle(opts)
|
||||
end
|
||||
|
||||
M.is_sidebar_open = function()
|
||||
function M.is_sidebar_open()
|
||||
local sidebar = M.get()
|
||||
if not sidebar then return false end
|
||||
return sidebar:is_open()
|
||||
end
|
||||
|
||||
---@param opts? AskOptions
|
||||
M.open_sidebar = function(opts)
|
||||
function M.open_sidebar(opts)
|
||||
opts = opts or {}
|
||||
if opts.ask == nil then opts.ask = true end
|
||||
local sidebar = M.get()
|
||||
@@ -324,7 +324,7 @@ M.open_sidebar = function(opts)
|
||||
M.current.sidebar:open(opts)
|
||||
end
|
||||
|
||||
M.close_sidebar = function()
|
||||
function M.close_sidebar()
|
||||
local sidebar = M.get()
|
||||
if not sidebar then return end
|
||||
sidebar:close()
|
||||
|
||||
Reference in New Issue
Block a user