feat(git): Add bcommits_range picker (#2398)
* Filter bcommits by selection in visual mode * Split bcommits_range into new picker * Add option to run bcommits_range as operator Starts operator-pending mode and shows commits in the range of lines covered by the next text object or motion * Rename range arguments to "first" and "last" Can't use start/end, since end is an annoying keyword to use in lua and start/stop doesn't fit as well * Move operators functionality to new module * Run bcommits if no range given to bcommits_range * Make bcommits_range default to current line Instead of calling bcommits * Improve documentation of telescope.operators * Add default value for last_operator Default to a no-op callback * Update bcommits_range for detached worktrees See #2597 * Rename range arguments to "from" and "to" * Move shared bcommits picker into single function
This commit is contained in:
23
lua/telescope/operators.lua
Normal file
23
lua/telescope/operators.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local operators = {}
|
||||
|
||||
local last_operator = { callback = function(_) end, opts = {} }
|
||||
|
||||
--- Execute the last saved operator callback and options
|
||||
operators.operator_callback = function()
|
||||
last_operator.callback(last_operator.opts)
|
||||
end
|
||||
|
||||
--- Enters operator-pending mode, then executes callback.
|
||||
--- See `:h map-operator`
|
||||
---
|
||||
---@param callback function: the function to call after exiting operator-pending
|
||||
---@param opts table: options to pass to the callback
|
||||
operators.run_operator = function(callback, opts)
|
||||
last_operator = { callback = callback, opts = opts }
|
||||
vim.o.operatorfunc = "v:lua.require'telescope.operators'.operator_callback"
|
||||
-- feed g@ to enter operator-pending mode
|
||||
-- 'i' required for which-key compatibility, etc.
|
||||
vim.api.nvim_feedkeys("g@", "mi", false)
|
||||
end
|
||||
|
||||
return operators
|
||||
Reference in New Issue
Block a user