- add a ft function to make it better when trying to load a plugin on a ft - add shorthands to make it easier to create one load condition
44 lines
1.2 KiB
Lua
44 lines
1.2 KiB
Lua
--- shorthands for when you only need to define one callback
|
|
local short = {}
|
|
|
|
--- create a usercommand which will trigger the plugin to load
|
|
---@param name string the name of the command
|
|
---@param opts vim.api.keyset.user_command? options
|
|
---@return function callback lazy setup
|
|
function short:cmd(name, opts)
|
|
return function(load)
|
|
load:cmd(name, opts)
|
|
end
|
|
end
|
|
|
|
--- create an auto command which will trigger the plugin to load
|
|
---@param event string the event to trigger on
|
|
---@param opts vim.api.keyset.create_autocmd? options
|
|
---@return function callback lazy setup
|
|
function short:auto(event, opts)
|
|
return function(load)
|
|
load:auto(event, opts)
|
|
end
|
|
end
|
|
|
|
--- create an auto command which will trigger on filetype
|
|
---@param filetype string filetype to register the auto on
|
|
function short:ft(filetype)
|
|
return function(load)
|
|
load:ft(filetype)
|
|
end
|
|
end
|
|
|
|
--- create a keybind which will trigger the plugin to load
|
|
---@param mode string the mode to trigger in
|
|
---@param bind string the binding to use
|
|
---@param opts vim.keymap.set.Opts? options
|
|
---@return function callback lazy setup
|
|
function short:keymap(mode, bind, opts)
|
|
return function(load)
|
|
load:keymap(mode, bind, opts)
|
|
end
|
|
end
|
|
|
|
return short
|