Commit Graph

466 Commits

Author SHA1 Message Date
Andy Stewart
e512d3a6fc Make the process_hunks() function public.
This is so other plugins, e.g. vim-signature, may use it.

Closes #489.
2018-02-26 08:58:27 +00:00
Andy Stewart
b27ee4d602 Rename variable for clarity. 2018-02-22 16:23:17 +00:00
Andy Stewart
816fc98ff2 Swap order of if/else so it reads better. 2018-02-22 11:09:05 +00:00
Andy Stewart
61a5e0143e Do not warn user when default grep cannot be found.
This restores the behaviour that was accidentally changed in 5bfe5b9.
2018-02-22 11:06:34 +00:00
Andy Stewart
e9aee00190 Switch off diff.mnemonicPrefix in tests.
Follows on c325a8b.
2018-02-22 11:04:10 +00:00
Andy Stewart
c3bad229db Use built-in uniq() when available. 2018-02-22 10:32:21 +00:00
Andy Stewart
87097d8923 Fix bugs in s:uniq().
I can't believe I got this wrong.

Fixes #485.
2018-02-22 10:17:28 +00:00
Daniel Hahler
c325a8b6d3 s:fix_file_references: handle diff.mnemonicPrefix
An alternative would be to run `git` with no user config always, i.e.
setting `GIT_CONFIG_NOSYSTEM` and `HOME=/dev/null` (different for
Windows then) in its environment.  Maybe there's an easier way / single
option for this..
2018-02-22 09:49:31 +00:00
Andy Stewart
9325986457 Remove deprecated command GitGutterRevertHunk. 2018-02-21 12:23:02 +00:00
Andy Stewart
8f6bbc9855 Extract uniq function. 2018-02-21 12:06:42 +00:00
Daniel Hahler
d78184e646 Use processed-dict, uniq() might not be available 2018-02-21 11:54:15 +00:00
Daniel Hahler
6c2def1075 Use sort+uniq with tabpagebuflist to remove duplicates 2018-02-21 11:54:15 +00:00
Daniel Hahler
4931dd1a82 Conditionally define s:vimdiff
This optimizes it a bit since the `exists()` is not called always.
2018-02-21 11:46:36 +00:00
Daniel Hahler
18f6d0ffe1 gitgutter#utility#setbufvar: skip unnecessary setbufvar
An existing dict gets returned by reference, so changing it does not
need a call to `setbufvar` afterwards.
2018-02-21 11:39:42 +00:00
Daniel Hahler
10254400c3 doc: fix example for g:gitgutter_diff_args 2018-02-21 11:35:53 +00:00
Andy Stewart
798abe53b3 Extract helper for triggering gitgutter. 2018-02-21 11:33:44 +00:00
Andy Stewart
35c92dbd50 Add test for user autocmd. 2018-02-21 11:31:48 +00:00
Daniel Hahler
a046b5ace1 Improve GitGutter User autocommand: context/unsilent
This provides `g:gitgutter_hook_context` during the hook's execution and
removes the `:silent`, but uses `exists()` instead.

The bufnr might be necessary to know in the User autocommand, e.g. to
clear some cache.
Not using`:silent` is good practice in general to not hide (wanted)
output and errors etc.
2018-02-21 11:23:02 +00:00
Andy Stewart
4692457ae2 Document how to disable realtime updates. 2018-02-19 14:31:59 +00:00
Andy Stewart
38a7789be9 Finish when pre-requisites not fulfilled. 2018-02-19 14:04:49 +00:00
Andy Stewart
d86ac1353f Avoid race conditions when processing multiple buffers asynchronously.
Fixes #472.
2018-02-19 12:56:22 +00:00
Andy Stewart
457f35e444 Ensure a re-activated buffer runs a diff.
See #303.
2018-02-19 10:59:39 +00:00
Andy Stewart
ef94b195ab Add tests for text objects. 2018-02-19 10:51:21 +00:00
Patryk Czachurski
314e64673b Fixed call to current_hunk in hunk text object 2018-02-19 10:14:34 +00:00
Andy Stewart
790ffa476a Simplify reading of buffer variable. 2018-02-17 09:19:28 +00:00
Andy Stewart
16568f4815 Add win32unix to OS check. 2018-02-16 15:40:02 +00:00
Andy Stewart
13361da09e Only use overbar sign when UI supports it.
Thanks @h3xx.

Closes #471.
2018-02-16 13:06:23 +00:00
Andy Stewart
7e3f41cdec Update docs. 2018-02-16 12:54:04 +00:00
Andy Stewart
ec6e1e484b Update docs with changed grep option.
Thanks @ErichDonGubler.

Closes #467.
2018-02-16 10:52:24 +00:00
Andy Stewart
213bd34bdf Mention hunk text object in introduction. 2018-02-15 17:17:23 +00:00
Andy Stewart
d586e4398e Add note about updatetime to troubleshooting section. 2018-02-15 17:16:59 +00:00
Andy Stewart
72b789ea8f Clarify that unstaging staged hunks is out of scope. 2018-02-15 17:16:16 +00:00
Andy Stewart
44373fd1dc Add issue template. 2018-02-15 14:55:37 +00:00
Andy Stewart
0c94dd0235 Handle UNC paths.
Fixes #328.
2018-02-15 14:52:10 +00:00
Andy Stewart
85f6e136bd Turn off gitgutter for any buffer with a vimdiff window.
Closes #303.
2018-02-14 11:10:59 +00:00
Andy Stewart
4e911819be Write buffer using writefile() instead of :write.
This is to avoid side effects caused by switching to the buffer to be
written and back again.

It also means that the plugin can process any buffer without having to
make it the current buffer.

Using the lower level writefile() function means we have to deal with
line endings.  It might also mean we have to deal with (file) encodings
but I hope not...

See #463, #466.
2018-02-13 10:22:36 +00:00
Andy Stewart
850e947509 Add backward compatibility for lambda.
Lambdas were introduced in Vim 7.4.2044.
2018-02-13 10:02:54 +00:00
Andy Stewart
933af37935 Replace v:t_string with backward-compatible equivalent.
v:t_string was introduced in Vim 7.4.2071.

Closes #464.
2018-02-13 09:37:45 +00:00
Andy Stewart
9ed38f00ee Merge branch 'master' of ssh://github.com/airblade/vim-gitgutter
* 'master' of ssh://github.com/airblade/vim-gitgutter:
  Pass bufnr into warn_once function.
2018-02-13 09:33:17 +00:00
Andy Stewart
7f14cd142c Pass bufnr into warn_once function.
Fixes #465.
2018-02-13 09:32:38 +00:00
Andy Stewart
8f2e2a226a Pass bufnr into warn_once function. 2018-02-13 09:32:22 +00:00
Andy Stewart
8a7d00590b Restore support for vim-repeat in hunk ops. 2018-02-12 16:42:20 +00:00
Andy Stewart
2d32a2965a Improve hunk previewing.
- Treat &previewheight as a maximum height.
- Make preview window shrink to fit the hunk.
- Resize preview window each time.
- Make preview window readonly and nomodifiable.

Based on code by @somini.  Thanks!

See #451.
2018-02-12 16:32:43 +00:00
Andy Stewart
a8af1853bd Remove long-standing deprecation warning. 2018-02-12 16:21:10 +00:00
Andy Stewart
d137753182 Handle &write option being off (e.g. vim -m FILE).
See #407.
2018-02-12 16:19:01 +00:00
Andy Stewart
8da5b64868 Avoid autocmds when switching buffers to write temp file. 2018-02-12 16:02:03 +00:00
Andy Stewart
3a052e4777 More idiomatic execute. 2018-02-12 15:52:34 +00:00
Andy Stewart
1452900ffd Check buffer is active before init. 2018-02-12 15:34:49 +00:00
Andy Stewart
5bfe5b9209 Big refactor.
- Hunk stage/undo/preview no longer saves the buffer.
- Hunk undo no longer makes locations go out of sync.
- Grep can be opted out of (grep output with ansi escapes is number one cause
  of issues).
- Replaced g:gitgutter_grep_command with g:gitgutter_grep.
- Always runs git-diff the same way instead of in two possible ways.
- Separated detection of git tracking from diffing.
- Simplified path handling.
- Removed support for xolox shell: Windows taskbar does not flash with async
  jobs.
- Removed g:gitgutter_{eager,realtime}.
- Simplified implementation generally.
2018-02-12 14:25:11 +00:00
Andy Stewart
932ffaca09 Ensure we write correct buffer.
Fixes #454.
2018-01-29 15:30:25 +00:00