-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
f78d956
commit e7e6492
Showing
5 changed files
with
191 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |