Commit Graph

1171 Commits

Author SHA1 Message Date
Tim Pope
c028ea5a44 Add foldtext for hunk headers 2021-04-01 08:57:58 -04:00
Tim Pope
88f50bba60 Press escape to background :Git to preview window
This can one day hopefully be generalized to handle --paginate, but for
now, leave it as undocumented experiment.
2021-03-31 16:06:40 -04:00
Tim Pope
9bd7c26466 Expand <cfile>
This doesn't play well with :Git as it can result in a fugitive:// URL,
but it does make :Gedit <cfile> and :GBrowse <cfile> do what I mean.
2021-03-31 16:05:14 -04:00
Tim Pope
002ed8de2e Make FugitiveChanged event aware of :Git result
If g:fugitive_result is defined during the User FugitiveChanged event,
one can trigger a custom behavior based on the arguments in .args or the
output in .file.

References https://github.com/tpope/vim-fugitive/pull/1015
2021-03-30 13:33:23 -04:00
Tim Pope
a1cb01da5b Provide :Gedit - to open previous :Git output
Also, provide :GBrowse - to open the first URL contained in that output.
2021-03-29 21:20:28 -04:00
Tim Pope
6b39f6c641 Restore X on submodules
References https://github.com/tpope/vim-fugitive/issues/1705
2021-03-29 20:32:11 -04:00
Tim Pope
09cbabe793 Don't trigger FugitiveChanged until :Git finishes output
Since this user event can error or otherwise interrupt us, run it as
late as possible.  Also rearrange a bit so that a user error won't
cascade to "missing :endif".
2021-03-29 19:33:01 -04:00
Tim Pope
258dd16938 Fix undesired line wrap in :Git output
If Vim is 100 columns wide, and we echo a string exactly 100 characters
long, Vim will insert a line break that a terminal wouldn't.  This is
particularly noticeable with progress bars that Git erases with a screen
width's worth of whitespace.  Work around this by decreasing the number
of columns by 1.
2021-03-28 14:42:46 -04:00
Tim Pope
112310c026 Move edit sentinel removal out of resume handler
Enable using this function in cases other than pausing for edit.
2021-03-28 14:42:46 -04:00
Tim Pope
f4acdcc5b4 Eliminate blank line after resuming from GIT_EDITOR
Also add has_key(a:tmp, 'echo') checks to allow for future async
workflows.
2021-03-27 23:08:13 -04:00
Tim Pope
f7321f6d5b Allow close callback to run before leaving job wait loop
Apparently, both job_status() == "dead" and ch_status() == "closed"
isn't enough to guarantee all callbacks have run.  One last sleep seems
to do the trick, but let's also add a sanity check because this can
cause confusing, hard to debug behavior.
2021-03-27 23:08:13 -04:00
Tim Pope
00cb68e627 Echo from wait loop, not job callback
This makes the pager behave a better, allowing the -- More -- prompt to
actually display and not dropping output if the process exits while
there's a backlog.  An additional benefit is if Git for some reason
produces additional output while GIT_EDITOR is running, that output will
be buffered rather than interrupting the user.

The extracted s:RunTick() helper changes the Vim behavior to check the
process status after waiting as well as before.  This brings it in line
with how Neovim's jobwait() appears to work.

The zero argument :echo after the final s:RunEcho() clears up some weird
draw issues with `:Git command|someothercommand`.

References https://github.com/tpope/vim-fugitive/issues/1717
2021-03-27 15:38:29 -04:00
Tim Pope
af1a46edb7 Don't record last job until after completion
This prevents orphaning a :Git commit when calling a second :Git command
while editing the commit message, and is more predictable all around.
2021-03-27 15:38:29 -04:00
Tim Pope
eaee845aba Unify remote resolution
HTTP redirects and SSH host aliases are just different manifestations of
the same indirection, so handle them both in FugitiveRemoteUrl().  Also
make this function idempotent if a URL is passed in, and pass some
sensible options to cURL.
2021-03-26 12:26:27 -04:00
Tim Pope
6860c592ad Capture cwd of :Git command 2021-03-26 12:26:27 -04:00
Tim Pope
a12e88bcc2 Add error message when editing after Vim exit
I don't think it's possible to see this, but we can use this error
delivery system for other purposes.
2021-03-26 12:26:21 -04:00
Tim Pope
0713b84f97 Don't wait silently on :wall with 'confirm' 2021-03-26 12:26:21 -04:00
Tim Pope
93b434949b Don't try to send :Git process CTRL-C when stdin is closed
Curiously, this appears to work anyways in Neovim, but not Vim.
2021-03-25 19:32:50 -04:00
Tim Pope
7de9b5a04b Retool :Git blame colored commits
Use 3 characters of the commit hash rather than 6, limiting the maximum
total declarations to 4,096 rather than 16 million. Avoid color
components lower than 0x20 and higher than 0xdf to help avoid colors
that blend into the background, light or dark.  And for the terminal,
replace the use of CSApprox with a simple usage of the 6x6x6 color cube
found on 256 color terminals.  CSApprox aims to provide accurate
replication of the input colors, whereas our goal is simply to use all
colors in roughly equal amounts.
2021-03-25 11:34:29 -04:00
Tim Pope
b2195e7690 Extract fugitiveblame ftplugin
References https://github.com/tpope/vim-fugitive/issues/1425
2021-03-24 21:17:37 -04:00
Tim Pope
5e5ce843ea Automatically mkdir when editing .git/info/exclude 2021-03-24 19:56:08 -04:00
Tim Pope
a03444404a Capture exit status of :Git 2021-03-24 17:42:16 -04:00
Tim Pope
64a3f99d03 Pass private job state to s:RunWait() 2021-03-24 17:42:16 -04:00
Tim Pope
9103a738c7 Fix :GBrowse with no argument 2021-03-24 17:42:16 -04:00
Tim Pope
156dbcd738 Don't set foldmethod=syntax in historical buffers
This was originally implemented in part to address the marker fold
method triggering on diffs, so try to still solve that.
2021-03-24 14:21:32 -04:00
Tim Pope
133bf406c7 Accept alternate syntax for :GBrowse remote
The @ syntax is kind of weird as you can't use fnameescape() to get
around it.  Add an alternative syntax for programmatic usage.
2021-03-24 14:21:32 -04:00
Tim Pope
d5d436bfa3 Tweak default list of paginated commands
The only functional change here should be the exclusion of the diff-*
plumbing commands.
2021-03-24 14:21:17 -04:00
Tim Pope
53df837ac6 Don't complete directories as subcommands 2021-03-24 14:20:45 -04:00
Tim Pope
0205ae8d45 Handle tabs in commit subject
References https://github.com/tpope/vim-fugitive/pull/1713
2021-03-24 14:20:45 -04:00
Tim Pope
11b824a0ee Forcefully disable colors on paginated :Git output
References https://github.com/tpope/vim-fugitive/discussions/1711
2021-03-24 14:20:45 -04:00
Tim Pope
857496c32f Unify temp state and job state 2021-03-23 13:39:45 -04:00
Tim Pope
9715dbe19e Replace broken check for nvim 0.5.0
Apparently has('nvim-0.5.0') actually means "any nightly release after
0.4.4".  I guess we'll have to settle for 0.5.1?

Closes https://github.com/tpope/vim-fugitive/issues/1709
2021-03-23 13:39:45 -04:00
Tim Pope
58d2b25836 Use git --list-cmds= to complete subcommands
For older Git versions, use the list of subcommands from when
--list-cmds= was first added, and subtract out "worktree" for Git
versions too old to have it.  This one simple conditional gives us
accurate completion for Git versions up to a decade old.

The option is described as "internal/experimental", so make sure the
exit status is successful, and filter out anything that looks like a
warning or deprecation notice.  In case of failure, use the commands
provided by --list-cmds= as of the date of this commit.

Closes https://github.com/tpope/vim-fugitive/pull/1629
2021-03-21 10:13:42 -04:00
Tim Pope
1999aef8cd Retool completion of subcommands
Support configured completion commands and aliases using our cached
config helpers, and support --exec-path and $PATH git-* executables by
globbing once and caching indefinitely.

References https://github.com/tpope/vim-fugitive/pull/1629
2021-03-21 10:13:42 -04:00
Tim Pope
a55d6f39c8 Paginate :Git whatchanged 2021-03-21 10:13:42 -04:00
Tim Pope
4e285c8137 Clean up argument splitting utility functions 2021-03-21 07:08:16 -04:00
Tim Pope
ddea2ecb0f Expand ssh host aliases in remote urls
A common practice for using multiple accounts with a hosting service
such as GitHub is to alias the host in ~/.ssh/config and use an
alternate ssh key to authenticate as the alternate user:

	Host github.com-work
		HostName github.com
		IdentityFile ~/.ssh/id_rsa_work

By swapping in the original host name for the alias in
FugitiveRemoteUrl(), we can enable :GBrowse plugins to correctly
recognize the hosting service's domain name.

If for some reason you need the original URL without modification, pass
a true value as the third parameter:

	let url = FugitiveRemoteUrl('', bufnr(''), 1)

References https://github.com/tpope/vim-rhubarb/issues/60
2021-03-20 05:56:24 -04:00
Tim Pope
10ed587f65 Capture :Git job output to temp file
This is intended to support an upcoming job backed --paginate, but you
can also unofficially use g:_fugitive_last_job.file to get, for example,
the error messages from a failing pre-commit hook.
2021-03-19 23:39:42 -04:00
Tim Pope
04b0b26f84 Fix diff in status buffer
Half the reason I gave up and wholesale reverted in 4875dd34 was because
the entirely unnecessary abbreviation of "submodule" to "sub" was
difficult to search for, and I wanted the whole thing gone.

Closes https://github.com/tpope/vim-fugitive/issues/1707
2021-03-19 23:37:15 -04:00
Tim Pope
4ea84b29eb Default coo to identifier under cursor in temp buffers
I initially intended to do a :Git branch specific version of this, but
`:Git checkout bad-argument --` is mostly harmless, so hack it for now.

Closes https://github.com/tpope/vim-fugitive/issues/1572
2021-03-19 20:29:16 -04:00
Tim Pope
7bee1113e3 Don't automatically enable syntax folding in status buffer
Closes https://github.com/tpope/vim-fugitive/issues/1565

References https://github.com/tpope/vim-fugitive/issues/1317
2021-03-19 20:29:16 -04:00
Tim Pope
4e85dd3424 Revert "Support X for submodules"
I should have looked closer because because I didn't realize "Support X
for submodules" meant "make it do something completely unrelated".

This reverts commit a21ca7e86e.

References https://github.com/tpope/vim-fugitive/issues/1705
2021-03-19 03:13:52 -04:00
Tim Pope
0508885550 Don't clobber alt buffer with :Gread
Why does :read do this???
2021-03-19 02:49:08 -04:00
Tim Pope
99fccd08e2 Make :Gdiffsplit! from common ancestor stage open ours and theirs
References https://github.com/tpope/vim-fugitive/issues/1706
2021-03-19 02:48:56 -04:00
Tim Pope
0858688120 Don't expand # in :GBrowse http://example.com/#anchor 2021-03-19 02:48:56 -04:00
Tim Pope
91089715f4 Update env workarounds for nvim
Commit e85c8dff692c894a614192f6dd8a4c71c1c9fe30 in the neovim repository
appears to have addressed the bugs that prevent us from providing a
custom environment for a job.  This hasn't made it into a stable release
yet, so let's assume it will land in the next minor version.
2021-03-19 02:48:56 -04:00
Tim Pope
563faf95b8 Remove broken deprecated :Git merge calling mergetool
Closes https://github.com/tpope/vim-fugitive/issues/1704
2021-03-18 16:48:10 -04:00
Tim Pope
d7c2e50816 Partition public and private job state 2021-03-18 01:49:08 -04:00
Tim Pope
39d904051d Avoid :normal during status reload
This was clearing the last line of output when attempting to reload
status from a job close callback, so let's use a different method to
change the column.
2021-03-18 01:48:46 -04:00
Tim Pope
e89d22e5da Use unambiguous option keys for subcommand delegation 2021-03-18 01:44:28 -04:00