-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathgitsigns.txt
1157 lines (921 loc) · 46.9 KB
/
gitsigns.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*gitsigns.txt* Gitsigns
*gitsigns.nvim*
Author: Lewis Russell <lewis6991@gmail.com>
Version: 0.7-dev
Homepage: <https://github.com/lewis6991/gitsigns.nvim>
License: MIT license
==============================================================================
INTRODUCTION *gitsigns*
Gitsigns is a plugin for Neovim that provides integration with Git via a
feature set which includes (but not limited to):
• Provides signs in the |signcolumn| to show changed/added/removed lines.
• Mappings to operate on hunks to stage, undo or reset against Git's index.
Gitsigns is implemented entirely in Lua which is built into Neovim and
requires no external dependencies other than git. This is unlike other plugins
that require python, node, etc, which need to communicate with Neovim using
|RPC|. By default, Gitsigns also uses Neovim's built-in diff library
(`vim.diff`) unlike other similar plugins that need to run `git-diff` as an
external process which is less efficient, has tighter bottlenecks and requires
file IO.
==============================================================================
USAGE *gitsigns-usage*
For basic setup with all batteries included:
>lua
require('gitsigns').setup()
<
Configuration can be passed to the setup function. Here is an example with most
of the default settings:
>
require('gitsigns').setup {
signs = {
add = { text = '│' },
change = { text = '│' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
untracked = { text = '┆' },
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
interval = 1000,
follow_files = true
},
attach_to_untracked = true,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
},
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
},
yadm = {
enable = false
},
}
<
==============================================================================
MAPPINGS *gitsigns-mappings*
Custom mappings can be defined in the `on_attach` callback in the config table
passed to |gitsigns-setup()|. See |gitsigns-config-on_attach|.
Most actions can be repeated with `.` if you have |vim-repeat| installed.
==============================================================================
FUNCTIONS *gitsigns-functions*
Note functions with the {async} attribute are run asynchronously and are
non-blocking (return immediately).
setup({cfg}) *gitsigns.setup()*
Setup and start Gitsigns.
Attributes: ~
{async}
Parameters: ~
{cfg} Table object containing configuration for
Gitsigns. See |gitsigns-usage| for more details.
attach({bufnr}) *gitsigns.attach()*
Attach Gitsigns to the buffer.
Attributes: ~
{async}
Parameters: ~
{bufnr} (number): Buffer number
detach({bufnr}) *gitsigns.detach()*
Detach Gitsigns from the buffer {bufnr}. If {bufnr} is not
provided then the current buffer is used.
Parameters: ~
{bufnr} (number): Buffer number
detach_all() *gitsigns.detach_all()*
Detach Gitsigns from all buffers it is attached to.
refresh() *gitsigns.refresh()*
Refresh all buffers.
Attributes: ~
{async}
get_actions() *gitsigns.get_actions()*
Get all the available line specific actions for the current
buffer at the cursor position.
Return: ~
Dictionary of action name to function which when called
performs action.
setloclist({nr}, {target}) *gitsigns.setloclist()*
Populate the location list with hunks. Automatically opens the
location list window.
Alias for: `setqflist({target}, { use_location_list = true, nr = {nr} }`
Attributes: ~
{async}
Parameters: ~
{nr} (integer): Window number or the |window-ID|.
`0` for the current window (default).
{target} (integer or string): See |gitsigns.setqflist()|.
setqflist({target}, {opts}) *gitsigns.setqflist()*
Populate the quickfix list with hunks. Automatically opens the
quickfix window.
Attributes: ~
{async}
Parameters: ~
{target} (integer or string):
Specifies which files hunks are collected from.
Possible values.
• [integer]: The buffer with the matching buffer
number. `0` for current buffer (default).
• `"attached"`: All attached buffers.
• `"all"`: All modified files for each git
directory of all attached buffers in addition
to the current working directory.
{opts} (table|nil):
Additional options:
• {use_location_list}: (boolean)
Populate the location list instead of the
quickfix list. Default to `false`.
• {nr}: (integer)
Window number or ID when using location list.
Expand folds when navigating to a hunk which is
inside a fold. Defaults to `0`.
• {open}: (boolean)
Open the quickfix/location list viewer.
Defaults to `true`.
show({revision}) *gitsigns.show()*
Show revision {base} of the current file, if it is given, or
with the currently set base (index by default).
If {base} is the index, then the opened buffer is editable and
any written changes will update the index accordingly.
Examples: >
" View the index version of the file
:Gitsigns show
" View revision of file in the last commit
:Gitsigns show ~1
<
For a more complete list of ways to specify bases, see
|gitsigns-revision|.
Attributes: ~
{async}
diffthis({base}, {opts}) *gitsigns.diffthis()*
Perform a |vimdiff| on the given file with {base} if it is
given, or with the currently set base (index by default).
If {base} is the index, then the opened buffer is editable and
any written changes will update the index accordingly.
Parameters: ~
{base} (string|nil): Revision to diff against. Defaults
to index.
{opts} (table|nil):
Additional options:
• {vertical}: {boolean}. Split window vertically. Defaults to
config.diff_opts.vertical. If running via command line, then
this is taken from the command modifiers.
• {split}: {string}. One of: 'aboveleft', 'belowright',
'botright', 'rightbelow', 'leftabove', 'topleft'. Defaults to
'aboveleft'. If running via command line, then this is taken
from the command modifiers.
Examples: >
" Diff against the index
:Gitsigns diffthis
" Diff against the last commit
:Gitsigns diffthis ~1
<
For a more complete list of ways to specify bases, see
|gitsigns-revision|.
Attributes: ~
{async}
reset_base({global}) *gitsigns.reset_base()*
Reset the base revision to diff against back to the
index.
Alias for `change_base(nil, {global})` .
change_base({base}, {global}) *gitsigns.change_base()*
Change the base revision to diff against. If {base} is not
given, then the original base is used. If {global} is given
and true, then change the base revision of all buffers,
including any new buffers.
Attributes: ~
{async}
Parameters:~
{base} string|nil The object/revision to diff against.
{global} boolean|nil Change the base of all buffers.
Examples: >
" Change base to 1 commit behind head
:lua require('gitsigns').change_base('HEAD~1')
" Also works using the Gitsigns command
:Gitsigns change_base HEAD~1
" Other variations
:Gitsigns change_base ~1
:Gitsigns change_base ~
:Gitsigns change_base ^
" Commits work too
:Gitsigns change_base 92eb3dd
" Revert to original base
:Gitsigns change_base
<
For a more complete list of ways to specify bases, see
|gitsigns-revision|.
blame_line({opts}) *gitsigns.blame_line()*
Run git blame on the current line and show the results in a
floating window. If already open, calling this will cause the
window to get focus.
Parameters: ~
{opts} (table|nil):
Additional options:
• {full}: (boolean)
Display full commit message with hunk.
• {ignore_whitespace}: (boolean)
Ignore whitespace when running blame.
Attributes: ~
{async}
get_hunks({bufnr}) *gitsigns.get_hunks()*
Get hunk array for specified buffer.
Parameters: ~
{bufnr} integer: Buffer number, if not provided (or 0)
will use current buffer.
Return: ~
Array of hunk objects. Each hunk object has keys:
• `"type"`: String with possible values: "add", "change",
"delete"
• `"head"`: Header that appears in the unified diff
output.
• `"lines"`: Line contents of the hunks prefixed with
either `"-"` or `"+"`.
• `"removed"`: Sub-table with fields:
• `"start"`: Line number (1-based)
• `"count"`: Line count
• `"added"`: Sub-table with fields:
• `"start"`: Line number (1-based)
• `"count"`: Line count
select_hunk() *gitsigns.select_hunk()*
Select the hunk under the cursor.
preview_hunk_inline() *gitsigns.preview_hunk_inline()*
Preview the hunk at the cursor position inline in the buffer.
preview_hunk() *gitsigns.preview_hunk()*
Preview the hunk at the cursor position in a floating
window. If the preview is already open, calling this
will cause the window to get focus.
prev_hunk({opts}) *gitsigns.prev_hunk()*
Jump to the previous hunk in the current buffer. If a hunk preview
(popup or inline) was previously opened, it will be re-opened
at the previous hunk.
Parameters: ~
See |gitsigns.next_hunk()|.
next_hunk({opts}) *gitsigns.next_hunk()*
Jump to the next hunk in the current buffer. If a hunk preview
(popup or inline) was previously opened, it will be re-opened
at the next hunk.
Parameters: ~
{opts} table|nil Configuration table. Keys:
• {wrap}: (boolean)
Whether to loop around file or not. Defaults
to the value 'wrapscan'
• {navigation_message}: (boolean)
Whether to show navigation messages or not.
Looks at 'shortmess' for default behaviour.
• {foldopen}: (boolean)
Expand folds when navigating to a hunk which is
inside a fold. Defaults to `true` if 'foldopen'
contains `search`.
• {preview}: (boolean)
Automatically open preview_hunk() upon navigating
to a hunk.
• {greedy}: (boolean)
Only navigate between non-contiguous hunks. Only useful if
'diff_opts' contains `linematch`. Defaults to `true`.
reset_buffer_index() *gitsigns.reset_buffer_index()*
Unstage all hunks for current buffer in the index. Note:
Unlike |gitsigns.undo_stage_hunk()| this doesn't simply undo
stages, this runs an `git reset` on current buffers file.
Attributes: ~
{async}
stage_buffer() *gitsigns.stage_buffer()*
Stage all hunks in current buffer.
Attributes: ~
{async}
undo_stage_hunk() *gitsigns.undo_stage_hunk()*
Undo the last call of stage_hunk().
Note: only the calls to stage_hunk() performed in the current
session can be undone.
Attributes: ~
{async}
reset_buffer() *gitsigns.reset_buffer()*
Reset the lines of all hunks in the buffer.
reset_hunk({range}, {opts}) *gitsigns.reset_hunk()*
Reset the lines of the hunk at the cursor position, or all
lines in the given range. If {range} is provided, all lines in
the given range are reset. This supports partial-hunks,
meaning if a range only includes a portion of a particular
hunk, only the lines within the range will be reset.
Parameters:~
{range} table|nil List-like table of two integers making
up the line range from which you want to reset the hunks.
If running via command line, then this is taken from the
command modifiers.
{opts} table|nil Additional options:
• {greedy}: (boolean)
Stage all contiguous hunks. Only useful if 'diff_opts'
contains `linematch`. Defaults to `true`.
stage_hunk({range}, {opts}) *gitsigns.stage_hunk()*
Stage the hunk at the cursor position, or all lines in the
given range. If {range} is provided, all lines in the given
range are staged. This supports partial-hunks, meaning if a
range only includes a portion of a particular hunk, only the
lines within the range will be staged.
Attributes: ~
{async}
Parameters:~
{range} table|nil List-like table of two integers making
up the line range from which you want to stage the hunks.
If running via command line, then this is taken from the
command modifiers.
{opts} table|nil Additional options:
• {greedy}: (boolean)
Stage all contiguous hunks. Only useful if 'diff_opts'
contains `linematch`. Defaults to `true`.
toggle_deleted({value}) *gitsigns.toggle_deleted()*
Toggle |gitsigns-config-show_deleted|
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.
Returns:~
Current value of |gitsigns-config-show_deleted|
toggle_current_line_blame({value}) *gitsigns.toggle_current_line_blame()*
Toggle |gitsigns-config-current_line_blame|
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.
Returns:~
Current value of |gitsigns-config-current_line_blame|
toggle_word_diff({value}) *gitsigns.toggle_word_diff()*
Toggle |gitsigns-config-word_diff|
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.
Returns:~
Current value of |gitsigns-config-word_diff|
toggle_linehl({value}) *gitsigns.toggle_linehl()*
Toggle |gitsigns-config-linehl|
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.
Returns:~
Current value of |gitsigns-config-linehl|
toggle_numhl({value}) *gitsigns.toggle_numhl()*
Toggle |gitsigns-config-numhl|
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.
Returns:~
Current value of |gitsigns-config-numhl|
toggle_signs({value}) *gitsigns.toggle_signs()*
Toggle |gitsigns-config-signbooleancolumn|
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.
Returns:~
Current value of |gitsigns-config-signcolumn|
==============================================================================
CONFIGURATION *gitsigns-config*
This section describes the configuration fields which can be passed to
|gitsigns.setup()|. Note fields of type `table` may be marked with extended
meaning the field is merged with the default, with the user value given higher
precedence. This allows only specific sub-fields to be configured without
having to redefine the whole field.
signs *gitsigns-config-signs*
Type: `table[extended]`
Default: >
{
add = { text = '┃' },
change = { text = '┃' },
delete = { text = '▁' },
topdelete = { text = '▔' },
changedelete = { text = '~' },
untracked = { text = '┆' },
}
<
Configuration for signs:
• `text` specifies the character to use for the sign.
• `show_count` to enable showing count of hunk, e.g. number of deleted
lines.
The highlights `GitSigns[kind][type]` is used for each kind of sign. E.g.
'add' signs uses the highlights:
• `GitSignsAdd` (for normal text signs)
• `GitSignsAddNr` (for signs when `config.numhl == true`)
• `GitSignsAddLn `(for signs when `config.linehl == true`)
See |gitsigns-highlight-groups|.
keymaps *gitsigns-config-keymaps*
DEPRECATED
config.keymaps is now deprecated. Please define mappings in config.on_attach() instead.
Type: `table`, Default: `{}`
Keymaps to set up when attaching to a buffer.
Each key in the table defines the mode and key (whitespace delimited)
for the mapping and the value defines what the key maps to. The value
can be a table which can contain keys matching the options defined in
|map-arguments| which are: `expr`, `noremap`, `nowait`, `script`, `silent`
and `unique`. These options can also be used in the top level of the
table to define default options for all mappings.
Since this field is not extended (unlike |gitsigns-config-signs|),
mappings defined in this field can be disabled by setting the whole field
to `{}`, and |gitsigns-config-on_attach| can instead be used to define
mappings.
worktrees *gitsigns-config-worktrees*
Type: `table`, Default: `nil`
Detached working trees.
Array of tables with the keys `gitdir` and `toplevel`.
If normal attaching fails, then each entry in the table is attempted
with the work tree details set.
Example: >
worktrees = {
{
toplevel = vim.env.HOME,
gitdir = vim.env.HOME .. '/projects/dotfiles/.git'
}
}
on_attach *gitsigns-config-on_attach*
Type: `function`, Default: `nil`
Callback called when attaching to a buffer. Mainly used to setup keymaps
when `config.keymaps` is empty. The buffer number is passed as the first
argument.
This callback can return `false` to prevent attaching to the buffer.
Example: >
on_attach = function(bufnr)
if vim.api.nvim_buf_get_name(bufnr):match(<PATTERN>) then
-- Don't attach to specific buffers whose name matches a pattern
return false
end
-- Setup keymaps
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', '<cmd>lua require"gitsigns".stage_hunk()<CR>', {})
... -- More keymaps
end
<
watch_gitdir *gitsigns-config-watch_gitdir*
Type: `table[extended]`
Default: >
{
enable = true,
interval = 1000,
follow_files = true
}
<
When opening a file, a libuv watcher is placed on the respective
`.git` directory to detect when changes happen to use as a trigger to
update signs.
Fields: ~
• `enable`:
Whether the watcher is enabled.
• `interval`:
Interval the watcher waits between polls of the gitdir in milliseconds.
• `follow_files`:
If a file is moved with `git mv`, switch the buffer to the new location.
sign_priority *gitsigns-config-sign_priority*
Type: `number`, Default: `6`
Priority to use for signs.
signcolumn *gitsigns-config-signcolumn*
Type: `boolean`, Default: `true`
Enable/disable symbols in the sign column.
When enabled the highlights defined in `signs.*.hl` and symbols defined
in `signs.*.text` are used.
numhl *gitsigns-config-numhl*
Type: `boolean`, Default: `false`
Enable/disable line number highlights.
When enabled the highlights defined in `signs.*.numhl` are used. If
the highlight group does not exist, then it is automatically defined
and linked to the corresponding highlight group in `signs.*.hl`.
linehl *gitsigns-config-linehl*
Type: `boolean`, Default: `false`
Enable/disable line highlights.
When enabled the highlights defined in `signs.*.linehl` are used. If
the highlight group does not exist, then it is automatically defined
and linked to the corresponding highlight group in `signs.*.hl`.
show_deleted *gitsigns-config-show_deleted*
Type: `boolean`, Default: `false`
Show the old version of hunks inline in the buffer (via virtual lines).
Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`.
diff_opts *gitsigns-config-diff_opts*
Type: `table[extended]`, Default: derived from 'diffopt'
Diff options.
Fields: ~
• algorithm: string
Diff algorithm to use. Values:
• "myers" the default algorithm
• "minimal" spend extra time to generate the
smallest possible diff
• "patience" patience diff algorithm
• "histogram" histogram diff algorithm
• internal: boolean
Use Neovim's built in xdiff library for running diffs.
• indent_heuristic: boolean
Use the indent heuristic for the internal
diff library.
• vertical: boolean
Start diff mode with vertical splits.
• linematch: integer
Enable second-stage diff on hunks to align lines.
Requires `internal=true`.
base *gitsigns-config-base*
Type: `string`, Default: index
The object/revision to diff against.
See |gitsigns-revision|.
count_chars *gitsigns-config-count_chars*
Type: `table`
Default: >
{
[1] = '1', -- '₁',
[2] = '2', -- '₂',
[3] = '3', -- '₃',
[4] = '4', -- '₄',
[5] = '5', -- '₅',
[6] = '6', -- '₆',
[7] = '7', -- '₇',
[8] = '8', -- '₈',
[9] = '9', -- '₉',
['+'] = '>', -- '₊',
}
<
The count characters used when `signs.*.show_count` is enabled. The
`+` entry is used as a fallback. With the default, any count outside
of 1-9 uses the `>` character in the sign.
Possible use cases for this field:
• to specify unicode characters for the counts instead of 1-9.
• to define characters to be used for counts greater than 9.
status_formatter *gitsigns-config-status_formatter*
Type: `function`
Default: >
function(status)
local added, changed, removed = status.added, status.changed, status.removed
local status_txt = {}
if added and added > 0 then table.insert(status_txt, '+'..added ) end
if changed and changed > 0 then table.insert(status_txt, '~'..changed) end
if removed and removed > 0 then table.insert(status_txt, '-'..removed) end
return table.concat(status_txt, ' ')
end
<
Function used to format `b:gitsigns_status`.
max_file_length *gitsigns-config-max_file_length*
Type: `number`, Default: `40000`
Max file length (in lines) to attach to.
preview_config *gitsigns-config-preview_config*
Type: `table[extended]`
Default: >
{
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
}
<
Option overrides for the Gitsigns preview window. Table is passed directly
to `nvim_open_win`.
attach_to_untracked *gitsigns-config-attach_to_untracked*
Type: `boolean`, Default: `true`
Attach to untracked files.
update_debounce *gitsigns-config-update_debounce*
Type: `number`, Default: `100`
Debounce time for updates (in milliseconds).
current_line_blame *gitsigns-config-current_line_blame*
Type: `boolean`, Default: `false`
Adds an unobtrusive and customisable blame annotation at the end of
the current line.
The highlight group used for the text is `GitSignsCurrentLineBlame`.
current_line_blame_opts *gitsigns-config-current_line_blame_opts*
Type: `table[extended]`
Default: >
{
virt_text = true,
virt_text_pos = 'eol',
virt_text_priority = 100,
delay = 1000
}
<
Options for the current line blame annotation.
Fields: ~
• virt_text: boolean
Whether to show a virtual text blame annotation.
• virt_text_pos: string
Blame annotation position. Available values:
`eol` Right after eol character.
`overlay` Display over the specified column, without
shifting the underlying text.
`right_align` Display right aligned in the window.
• delay: integer
Sets the delay (in milliseconds) before blame virtual text is
displayed.
• ignore_whitespace: boolean
Ignore whitespace when running blame.
• virt_text_priority: integer
Priority of virtual text.
current_line_blame_formatter_opts
*gitsigns-config-current_line_blame_formatter_opts*
DEPRECATED
Type: `table[extended]`
Default: >
{
relative_time = false
}
<
Options for the current line blame annotation formatter.
Fields: ~
• relative_time: boolean
current_line_blame_formatter *gitsigns-config-current_line_blame_formatter*
Type: `string|function`, Default: `' <author>, <author_time> - <summary>'`
String or function used to format the virtual text of
|gitsigns-config-current_line_blame|.
When a string, accepts the following format specifiers:
• `<abbrev_sha>`
• `<orig_lnum>`
• `<final_lnum>`
• `<author>`
• `<author_mail>`
• `<author_time>` or `<author_time:FORMAT>`
• `<author_tz>`
• `<committer>`
• `<committer_mail>`
• `<committer_time>` or `<committer_time:FORMAT>`
• `<committer_tz>`
• `<summary>`
• `<previous>`
• `<filename>`
For `<author_time:FORMAT>` and `<committer_time:FORMAT>`, `FORMAT` can
be any valid date format that is accepted by `os.date()` with the
addition of `%R` (defaults to `%Y-%m-%d`):
• `%a` abbreviated weekday name (e.g., Wed)
• `%A` full weekday name (e.g., Wednesday)
• `%b` abbreviated month name (e.g., Sep)
• `%B` full month name (e.g., September)
• `%c` date and time (e.g., 09/16/98 23:48:10)
• `%d` day of the month (16) [01-31]
• `%H` hour, using a 24-hour clock (23) [00-23]
• `%I` hour, using a 12-hour clock (11) [01-12]
• `%M` minute (48) [00-59]
• `%m` month (09) [01-12]
• `%p` either "am" or "pm" (pm)
• `%S` second (10) [00-61]
• `%w` weekday (3) [0-6 = Sunday-Saturday]
• `%x` date (e.g., 09/16/98)
• `%X` time (e.g., 23:48:10)
• `%Y` full year (1998)
• `%y` two-digit year (98) [00-99]
• `%%` the character `%´
• `%R` relative (e.g., 4 months ago)
When a function:
Parameters: ~
{name} Git user name returned from `git config user.name` .
{blame_info} Table with the following keys:
• `abbrev_sha`: string
• `orig_lnum`: integer
• `final_lnum`: integer
• `author`: string
• `author_mail`: string
• `author_time`: integer
• `author_tz`: string
• `committer`: string
• `committer_mail`: string
• `committer_time`: integer
• `committer_tz`: string
• `summary`: string
• `previous`: string
• `filename`: string
Note that the keys map onto the output of:
`git blame --line-porcelain`
{opts} Passed directly from
|gitsigns-config-current_line_blame_formatter_opts|.
Return: ~
The result of this function is passed directly to the `opts.virt_text`
field of |nvim_buf_set_extmark| and thus must be a list of
[text, highlight] tuples.
current_line_blame_formatter_nc
*gitsigns-config-current_line_blame_formatter_nc*
Type: `string|function`, Default: `' <author>'`
String or function used to format the virtual text of
|gitsigns-config-current_line_blame| for lines that aren't committed.
See |gitsigns-config-current_line_blame_formatter| for more information.
trouble *gitsigns-config-trouble*
Type: `boolean`, Default: true if installed
When using setqflist() or setloclist(), open Trouble instead of the
quickfix/location list window.
yadm *gitsigns-config-yadm*
Type: `table`, Default: `{ enable = false }`
yadm configuration.
word_diff *gitsigns-config-word_diff*
Type: `boolean`, Default: `false`
Highlight intra-line word differences in the buffer.
Requires `config.diff_opts.internal = true` .
Uses the highlights:
• For word diff in previews:
• `GitSignsAddInline`
• `GitSignsChangeInline`
• `GitSignsDeleteInline`
• For word diff in buffer:
• `GitSignsAddLnInline`
• `GitSignsChangeLnInline`
• `GitSignsDeleteLnInline`
• For word diff in virtual lines (e.g. show_deleted):
• `GitSignsAddVirtLnInline`
• `GitSignsChangeVirtLnInline`
• `GitSignsDeleteVirtLnInline`
debug_mode *gitsigns-config-debug_mode*
Type: `boolean`, Default: `false`
Enables debug logging and makes the following functions
available: `dump_cache`, `debug_messages`, `clear_debug`.
==============================================================================
HIGHLIGHT GROUPS *gitsigns-highlight-groups*
These are the highlights groups used by Gitsigns.
Note if a highlight is not defined, it will be automatically derived by
searching for other defined highlights in order.
*hl-GitSignsAdd*
GitSignsAdd
Used for the text of 'add' signs.
Fallbacks: `GitGutterAdd`, `SignifySignAdd`, `DiffAddedGutter`, `diffAdded`, `DiffAdd`
*hl-GitSignsChange*
GitSignsChange
Used for the text of 'change' signs.
Fallbacks: `GitGutterChange`, `SignifySignChange`, `DiffModifiedGutter`, `diffChanged`, `DiffChange`
*hl-GitSignsDelete*
GitSignsDelete
Used for the text of 'delete' signs.
Fallbacks: `GitGutterDelete`, `SignifySignDelete`, `DiffRemovedGutter`, `diffRemoved`, `DiffDelete`
*hl-GitSignsChangedelete*
GitSignsChangedelete
Used for the text of 'changedelete' signs.
Fallbacks: `GitSignsChange`
*hl-GitSignsTopdelete*
GitSignsTopdelete
Used for the text of 'topdelete' signs.
Fallbacks: `GitSignsDelete`
*hl-GitSignsUntracked*
GitSignsUntracked
Used for the text of 'untracked' signs.
Fallbacks: `GitSignsAdd`
*hl-GitSignsAddNr*
GitSignsAddNr
Used for number column (when `config.numhl == true`) of 'add' signs.
Fallbacks: `GitGutterAddLineNr`, `GitSignsAdd`
*hl-GitSignsChangeNr*
GitSignsChangeNr
Used for number column (when `config.numhl == true`) of 'change' signs.
Fallbacks: `GitGutterChangeLineNr`, `GitSignsChange`
*hl-GitSignsDeleteNr*
GitSignsDeleteNr
Used for number column (when `config.numhl == true`) of 'delete' signs.
Fallbacks: `GitGutterDeleteLineNr`, `GitSignsDelete`
*hl-GitSignsChangedeleteNr*
GitSignsChangedeleteNr
Used for number column (when `config.numhl == true`) of 'changedelete' signs.
Fallbacks: `GitSignsChangeNr`
*hl-GitSignsTopdeleteNr*
GitSignsTopdeleteNr
Used for number column (when `config.numhl == true`) of 'topdelete' signs.
Fallbacks: `GitSignsDeleteNr`
*hl-GitSignsUntrackedNr*
GitSignsUntrackedNr
Used for number column (when `config.numhl == true`) of 'untracked' signs.
Fallbacks: `GitSignsAddNr`
*hl-GitSignsAddLn*
GitSignsAddLn
Used for buffer line (when `config.linehl == true`) of 'add' signs.
Fallbacks: `GitGutterAddLine`, `SignifyLineAdd`, `DiffAdd`
*hl-GitSignsChangeLn*
GitSignsChangeLn
Used for buffer line (when `config.linehl == true`) of 'change' signs.
Fallbacks: `GitGutterChangeLine`, `SignifyLineChange`, `DiffChange`
*hl-GitSignsChangedeleteLn*
GitSignsChangedeleteLn
Used for buffer line (when `config.linehl == true`) of 'changedelete' signs.
Fallbacks: `GitSignsChangeLn`
*hl-GitSignsUntrackedLn*
GitSignsUntrackedLn
Used for buffer line (when `config.linehl == true`) of 'untracked' signs.
Fallbacks: `GitSignsAddLn`