forked from sindrets/diffview.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiffview.txt
1337 lines (998 loc) · 52.8 KB
/
diffview.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
*diffview.txt* Diffview.nvim
Single tabpage interface to easily cycle through diffs for all modified files
for any git rev.
Author: Sindre T. Strøm
==============================================================================
INTRODUCTION *diffview.nvim* *diffview*
Vim's diff mode is pretty good, but there is no convenient way to quickly bring
up all modified files in a diffsplit. This plugin aims to provide a simple,
unified, single tabpage interface that lets you easily review all changed files
for any git rev.
==============================================================================
USAGE *diffview-usage*
Quick-start: `:DiffviewOpen` to open a Diffview that compares against the
index.
You can have multiple Diffviews open, tracking different git revs. Each Diffview
opens in its own tabpage. To close and dispose of a Diffview, call either
`:DiffviewClose` or `:tabclose` while a Diffview is the current tabpage.
Diffviews are automatically updated:
• Every time you enter a Diffview
• Whenever `.git/index` changes.
• On |BufWritePost|
• On |User_FugitiveChanged|
Updates are not run unless the current tabpage is a Diffview.
COMMANDS *diffview-commands*
*:DiffviewOpen*
:DiffviewOpen [git-rev] [options] [ -- {paths...}]
Opens a new Diffview that compares against [git-rev]. If no [git-rev]
is given, defaults to comparing against the index. Additional
{paths...} may be provided to narrow down what files are shown. If the
`-C` flag is not defined, the git top-level is determined from the
current buffer when possible. Otherwise it's determined from the cwd.
Examples:
>
:DiffviewOpen
:DiffviewOpen HEAD~2
:DiffviewOpen HEAD~4..HEAD~2
:DiffviewOpen d4a7b0d
:DiffviewOpen d4a7b0d^!
:DiffviewOpen d4a7b0d..519b30e
:DiffviewOpen origin/main...HEAD
:DiffviewOpen HEAD~2 -- lua/diffview plugin
:DiffviewOpen d4a7b0d -uno
<
*diffview-merge-tool*
If you call `:DiffviewOpen` during a merge or a rebase, the view will
list the conflicted files in their own section. When opening a
conflicted file, it will open in a 3-way diff allowing you to resolve
the conflict with the context of the target branch's version (OURS,
left), and the version from the branch which is being merged (THEIRS,
right).
The conflicted file's entry in the file panel will show the
remaining number of conflict markers (the number following the file
name). If what follows the file name is instead an exclamation mark
(`!`), this indicates that the file has not yet been opened, and the
number of conflicts is unknown. If the sign is a check mark, this
indicates that there are no more conflicts in the file.
You can jump between conflict markers with `]x` and `[x`. This works
from the file panel as well. Further, in addition to the normal
|copy-diffs| mappings you can use `2do` to obtain the hunk from the
OURS side of the diff, `3do` to obtain the hunk from the THEIRS side
of the diff, and - in a 4-way diff - `1do` to obtain the hunk from the
BASE. See |diffview-conflict-versions| to tell what windows correspond
with what version of the file.
Additionally there are mappings for operating directly on the conflict
markers:
• `<leader>co`: Choose the OURS version of the conflict.
• `<leader>ct`: Choose the THEIRS version of the conflict.
• `<leader>cb`: Choose the BASE version of the conflict.
• `<leader>ca`: Choose all versions of the conflict (effectively
just deletes the markers, leaving all the content).
• `dx`: Choose none of the versions of the conflict (delete the
conflict region).
For more info on these actions, see
|diffview-actions-conflict_choose|.
NOTE: The horizontal 3-way diff is only the default layout for the
merge-tool, but there are multiple variations on the 3-way diff layout
as well as a 4-way diff, and a single window layout available. The
default mapping `g<C-x>` allows you to cycle through the available
layouts. To configure a different default layout, see
|diffview-config-view.x.layout|.
Options:~
-u[value], --untracked-files[={value}]
Specify whether or not to show untracked files. If
flag is given without value; defaults to `true`.
{value} can be one of:
• `true`, `normal`, `all` Show untracked.
• `false`, `no` Don't show untracked.
--cached, --staged
Diff staged changes against [git-rev]. If no [git-rev]
is given, defaults to `HEAD`.
--imply-local If a range rev is provided and either end of the range
points to `HEAD`: point that end to local files
instead (not created from git). This can be useful
i.e. when using symmetric difference ranges
(triple-dot), but you want to be able to utilize the
LSP features that are not available while you're
viewing files created from git.
-C{path} Run as if git was started in {path} instead of the
current working directory.
--selected-file={path}
Specify a path to the preferred initially selected
file. If the path doesn't match any of the files in
the initial set of files, this option does nothing.
*:DiffviewFileHistory*
:[range]DiffviewFileHistory [paths] [options]
Opens a new file history view that lists all commits that affected the
given paths. This is a porcelain interface for git-log. Both [paths]
and [options] may be specified in any order, even interchangeably.
If no [paths] are given, defaults to the top-level of the working
tree. The top-level will be inferred from the current buffer when
possible, otherwise the cwd is used. Multiple [paths] may be provided
and git pathspec is supported (see `:Man gitglossary(7)` for
information about pathspec).
If [range] is given, the file history view will trace the line
evolution of the given range in the current file (see the `-L` flag
below).
From the file history panel (the panel listing the commits) you can
open an option panel by pressing `g!`. The option panel will allow you
to change the flags that will be passed to `git-log`. A flag can be
adjusted either by moving the cursor to its line followed by pressing
<Tab>, or by using the mappings that are shown directly in the panel,
preceding the flags' descriptions.
NOTE: Commits are only listed if git-log is able to show its file
stats given your currently configured log options. As such pay
attention to the value of `--diff-merges`, as this controls how
git-log treats merge commits and subsequently it's willingness to show
stats for these commits. Setting `--diff-merges=off` will tell git-log
to never compare merge commits, and as such they won't show up in the
file history view.
Examples:
>
:DiffviewFileHistory
:DiffviewFileHistory %
:DiffviewFileHistory path/to/some/file.txt
:DiffviewFileHistory path/to/some/directory
:DiffviewFileHistory multiple/paths foo/bar baz/qux
:DiffviewFileHistory --base=HEAD~4
:DiffviewFileHistory --base=LOCAL
:DiffviewFileHistory --range=origin..HEAD
:DiffviewFileHistory --range=feat/some-branch
:'<,'>DiffviewFileHistory
<
Options:~
--base={git-rev}
Specify a base git rev from which the right side of
the diff will be created. Use the special value
`LOCAL` to use the local version of the file.
--range={git-rev}
Show only commits in the specified revision range.
-C{path} Run as if git was started in {path} instead of the
current working directory.
NOTE: All following options are described in far more detail in the
man page for git-log. See `:Man git-log(1)` for more information.
--follow Follow renames (only for single file).
--first-parent Follow only the first parent upon seeing a merge
commit.
--show-pulls Show merge commits that are not TREESAME to its first
parent, but are to a later parent.
--reflog Include all reachable objects mentioned by reflogs.
--all Include all refs.
--merges List only merge commits.
--no-merges List no merge commits.
--reverse List commits in reverse order.
-n{n}, --max-count={n}
Limit the number of commits.
-L{start},{end}:{file}, -L:{funcname}:{file}
Trace the evolution of the line range given by
{start},{end}, or by the function name regex
{funcname}, within the {file}. You can specify this
option more than once.
--diff-merges={value}
Determines how merge commits are treated. {value} can
be one of:
• `off`
• `on`
• `first-parent`
• `separate`
• `combined`
• `dense-combined`
• `remerge`
--author={pattern}
Limit the commits output to ones with author/committer
header lines that match the specified pattern (regular
expression).
--grep={pattern}
Limit the commits output to ones with log message that
matches the specified pattern (regular expression).
*:DiffviewClose*
:DiffviewClose Close the active Diffview.
*:DiffviewToggleFiles*
:DiffviewToggleFiles Toggles the file panel.
*:DiffviewFocusFiles*
:DiffviewFocusFiles Brings focus to the file panel. Opens it if it's closed.
*:DiffviewRefresh*
:DiffviewRefresh Update stats and entries in the file list of the
current Diffview.
*:DiffviewLog*
:DiffviewLog Open the log.
==============================================================================
CONFIGURATION *diffview-config*
EXAMPLE CONFIGURATION WITH DEFAULT SETTINGS: |diffview.defaults|
enhanced_diff_hl *diffview-config-enhanced_diff_hl*
Type: `boolean`, Default: `false`
Enable/disable enhanced diff highlighting. When enabled, |hl-DiffAdd|
in the left diff buffer will be highlighted as |hl-DiffDelete|, and
the delete fill-chars will be highlighted more subtly.
git_cmd *diffview-config-git_cmd*
Type: `string[]`, Default: `{ "git" }`
This table forms the first part of all git commands used internally in
the plugin. The first element should be the git binary. The subsequent
elements are passed as arguments.
view.x.layout *diffview-config-view.x.layout*
Type: >
"diff1_plain"
| "diff2_horizontal"
| "diff2_vertical"
| "diff3_horizontal"
| "diff3_vertical"
| "diff3_mixed"
| "diff4_mixed"
| -1
<
Default: (see example config above)
This determines the layout used for diffs in the various different
views. Some of the layouts are only applicable to certain types of
views.
If you set the layout to `-1`, the layout type will be derived from
your |'diffopt'| (more specifically: whether or not you have
`vertical` set).
Layouts: ~
Unless otherwise stated, the window symbols (A, B, C, D) represent
the following versions of a file:
In the diff_view and file_history_view:
• A: Old state
• B: New state
*diffview-conflict-versions*
In the merge_tool:
• A: OURS (current branch)
• B: LOCAL (the file as it currently exists on disk)
• C: THEIRS (incoming branch)
• D: BASE (common ancestor)
{diff1_plain}
Available for: merge_tool
This is a plain, singular window. This is available in case
you prefer to edit conflict markers manually without the
visual noise from diffs.
Window symbols:
• A: LOCAL
┌──────────────┐
│ │
│ │
│ A │
│ │
│ │
└──────────────┘
{diff2_horizontal}
Available for: diff_view, file_history_view
┌──────┬───────┐
│ │ │
│ │ │
│ A │ B │
│ │ │
│ │ │
└──────┴───────┘
{diff2_vertical}
Available for: diff_view, file_history_view
┌──────────────┐
│ A │
│ │
├──────────────┤
│ B │
│ │
└──────────────┘
{diff3_horizontal}
Available for: merge_tool
┌────┬────┬────┐
│ │ │ │
│ │ │ │
│ A │ B │ C │
│ │ │ │
│ │ │ │
└────┴────┴────┘
{diff3_vertical}
Available for: merge_tool
┌──────────────┐
│ A │
├──────────────┤
│ B │
├──────────────┤
│ C │
└──────────────┘
{diff3_mixed}
Available for: merge_tool
┌──────┬───────┐
│ A │ C │
│ │ │
├──────┴───────┤
│ B │
│ │
└──────────────┘
{diff4_mixed}
Available for: merge_tool
┌────┬────┬────┐
│ A │ D │ C │
│ │ │ │
├────┴────┴────┤
│ B │
│ │
└──────────────┘
*diffview-config-view.merge_tool.disable_diagnostics*
view.merge_tool.disable_diagnostics
Type: `boolean`, Default: `true`
Temporarily disable diagnostics for conflict buffers while in a
diff_view. The diagnostics are enabled again when leaving or closing
the view's tab page.
win_config *diffview-config-win_config*
Type: `table | fun(): table`, Default: `{}`
This is used to configure the windows of the various panels in the
plugin. If this is set to a function, it should return the config
table when called (usually whenever the panel opens). If
`type="float"`, then this should be the config table passed to
|nvim_open_win()|.
Certain fields are only applicable for either `type="split"` or
`type="float"`. If a field description is designated as "when
`type="split"`", then this implies that the field has a different
function when `type="float"`. When that is the case, the field's float
behavior is documented under |nvim_open_win()|.
Fields: ~
{type} ("split"|"float")
Determines whether the window should be a float or a normal
split.
{width} (integer)
The width of the window (in character cells). If `type` is
`"split"` then this is only applicable when `position` is
`"left"|"right"`.
{height} (integer)
The width of the window (in character cells). If `type` is
`"split"` then this is only applicable when `position` is
`"top"|"bottom"`.
{position} ("left"|"top"|"right"|"bottom")
Determines where the panel is positioned (only when
`type="split"`).
{relative} ("editor"|"win")
Determines what the `position` is relative to (when
`type="split"`).
Default: `"editor"`
{win} (integer)
The window handle of the target relative window (when
`type="split"`. Only when `relative="win"`). Use `0` for
current window.
Default: `0`
{win_opts} (table)
Table of window local options (see |vim.opt_local|).
These options are applied whenever the window is opened.
NOTE: Fields that are only applicable when `type="float"` are not
listed here because they are already documented under
|nvim_open_win()|.
Examples: >
-- Split window, aligned to the right side of the editor:
win_config = {
type = "split",
position = "right",
width = 40,
}
-- Split window, aligned to the bottom of the first window in
-- the current tabpage:
win_config = function()
local c = {
type = "split",
position = "bottom",
relative = "win",
height = 14,
}
c.win = vim.api.nvim_tabpage_list_wins(0)[1]
return c
end
-- Floating window, centered in the editor:
win_config = function()
local c = { type = "float" }
local editor_width = vim.o.columns
local editor_height = vim.o.lines
c.width = math.min(100, editor_width)
c.height = math.min(24, editor_height)
c.col = math.floor(editor_width * 0.5 - c.width * 0.5)
c.row = math.floor(editor_height * 0.5 - c.height * 0.5)
return c
end,
<
log_options *diffview-config-log_options*
Type: `table`, Default: (see example config above)
This table allows you to control the default options that are passed
to git-log in order to produce the file history. The table is divided
into the sub-tables `single_file`, and `multi_file`. This allows you
to define different default log options for history targeting singular
files, and history targeting multiple paths, and/or directories.
Fields:~
{single_file} (`LogOptions`)
See |diffview.git.LogOptions|.
{multi_file} (`LogOptions`)
See |diffview.git.LogOptions|.
default_args *diffview-config-default_args*
Type: `table<string, string[]>`, Default: `{}`
This table allows you to define the default args that will always be
prepended to the arg-list for the commands specified by the table
keys.
Examples: >
default_args = {
DiffviewOpen = { "--untracked-files=no", "--imply-local" },
DiffviewFileHistory = { "--base=LOCAL" },
}
<
hooks *diffview-config-hooks*
Type: `table<string, function>`, Default: `{}`
This is a table of event names mapped to callback functions. The
callbacks are called when the related events are emitted from
Diffview. The hook events are also available as User autocommands. See
|diffview-user-autocmds| for more details.
Available Events:~
{view_opened} (`fun(view: View)`)
Emitted after a new view has been opened. It's called after
initializing the layout in the new tabpage (all windows are
ready).
Callback Parameters:~
{view} (`View`)
The `View` instance that was opened.
{view_closed} (`fun(view: View)`)
Emitted after closing a view.
Callback Parameters:~
{view} (`View`)
The `View` instance that was closed.
{view_enter} (`fun(view: View)`)
Emitted just after entering the tabpage of a view.
Callback Parameters:~
{view} (`View`)
The `View` instance that was entered.
{view_leave} (`fun(view: View)`)
Emitted just before leaving the tabpage of a view.
Callback Parameters:~
{view} (`View`)
The `View` instance that's about to be left.
{diff_buf_read} (`fun(bufnr: integer)`)
Emitted after a new diff buffer is ready (the first time it's
created). Diff buffers are all buffers with |diff-mode|
enabled. That includes buffers of local files (not created
from git).
This is always called with the new buffer as the current
buffer such that |:setlocal| will apply settings to that
relevant buffer.
Callback Parameters:~
{bufnr} (`integer`)
The buffer number of the new buffer.
{diff_buf_win_enter} (`fun(bufnr: integer)`)
Emitted after a diff buffer is displayed in a window.
This is always called with the new buffer as the current
buffer and the correct diff window as the current window such
that |:setlocal| will apply settings to the relevant buffer /
window.
Callback Parameters:~
{bufnr} (`integer`)
The buffer number of the new buffer.
Examples: >
hooks = {
diff_buf_read = function(bufnr)
-- Change local options in diff buffers
vim.opt_local.wrap = false
vim.opt_local.list = false
vim.opt_local.colorcolumn = { 80 }
end,
view_opened = function(view)
print(
("A new %s was opened on tab page %d!")
:format(view:class():name(), view.tabpage)
)
end,
}
<
keymaps *diffview-config-keymaps*
Type: `table`, Default: (see example config above)
The keymaps config is structured as a table with sub-tables for
various different contexts where mappings can be declared. In these
sub-tables key-value pairs are treated as the |{lhs}| and |{rhs}| of a
normal mode mapping. These mappings all use the |:map-arguments|
`silent`, `nowait`, and `noremap`. The implementation uses
|vim.keymap.set()|, so the {rhs} can be either a vim command in the
form of a string, or it can be a lua function: >
view = {
-- Vim command:
["a"] = "<Cmd>echom 'foo'<CR>",
-- Lua function:
["b"] = function() print("bar") end,
}
<
For more control (i.e. mappings for other modes), you can also define
index values as list-like tables containing the arguments for
|vim.keymap.set()|. This way you can also change all the
|:map-arguments| with the only exception being the `buffer` field, as
this will be overridden with the target buffer number: >
view = {
-- Normal and visual mode mapping to vim command:
{ { "n", "v" }, "<leader>a", "<Cmd>echom 'foo'<CR>", { silent = true } },
-- Visual mode mapping to lua function:
{ "v", "<leader>b", function() print("bar") end, { nowait = true } },
}
<
To disable all the default mappings simply set: >
keymaps = {
disable_defaults = true,
}
<
To disable any single mapping without disabling them all, set its
value to `false`: >
view = {
["<tab>"] = false,
}
<
*diffview-actions*
Actions~
Actions are key-mappable functions. You can access an action through
the config module: >
require("diffview.config").actions.{action_name}
<
Where {action_name} is the name of the action you're accessing. Many
actions are contextual and will behave slightly differently depending
on what context they were called from. The various actions are
described with all the contexts in which they have a function.
Following are the different contexts described alongside possible
subjects, upon which actions called from their context, will act on.
Contexts:~
{diff_view}
The windows containing the diff buffers in a Diffview.
Subjects:
• The current tabpage
• The file being diffed
• The commit of either of the two files being diffed
• The range of git revs between the two files being diffed
{merge_tool} (View)
The windows containing the diff buffers for conflicted files
during a merge or rebase.
Subjects:
• The file being diffed
{file_history_view}
The windows containing the diff buffers in a FileHistoryView.
Subjects:
• The current tabpage
• The file being diffed
• The commit of either of the two files being diffed
• The range of git revs between the two files being diffed
{view}
Any of the views.
{file_panel}
The panel listing the files in a Diffview.
Subjects:
• The window
• The file under the cursor
• The file currently open
{file_history_panel}
The panel listing the commits in a FileHistoryView.
Subjects:
• The window
• The commit under the cursor
• The file under cursor
• The file currently open
{options_panel}
Panel used for interactively changing options in i.e. the
FileHistoryView.
Subjects:
• The window
• The option under the cursor
{panel}
Any of the panels.
*diffview-available-actions*
Available Actions~
close *diffview-actions-close*
Contexts: `view`, `panel`
Close the subject of the context.
close_all_folds *diffview-actions-close_all_folds*
Contexts: `file_history_panel`
If the FileHistoryView is showing history for multiple files: close
all the folds in the panel.
conflict_choose({version}) *diffview-actions-conflict_choose*
Contexts: `merge_tool`
Replace the merge conflict under the cursor with one, none or all the
versions of the conflict. Choosing `'none'` effectively deletes the
entire conflict region. Choosing `'all'` effectively deletes only the
conflict markers and leaves all the content.
Parameters: ~
{version} `'ours'|'theirs'|'base'|'all'|'none'`
See |diffview-conflict-versions| to tell what versions of the
file these names correspond with.
*diffview-conflict-example*
Example conflict region annotated with the version names: >
<<<<<<< OURS (Start of conflict, typically the current branch)
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
||||||| BASE (Common ancestor)
Consequat semper viverra nam libero justo laoreet sit amet.
Sed risus pretium quam vulputate dignissim.
Nisl condimentum id venenatis a condimentum.
======= THEIRS (Incoming branch)
Rhoncus aenean vel elit scelerisque.
A pellentesque sit amet porttitor eget dolor morbi.
Integer eget aliquet nibh praesent tristique magna sit amet.
>>>>>>> (End of conflict)
<
copy_hash *diffview-actions-copy_hash*
Contexts: `file_history_panel`
Copy the commit hash of the commit under the cursor.
diffget({target}) *diffview-actions-diffget*
Contexts: `merge_tool`
Obtain the hunk from a particular version of the current file.
Parameters: ~
{target} `'ours'|'theirs'|'base'|'local'`
See |diffview-conflict-versions| to tell what windows
correspond with what version of the file.
focus_entry *diffview-actions-focus_entry*
Contexts: `file_panel`, `file_history_panel`
Like |diffview-actions-select_entry| when invoked from the same
context, but also bring the cursor to the right diff split.
focus_files *diffview-actions-focus_files*
Contexts: `view`
Bring focus to the file panel of the subject. Opens the panel if it's
closed.
goto_file *diffview-actions-goto_file*
Contexts: `view`, `panel`
Open the local version of the file in a new split in a different
tabpage. This will target your previous (last accessed) tabpage first.
If you have no non-diffview tabpages open, the file will open in a new
tabpage. See |diffview-file-inference| for details on how the
file target is determined.
goto_file_edit *diffview-actions-goto_file_edit*
Contexts: `view`, `panel`
Like |diffview-actions-goto_file| except after changing tabpage,
instead of creating a new split, it will just open the file in the
last accessed window.
goto_file_split *diffview-actions-goto_file_split*
Contexts: `view`, `panel`
Open the local version of the file in a new split. See
|diffview-file-inference| for details on how the file target is
determined.
goto_file_tab *diffview-actions-goto_file_tab*
Contexts: `view`, `panel`
Open the local version of the file in a new tabpage. See
|diffview-file-inference| for details on how the file target is
determined.
listing_style *diffview-actions-listing_style*
Contexts: `file_panel`
Cycle through the available listing styles. The currently available
styles are: file tree and flat list.
next_conflict *diffview-actions-next_conflict*
Contexts: `diff_view`, `file_panel`
Moves the cursor to the next conflict marker in the current file.
next_entry *diffview-actions-next_entry*
Contexts: `view`, `panel`
Bring the cursor in the subject panel to the next entry.
open_all_folds *diffview-actions-open_all_folds*
Contexts: `file_history_panel`
If the FileHistoryView is showing history for multiple files: open
all the folds in the panel.
open_commit_log *diffview-actions-open_commit_log*
Contexts: `view`, `file_panel`, `file_history_panel`
Open a panel showing the full commit description of the subject's
target commit range.
open_in_diffview *diffview-actions-open_in_diffview*
Contexts: `file_history_view`, `file_history_panel`
Open the subject in a new Diffview.
options *diffview-actions-options*
Contexts: `file_history_view`, `file_history_panel`
Open the option panel for the subject.
prev_conflict *diffview-actions-prev_conflict*
Contexts: `diff_view`, `file_panel`
Moves the cursor to the previous conflict marker in the current file.
prev_entry *diffview-actions-prev_entry*
Contexts: `view`, `panel`
Bring the cursor in the subject panel to the previous entry.
refresh_files *diffview-actions-refresh_files*
Contexts: `diff_view`, `file_panel`
Update stats and entries in the file list.
restore_entry *diffview-actions-restore_entry*
Contexts: `diff_view`, `file_panel`
Revert the selected file entry to the state from the left side of the
diff. This only works if the right side of the diff is showing the
local state of the file. A command is echoed that shows how to undo
the change. Check |:messages| to see it again.
NOTE: "Restoring" an untracked file will delete it from disk. It still
gets backed up in the local git database, so it is reversible.
scroll_view({distance}) *diffview-actions-scroll_view*
Contexts: `panel`
Scroll the view a given distance.
Parameters:~
{distance} (number)
Either an exact number of lines, or a fraction of the window
height. Use negative numbers to scroll up and positive numbers
to scroll down.
select_entry *diffview-actions-select_entry*
Contexts: `view`, `panel`
Select the subject.
Think of this as a general "interact" action. In the file panel, and
the file history panel, this will open the file under the cursor. If
the entry under the cursor is a directory, or a history entry with
multiple files, this will collapse or open the entry. In the option
panel this will interact with the option under the cursor.
select_next_entry *diffview-actions-select_next_entry*
Contexts: `view`, `file_panel`, `file_history_panel`
Select the entry following the subject.
select_prev_entry *diffview-actions-select_prev_entry*
Contexts: `view`, `file_panel`, `file_history_panel`
Select the entry preceding the subject.
stage_all *diffview-actions-stage_all*
Contexts: `diff_view`, `file_panel`
Stage all changes.
toggle_files *diffview-actions-toggle_files*
Contexts: `view`, `file_panel`, `file_history_panel`
Toggle the subject panel.
toggle_flatten_dirs *diffview-actions-toggle_flatten_dirs*
Contexts: `file_panel`
Toggle whether or not to flatten empty subdirectories in the file tree
listing style.
toggle_stage_entry *diffview-actions-toggle_stage_entry*
Contexts: `diff_view`, `file_panel`
Stage / unstage the subject.
unstage_all *diffview-actions-unstage_all*
Contexts: `diff_view`, `file_panel`
Unstage all changes.
view_windo({cmd}, [targets]) *diffview-actions-view_windo*
Contexts: `view`, `panel`
Execute {cmd} for each target window in the target view. If no targets
are given, all windows are targeted. The {cmd} will be called with
each target window as the temporary current window (|nvim_win_call()|).
Parameters:~
{cmd} (string|function)
The vim cmd to execute, or a lua function.
[targets] (`{ a: boolean, b: boolean, c: boolean, d: boolean }`)
The windows to target. The letters correspond to the window
symbols for the current layout as they are illustrated under
|diffview-config-view.x.layout|.
*diffview-unused-actions*
Unused actions~
Not all actions are mapped by default. The unused actions offer variations on
the functionality provided by other actions, or just different functionality
that you might optionally want to use. Here is a list of tags to the unused
actions:
• |diffview-actions-focus_entry|
• |diffview-actions-goto_file_edit|
• |diffview-actions-view_windo|
USER AUTOCOMMANDS *diffview-user-autocmds*
For information on how to use User autocommands, see |User|.
`DiffviewViewOpened` Fires after a new view has been opened. It's called
after initializing the layout in the new tabpage (all
windows are ready).
`DiffviewViewClosed` Fires after a view is closed.
`DiffviewViewEnter` Fires just after entering a view.
`DiffviewViewLeave` Fires just before leaving a view.
`DiffviewDiffBufRead` Fires after a new diff buffer is ready (the first
time it's created). Diff buffers are all buffers with
|diff-mode| enabled. That includes buffers of local
files (not created from git).
This is always called with the new buffer as the current
buffer such that |:setlocal| will apply settings to that
relevant buffer.
`DiffviewDiffBufWinEnter`