73 lines
1.7 KiB
Lua
73 lines
1.7 KiB
Lua
-- This file contains shorthands which rely on the loader core functions. They
|
|
-- are intended to ease lazy loading condition definitions to use them you may
|
|
-- do the following:
|
|
--
|
|
-- ```lua
|
|
-- _G.dep_short = require("dep.lazy.loader.short")
|
|
-- ```
|
|
--
|
|
-- Which will allow you to reference it anywhere in your config like so:
|
|
--
|
|
-- ```lua
|
|
-- require("dep") {
|
|
-- { "some/plugin",
|
|
-- lazy = dep_short.cmd("TheCommand")
|
|
-- }
|
|
-- }
|
|
-- ```
|
|
--
|
|
-- Happy vimming o/
|
|
local short = {}
|
|
|
|
--- create a single command
|
|
---@param name string the name of the command
|
|
---@param opts vim.api.keyset.user_command? options
|
|
---@return function callback
|
|
function short.cmd(name, opts)
|
|
return function(load)
|
|
load:cmd(name, opts)
|
|
end
|
|
end
|
|
|
|
--- create a single auto command
|
|
---@param event string the event to trigger on
|
|
---@param opts vim.api.keyset.create_autocmd? options
|
|
---@return function callback
|
|
function short.auto(event, opts)
|
|
return function(load)
|
|
load:auto(event, opts)
|
|
end
|
|
end
|
|
|
|
--- create a single auto command which will trigger on filetype
|
|
---@param filetype string filetype to register the auto on
|
|
---@return function callback
|
|
function short.ft(filetype)
|
|
return function(load)
|
|
load:ft(filetype)
|
|
end
|
|
end
|
|
|
|
--- create a single keybind
|
|
---@param mode string the mode to trigger in
|
|
---@param bind string the binding to use
|
|
---@param opts lazy.Opts? options
|
|
---@return function callback
|
|
function short.keymap(mode, bind, opts)
|
|
return function(load)
|
|
load:keymap(mode, bind, opts)
|
|
end
|
|
end
|
|
|
|
--- create a single plugin load event for when another plugin loads
|
|
---@param plugin string plugin name
|
|
---@param opts table? options
|
|
---@return function callback
|
|
function short.plugin(plugin, opts)
|
|
return function(load)
|
|
load:plugin(plugin, opts)
|
|
end
|
|
end
|
|
|
|
return short
|