Commit Graph

243 Commits

Author SHA1 Message Date
Nikita Kouevda
28d463f199 mv restore into gitgutter#utility#system 2023-08-31 07:50:14 -07:00
Nikita Kouevda
a5e0740801 Restore v:shell_error in autocmd ShellCmdPost
Fixes #869.
2023-08-30 23:43:30 -07:00
Andy Stewart
68f16eb21f Fix handling of file renames
Both `:file` and `:saveas` rename the current file.

`:file` does not write the newly named file to disk, and keeps the same
buffer.  It fires a single `BufFilePre` / `BufFilePost` pair of
autocommands:

    `BufFilePre`     buffer
    `BufFilePost`    buffer

`:saveas` does write the newly named file to disk, in a new buffer.  It
fires two pairs of `BufFilePre` / `BufFilePost` autocommands:

    `BufFilePre`     original buffer
    `BufFilePre`     new buffer
    `BufFilePost`    original buffer
    `BufFilePost`    new buffer

In both cases the cached path needs to be cleared.

See #860, #551.
Fixes #865.
2023-07-31 13:37:11 +01:00
Andy Stewart
8a95900cf1 Remove redundant comment 2023-06-01 09:25:54 +01:00
Andy Stewart
8d659d3dfc Declare similar autocmds next to each other 2023-06-01 09:25:43 +01:00
Andy Stewart
250112fecf Check before enabling after disabling for autocmds
Fixes #860.
See #551, #801.
2023-06-01 09:21:52 +01:00
Andy Stewart
52d0066823 Ensure older vims process buffer at startup
In this context older vims are those without timer_start() and lambda.

The plugin always used to process the buffer at startup.  Then in #734
an optimisation was introduced to defer processing at startup, to keep
vim's startup fast.  However in this optimisation older vim's
unintentionally lost their startup processing altogether.
2022-08-22 09:42:07 +01:00
Andy Stewart
7808c48c7b Use timer instead of autocmd to defer startup processing
If the user has removed the "gitgutter CursorHold" autocommand, which
is the documented way to turn off automatic refreshing, calling the
autocommand at start up will fail.  Use a timer instead.

This implementation also changes the processing delay to 1ms instead of
'updatetime'.

See #840.
2022-08-22 09:30:47 +01:00
Andy Stewart
d5bae10403 Add GitGutterDiffOrig command
Closes #827.
2022-04-15 14:13:51 +01:00
Andy Stewart
384bf003f6 Allow configuration of floating window appearance
Closes #807.
2022-02-02 09:23:45 +00:00
Andy Stewart
a02369403b Fix autocmd to use <abuf> for effective buffer
See #814, #607.
2022-01-29 15:14:20 +00:00
Andy Stewart
256702dd14 Fix restoration of g:gitgutter_enabled after :vimgrep
Fixes #801.
2021-09-07 15:10:00 +01:00
caojoshua
ca0f292e68 Use 0/1 instead of v:true/v:false for compatibility with older vim
versions.
2021-07-12 11:03:37 +01:00
caojoshua
aad6acea5d When using loclist, only add hunks for current file. 2021-07-12 11:03:37 +01:00
Vincent Cordobes
42ed714fb9 Capitalize warning messages 2021-04-22 12:03:06 +01:00
Andy Stewart
7224d1d8d7 Ensure backward compatibility with 'previewpopup' option 2021-03-18 11:05:56 +00:00
Andy Stewart
f2a825f405 Use floating window for preview instead of popup 2021-03-17 14:30:49 +00:00
Andy Stewart
2a0411c10c Revert GitGutterGetHunkSummary() to show hunks when inactive
In da77e46310 the function changed to be
consistent with GitGutterGetHunks(), i.e. to show "no data" if called in
a buffer for which gitgutter is inactive.

This function is mostly used in status lines.  GitGutter is inactive
when a popup window is open.  The commit mentioned above meant that when
a completion window was open, the hunk summary in the status line
changed to show no data.  It changed back again once the completion
window was closed, but the overall effect was a little distracting.

This commit reverts the change.

Closes #771.
2021-03-15 16:45:26 +00:00
Andy Stewart
b90aad666a Ensure GitGutterGetHunks() always returns a 3 element list
Thanks to @sebastianmarkow for pointing this out.
2021-02-16 18:04:12 +00:00
Andy Stewart
da77e46310 Make consistent with GitGutterGetHunks() 2021-02-16 16:05:41 +00:00
Andy Stewart
f614693b2a Replace custom function with built-in get() function 2020-11-21 11:19:06 +00:00
obcat
987a33355e Show message like "Hunk 4 of 11" after hunk jumping 2020-11-05 16:43:52 +00:00
Andy Stewart
696a6ed389 Ensure that buffer is processed soon after startup
Fixes #738.
2020-10-30 12:27:48 +00:00
Andy Stewart
ea79bc01c2 Skip processing on BufEnter while vim is starting
This is to keep vim's startup as fast as possible.

Closes #734.
2020-09-11 11:44:35 +01:00
Andy Stewart
d9dd9c8b74 Fix missing variable prefix 2020-09-08 09:43:53 +01:00
Andy Stewart
8005f71aab Avoid floating preview window immediately closing itself
Fixes #728.
2020-08-07 12:06:17 +01:00
shinjiro-sugita
1033745403 fix(plugin/gitgutter.vim): Avoid using double-byte characters 2020-07-28 10:01:32 +01:00
Andy Stewart
64018119fb Change default sign for removed above and below
Closes #724.
2020-07-27 15:07:45 +01:00
Andy Stewart
51a03d4ae0 Add option for <Esc> to close non-floating preview window
Closes #718.
2020-06-23 15:18:25 +01:00
Andy Stewart
4802c04f1d Remove obsolescence warning about sign column 2020-05-01 12:03:16 +01:00
Andy Stewart
76d1cf609d Do not set background on existing GitGutter* highlights unless requested
If GitGutter* highlight groups already exist, they were declared
deliberately (either by the colorscheme maintainer or the user).  So do
not adjust them.

However if you would like to make the signs' backgrounds match the sign
column, you can do this:

    let g:gitgutter_set_sign_backgrounds = 1
2020-04-30 19:43:02 +01:00
Andy Stewart
0da302c28a Do not adjust SignColumn highlight
This was introduced in 07d7c9d4 because many colorschemes at the time
had ugly sign columns, and people kept asking how to deal with it.

These days there are many more plugins which use the sign column and
consequently more colorschemes pay attention to the SignColumn highlight
group.

Therefore it no longer makes sense for vim-gitgutter to adjust the
sign column's appearance.

To restore the previous behaviour, add this to your vimrc:

    highlight! link SignColumn LineNr

See #696.
2020-04-30 19:41:09 +01:00
Andy Stewart
67d5dc11d6 Bail early if git cannot be found
There is no point trying to run without git.
2020-04-27 14:12:33 +01:00
Andy Stewart
a194e9da01 When git cannot be found only warn if plugin enabled
This enables the plugin to be loaded on systems without git, without
emitting any warnings.

See #702.
2020-04-27 14:09:56 +01:00
Andy Stewart
ea14301cb4 Default to not limiting number of signs on newer Vims
The limit on the maximum number of signs was introduced when Vim's sign
drawing code was much slower than it is now.

See #681.
2020-04-27 10:09:22 +01:00
Andy Stewart
1c53af9a0d Listen to FugitiveChanged autocmd
Closes #666.
2019-12-03 15:27:08 +00:00
Richard Robbins
d36686e6a5 Add g:gitgutter_use_location_list option 2019-11-22 13:25:40 +02:00
Andy Stewart
7be1f83092 Fix escaping in non-expression map warnings.
Closes #648.
2019-09-05 09:24:01 +01:00
Andy Stewart
0469b8435a Deprecate <Plug>... maps in favour of <Plug>(...) 2019-09-04 08:56:36 +01:00
Andy Stewart
88d396f1b4 Add :GitGutterQuickFix command.
It loads all hunks into the quickfix list.

Closes #617.
2019-08-28 11:59:19 +01:00
Andy Stewart
8bafd08ef4 Support diffs relative to the working tree.
Closes #558.
2019-08-28 09:22:06 +01:00
Andy Stewart
83eb5377be Fix FileChangedShellPost handler on terminal vim.
It seems to be necessary to delay the update by 1 tick.

See #607.
2019-08-28 09:09:15 +01:00
Andy Stewart
7e3b079e6a Fix option setting logic for floating windows. 2019-08-28 09:00:48 +01:00
Andy Stewart
f0f56b9569 Use floating windows for hunk previews on Neovim. 2019-08-27 16:02:51 +01:00
Andy Stewart
cbaa22e38c Use sign functions, groups, and priority, where available.
On Vims that support it, signs are placed in the "gitgutter" group with
a priority set by g:gitgutter_sign_priority.

Closes #544.
Closes #576.
Closes #627.
2019-08-16 16:21:06 +01:00
Andy Stewart
afe94ede1b Do not use a dummy sign to keep the sign column open.
This removes the g:gitgutter_sign_column_always option.

Vim 7.4.2201 introduced the |signcolumn| option to configure when the
signcolumn is visible, building in behaviour which the plugin provided
manually.

Although it would be good to maintain this feature for older Vims, the
complexity added by the code outweighs the benefit of backward
compatibility.
2019-08-16 12:06:28 +01:00
Andy Stewart
e608bff4a3 Update signs after a Fugitive :Gwrite.
See tpope/vim-fugitive#503.
Closes #502.
2019-08-15 11:43:30 +01:00
Andy Stewart
bc1d28db46 Allow staging part of an additions-only hunk.
See #279.
2019-08-12 17:19:05 +01:00
Andy Stewart
fef14f1d49 Ignore non-gitgutter signs by default on Neovim >= 0.4.0
See #627.
2019-08-12 10:03:59 +01:00
Dan Aloni
9bf988bd1d Add g:gitgutter_sign_allow_clobber to control clobbering.
I.e. how gitgutter handles non-gitgutter signs.

See #565, #627.

Co-authored-by: Andy Stewart <boss@airbladesoftware.com>
2019-08-10 07:29:15 +01:00