mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-12 10:24:37 +02:00
refactor: use actions
This commit is contained in:
parent
3f404079dc
commit
f40a2a1faa
7 changed files with 100 additions and 64 deletions
|
@ -1,8 +1,35 @@
|
|||
---@class lazyvim.util.cmp
|
||||
local M = {}
|
||||
|
||||
---@return string?
|
||||
function M.ai_accept() end
|
||||
---@alias lazyvim.util.cmp.Action fun():boolean?
|
||||
---@type table<string, lazyvim.util.cmp.Action>
|
||||
M.actions = {
|
||||
-- Native Snippets
|
||||
snippet_forward = function()
|
||||
if vim.snippet.active({ direction = 1 }) then
|
||||
vim.schedule(function()
|
||||
vim.snippet.jump(1)
|
||||
end)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
---@param actions string[]
|
||||
---@param fallback? string|fun()
|
||||
function M.map(actions, fallback)
|
||||
return function()
|
||||
for _, name in ipairs(actions) do
|
||||
if M.actions[name] then
|
||||
local ret = M.actions[name]()
|
||||
if ret then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return type(fallback) == "function" and fallback() or fallback
|
||||
end
|
||||
end
|
||||
|
||||
---@alias Placeholder {n:number, text:string}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue