Commit Graph

138 Commits

Author SHA1 Message Date
Lewis Russell
fa1e8c589a feat(signs): different add signs for untracked files
Resolves #569
2022-11-07 10:40:47 +00:00
Lewis Russell
666edc7ba4 fix(test): set merge.conflictstyle 2022-10-07 14:20:57 +01:00
Lewis Russell
f623543458 chore(ci)!: drop support for v0.6.x 2022-10-07 14:02:11 +01:00
Lewis Russell
a0cd6ccd73 chore!: remove deprecated fields 2022-09-13 09:28:42 +01:00
Lewis Russell
50e32c6309 feat: support for detached working trees
Added config.worktrees.

Array of tables with the keys 'gitdir' and 'toplevel'.

If attaching normally fails, then each entry in the table is attempted.

Example:

  worktrees = {
    {
      toplevel = vim.env.HOME,
      gitdir = vim.env.HOME .. '/projects/dotfiles/.git'
    }
  }

Resolves #397
2022-08-10 11:15:42 +01:00
Lewis Russell
44372ff5dc fix: improve fix for #521 2022-05-24 11:45:33 +01:00
Lewis Russell
13f811e8eb fix: don't set default for GitSignsDeleteLn
Setting GitSignsDeleteLn to anything by default doesn't make much sense
since it ends up highlighting lines not related to the hunk. This is
especially confusing when show_deleted is enabled.

+ Fix incorrect docs.

Fixes #565
2022-05-22 10:15:25 +01:00
Lewis Russell
b290aed76f refactor: move unit tests 2022-05-02 14:42:15 +01:00
Lewis Russell
329ffe6820 feat(command): implement argparser 2022-05-02 14:16:18 +01:00
Lewis Russell
61c8398b0d test: improve unit tests 2022-05-02 12:23:51 +01:00
Lewis Russell
9b3899a610 refactor(signs): simplify interface 2022-04-22 12:32:18 +01:00
Lewis Russell
498abfa13d refactor: OOP signs 2022-04-19 16:25:32 +01:00
Lewis Russell
d0b42c0fc7 fix(git): add --literal-pathspecs 2022-04-15 16:45:16 +01:00
Lewis Russell
420db8ddb9 feat(blame): support format strings
- config.current_line_blame_formatter can now be specified as a format
string.

- changed default of `config.current_line_blame_formatter` to
  '<author>, <author_time:%R> - <summary>' which is equivalent to the
  previous function default.

- deprecated config.current_line_blame_formatter_opts

Resolves #291
2022-02-13 15:23:41 +00:00
lschwahn
2fa3716bc4 fix: gitsigns in fugitive buffer not visible 2022-01-29 18:13:36 +00:00
Lewis Russell
b4548e4c60 refactor(highlights)!: rework highlights
- Added GitSigns*Inline and GitSigns*LnInline to be used with word diff
    - GitSigns*LnInline is used for word diff with config.word_diff
    - GitSigns*Inline is used for word diff in hunk previews

- Added GitSigns*VirtLn and GitSigns*VirtLnInline to be used with
  `config.show_deleted`.

- Define GitSigns highlights conditionally as opposed to only defining
  them if certain features are enabled.
2022-01-26 17:33:24 +00:00
Lewis Russell
d19029adca fix(): support filepaths with unicode characters
Fixes #447
2022-01-20 17:20:43 +00:00
Sergey Kuznetsov
7aad5257fa Hope the last tests fix 2022-01-11 16:16:47 +00:00
Sergey Kuznetsov
ee5e46450e Another try to fix tests 2022-01-11 16:16:47 +00:00
Sergey Kuznetsov
cf8e4df8d8 Fix tests 2022-01-11 16:16:47 +00:00
Fabian Viöl
9084e084f8 fix(blame_line): Do not omit carriage return
When blaming a line on a file, which as the "dos" fileformat
which is also checked in as a "dos" format including the
carriage returns, gitsigns.nvim currently reports
"Not yet commited" caused by an unsucessfull blame call
to git.

This commit fixes that behavior by appending the carriage
return lines again
2021-12-13 12:56:01 +00:00
Lewis Russell
caf51af051 fix(windows): Fix CRLF handling
Fixes #410
2021-12-08 22:15:22 +00:00
Lewis Russell
f362e54e11 feat(actions): true partial hunk staging
Resolves #338
2021-12-04 18:38:52 +00:00
Lewis Russell
805b12a9b7 chore(refactor): refactor Hunk object
So added and removed lines are kept in separate tables
2021-09-27 13:11:12 +01:00
Lewis Russell
c81aa3b690 feat(deprecated): only warn hard deprecations
Add deprecations to doc.

When fields are now initially deprecated, no warning messages will be
displayed. However if a deprecated field is marked with hard, then a
warning will be issued.

At the beginning of each release cycle, all deprecated fields will be
marked as hard and fields that were already marked as hard will be
removed.
2021-09-27 12:09:47 +01:00
Lewis Russell
489fe088c4 fix(watcher): watch gitdir instead if index
Some git command likes `git checkout -b` do no update .git/index.
Instead watch the git dir itself to capture all git operations.

Renamed config.watch_index -> config.watch_gitdir

Fixes #377
2021-09-24 16:30:10 +01:00
Lewis Russell
aa2522a6f3 fix(blame_line): don't error in fresh repo 2021-09-11 14:15:46 +01:00
Lewis Russell
34deec2813 Add config.diff_opts and deprecate fields
- DEPRECATED diff_algorithm
    replaced with diff_opts.algorithm

- DEPRECATED use_internal_diff
    replaced with diff_opts.internal

- ADDED diff_opts.indent_heuristic
2021-09-09 13:58:07 +01:00
Lewis Russell
3cd0656e14 handle deprecated fields more generically 2021-09-09 12:34:09 +01:00
Lewis Russell
7e5a748f34 feat: add g:gitsigns_head
Head value based on cwd

Resolves #344
2021-09-07 16:31:49 +01:00
Lewis Russell
5655cfa4c0 fix(update): issue speculative signs persisting
Speculative signs are added immediately whereas updates are debounced
and throttled for each buffer. If we perform two quick updates which
result in a sign begin added then removed, we need to make sure
speculative signs don't incorrectly persist. Example:

  -> buffer change
     - speculative signs (#1)
     - update (#1)
  -> undo (quickly after buffer change)
     - speculative signs (#2)
     - update (#2)

Update #1 is dropped due to the debounce which results in update #2 not
updating signs due to the hunks not changing. Since signs are never
updated, the speculative signs #1 and #2 will persist.

To get around this, we just need to invalidate the hunks to force a sign
refresh.
2021-08-28 12:23:01 +01:00
Lewis Russell
083dc2f485 Add short SHA when rebasing + test 2021-08-09 21:58:59 +01:00
Lewis Russell
3a477a0356 Remove config.use_decoration_api
The decoration provider is now always used.
2021-08-05 15:33:31 +01:00
Lewis Russell
fecff8b866 Tidy up tests 2021-08-03 22:48:48 +01:00
Lewis Russell
605166b6f6 Add get_hunks()
Resolves #242
2021-08-03 18:44:54 +01:00
Lewis Russell
fc170b4ed2 Don't re-apply signs if hunk heads don't change
Resolves #273
2021-08-03 11:08:22 +01:00
Lewis Russell
a50bf388be test: Make all tests run with ext_messages 2021-08-02 11:37:52 +01:00
Lewis Russell
dfc49f8be2 debug: Add trigger info to attach() 2021-08-02 11:30:00 +01:00
Lewis Russell
fe084521ac Disable during vimgrep
Fixes #284
2021-08-02 11:10:32 +01:00
Lewis Russell
90e71f866b Rework status vars
- Add root dir and git dir to b:gitsigns_status_dict (resolves #259)
2021-07-16 15:45:35 +01:00
Lewis Russell
ee454e1846 Improve highlight derivation
- Simplify code
- Search for more known highlight groups, e.g:
    - GitGutterAdd
    - SignifySignAdd
    - DiffAddedGutter
    - diffAdded
    - DiffAdd'
2021-06-26 14:22:13 +01:00
Lewis Russell
4ee167ded8 feat: Follow files when they move in the index 2021-06-25 17:00:15 +01:00
Lewis Russell
a272a8df25 test: Avoid using screen:expect and count signs instead 2021-06-23 16:57:42 +01:00
Lewis Russell
d22de18f9d Rework testsuite
- Make tests more asyn friendly and remove most of the magic sleeps
- Break up into multiple files
- Bypass cmake
2021-06-23 11:41:48 +01:00
Lewis Russell
3b303ecba3 Update after change_base 2021-06-19 16:30:56 +01:00
Lewis Russell
912df11b46 feat: Add config.on_attach()
- Callback to set keymaps (instead of config.keymaps) and to control
  whether to attach to a buffer.
- Documented how extended table configuation fields work.
- Removed non-buffer mappings and `buffer=true` from the default.

Resolves #155
2021-05-30 16:35:14 +01:00
Lewis Russell
6f9ffb94b4 Refactor gitsigns.tl
- Break into separate files
- Should slightly improve startup time.
- Removed update() from public API
2021-05-29 11:23:11 +01:00
Lewis Russell
c00f5f26fd Added diffthis()
Analogous to fugitives :Gvdiffsplit, see :help gitsigns.diffthis()

Resolves #14
2021-05-27 14:34:44 +01:00
Lewis Russell
80cb1dc5ff Detect when file is in a custom git dir
Fixes #193
2021-05-17 11:42:51 +01:00
Lewis Russell
dc0f6d895b Add config.attach_to_untracked
Resolves #68
2021-04-24 16:59:51 +01:00
Lewis Russell
d30167b9c5 Don't place signs if all sign attrs are disabled
Fixes #163
2021-04-24 16:35:36 +01:00
Lewis Russell
adcc3cd927 Show correct signs on fugitive revision buffers
Fixes #143
2021-04-14 13:34:30 +01:00
Lewis Russell
b5222fa439 Refactor git commands to be more OOP (take 2) 2021-04-10 15:05:29 +01:00
Lewis Russell
f11dc80ec4 Revert "Refactor git commands to be more OOP"
This reverts commit 718d61b712240afe873e795b2c6cca2590eef5d8.
2021-04-10 09:34:31 +01:00
Lewis Russell
dbd4c8a87d Refactor git commands to be more OOP 2021-04-10 00:17:19 +01:00
Tomáš Kallup
618601d2dc Implemented stage_buffer and reset_buffer_index
This allow users to run `lua require"gitsigns".stage_buffer()` to stage
all changes in a buffer and `lua require"gitsigns".reset_buffer_index()` to
unstage all changes in a buffer.

Added `ensure_file_in_index` to make sure files are tracked before
staging hunks.
Added `clear_status` to status, to clear only modifications (added,
changed, removed)

Added tests for `stage_buffer` and `reset_buffer_index`

Closes: #127
2021-04-06 10:51:27 +01:00
Lewis Russell
36184e5a58 Fix: Don't error on untracked files with blame
Fixes #123
2021-04-04 21:50:02 +01:00
Lewis Russell
654e16b6ff Feature: Add blame info as virtual text
- Enable with config.current_line_blame.
- Customise formatting with config.current_line_blame_formatter.
2021-04-01 12:34:48 +01:00
Lewis Russell
eb3b172920 Tweak debug message format 2021-03-29 18:30:26 +01:00
Lewis Russell
37dda705e5 Use nvim_echo for debug_messages 2021-03-29 18:30:26 +01:00
Lewis Russell
3258ded4f5 Reworks to the testsuite 2021-03-29 16:40:55 +01:00
Lewis Russell
e00bf6d095 Stop killing the intro
Fixes #111
2021-03-29 11:28:11 +01:00
Lewis Russell
ec979dc5c5 Attach to all buffers on setup 2021-03-28 18:06:48 +01:00
Denys Pavlov
25cf71188a Fix changing colorschemes breaking color highlight
- Update highlights when the colorscheme is changed
- Refactor existing highlight detection into a function
- Add test to prevent regression

Fixes #105
2021-03-26 15:55:21 +00:00
Lewis Russell
716b4d4bb7 Handle files with spaces 2021-03-17 14:03:03 +00:00
Lewis Russell
2f0d60f0c7 Enable internal diff and decoration provider by default
- Expose 'use_internal_diff' in the config and default to to true if
  luajit is present.

- Change 'use_decoration_api' default to true

- Reduce default for 'update_debounce' from 200ms to 100ms.
2021-03-14 20:43:03 +00:00
Lewis Russell
b3247537f6 Allow staging hunks in files with conflicts 2021-03-13 21:46:24 +00:00
Lewis Russell
ab16e46397 Derive default highlights if they aren't defined 2021-03-13 20:08:24 +00:00
Lewis Russell
ed60dad2e4 Run testsuite on advanced config 2021-03-12 22:26:16 +00:00
Lewis Russell
36a8ff49a6 Rework testsuite
Each test now initialises it's own gitdir and prepopulates it.
This should make it easier to write tests with more obscure git repo
states.
2021-03-11 21:11:37 +00:00
Lewis Russell
b9c485e5b5 Emit debug messages to an internal list instead 2021-03-08 22:38:41 +00:00
Lewis Russell
dedda8cbb5 Use temp files instead of uv pipes
For some reason, using temp files is much quicker than UV pipes.
2021-03-07 23:53:49 +00:00
Lewis Russell
bf7c8f2077 Improve how the staged file is created 2021-03-04 23:01:07 +00:00
Lewis Russell
45504ac201 Add config.update_debounce
- Set default to 200ms
- Don't user 'updatetime' as nvim's default of 4s is too long.
2021-03-04 21:02:54 +00:00
Lewis Russell
81bb6d50bb Clear signs and buffer vars on detach
for #56
2021-02-14 16:42:44 +00:00
Lewis Russell
b8d2fcb2b5 Show better signs for files with conflicts
When file has merge conflicts, during a merge or a rebase, diff against
the common ancestor (stage number 1).
2021-02-12 18:58:49 +00:00
Lewis Russell
25d5b843bd Fix testcase 2021-02-02 20:16:51 +00:00
Lewis Russell
26f9fc5aa8 Modify how staged text files are handled
Resolves #47
2021-01-31 15:18:34 +00:00
Lewis Russell
895c2284c8 Refactor testsuite 2021-01-04 15:40:34 +00:00
Lewis Russell
e015b43a4f Fix #41 again 2021-01-04 00:16:18 +00:00
Lewis Russell
b4d800cbd5 Fix #41 2021-01-03 23:47:06 +00:00
Lewis Russell
30496762b7 Better handling of new files
Resolves #39
2021-01-02 13:17:42 +00:00
Lewis Russell
1c3ed1bea4 Attempt to fix CI 2020-12-13 18:13:39 +00:00
Lewis Russell
ce627d53e4 Add line number highlights to signs
Resolves #8
2020-12-13 17:47:58 +00:00
Lewis Russell
75eaa20067 Add test for #23 2020-12-05 00:44:03 +00:00
Lewis Russell
284548d934 Fix #24 2020-12-02 23:05:43 +00:00
Lewis Russell
67c0609945 Fix indeterminism in test 2020-12-02 22:50:08 +00:00
Lewis Russell
d971e3333c Add testing framework and tests
Resolves #16
2020-11-23 22:46:07 +00:00