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:
Aaron Kollasch
2023-07-22 17:35:52 -04:00
committed by GitHub
parent f78d956901
commit e7e6492a2d
5 changed files with 189 additions and 71 deletions

View File

@@ -1052,6 +1052,36 @@ builtin.git_bcommits({opts}) *telescope.builtin.git_bcommits()*
{"git","log","--pretty=oneline","--abbrev-commit"}
builtin.git_bcommits_range({opts}) *telescope.builtin.git_bcommits_range()*
Lists commits for a range of lines in the current buffer with diff preview
In visual mode, lists commits for the selected lines
With operator mode enabled, lists commits inside the text object/motion
- Default keymaps or your overridden `select_` keys:
- `<cr>`: checks out the currently selected commit
- `<c-v>`: opens a diff in a vertical split
- `<c-x>`: opens a diff in a horizontal split
- `<c-t>`: opens a diff in a new tab
Parameters: ~
{opts} (table) options to pass to the picker
Options: ~
{cwd} (string) specify the path of the repo
{use_git_root} (boolean) if we should use git root as cwd or the cwd
(important for submodule) (default: true)
{current_file} (string) specify the current file that should be used
for bcommits (default: current buffer)
{git_command} (table) command that will be executed. the last
element must be "-L".
{"git","log","--pretty=oneline","--abbrev-commit","--no-patch","-L"}
{from} (number) the first line number in the range
(default: current line)
{to} (number) the last line number in the range
(default: the value of `from`)
{operator} (boolean) select lines in operator-pending mode
(default: false)
builtin.git_branches({opts}) *telescope.builtin.git_branches()*
List branches for current directory, with output from `git log --oneline`
shown in the preview window