Skip to content
This repository was archived by the owner on Dec 7, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Allow mapping to be created inside plugin setup, but still specified as
a trigger to load the plugin.
  • Loading branch information
Caio Daniel Nunes Santos committed May 16, 2025
commit db3dba4e942069b75012c07faefeea7babb98dc9
19 changes: 12 additions & 7 deletions lua/strive/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -932,21 +932,26 @@ function Plugin:keys(mappings)
if type(mapping) == 'table' then
mode = mapping[1] or 'n'
lhs = mapping[2]
rhs = mapping[3] or function() end
rhs = mapping[3]
opts = mapping[4] or {}
else
mode, lhs = 'n', mapping
rhs = function() end
opts = {}
end

-- Create a keymap that loads the plugin first
vim.keymap.set(mode, lhs, function()
if self:load() and type(rhs) == 'function' then
rhs()
elseif self:load() and type(rhs) == 'string' then
-- If rhs is a string command
vim.cmd(rhs)
if type(rhs) == 'function' then
self:load(nil, rhs)
elseif type(rhs) == 'string' then
self:load(nil, function() vim.cmd(rhs) end)
elseif type(rhs) == 'nil' then
-- If rhs not specified, it should be defined in plugin config
-- In this case, we need to pass a callback
self:load(nil, function()
vim.schedule(function()
vim.fn.feedkeys(lhs)
end) end)
end
end, opts)
end
Expand Down