This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
gina.txt
2762 lines (2286 loc) · 89.5 KB
/
gina.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
*gina.txt* Asynchronously control git repositories from Vim
Version: 1.0
Author: Alisue <[email protected]>
License: MIT License (See LICENSE)
=============================================================================
CONTENTS *gina-contents*
INTRODUCTION |gina-introduction|
USAGE |gina-usage|
COMMAND |gina-usage-command|
ACTION |gina-usage-action|
COMPONENT |gina-usage-component|
CUSTOM |gina-custom|
ACTION |gina-custom-action|
MAPPING |gina-custom-mapping|
COMMAND |gina-custom-command|
EXECUTE |gina-custom-execute|
EXAMPLE |gina-custom-example|
BUFFER |gina-buffer|
BLAME |gina-buffer-blame|
BRANCH |gina-buffer-branch|
CHANGES |gina-buffer-changes|
COMMIT |gina-buffer-commit|
DIFF |gina-buffer-diff|
GREP |gina-buffer-grep|
LOG |gina-buffer-log|
LS |gina-buffer-ls|
REFLOG |gina-buffer-reflog|
SHOW |gina-buffer-show|
STASH |gina-buffer-stash|
STASH SHOW |gina-buffer-stash-show|
STATUS |gina-buffer-status|
TAG |gina-buffer-tag|
INTERFACE |gina-interface|
COMMANDS |gina-commands|
FUNCTIONS |gina-functions|
VARIABLES |gina-variables|
HIGHLIGHTS |gina-highlights|
OPTIONS |gina-options|
ACTIONS |gina-actions|
MISC |gina-misc|
SHORT FORMAT |gina-misc-short-format|
TREEISH |gina-misc-treeish|
STRING FORMAT |gina-misc-string-format|
ASKPASS |gina-misc-askpass|
CHANGELOG |gina-changelog|
=============================================================================
INTRODUCTION *gina-introduction*
*gina.vim* (gina) is a plugin to asynchronously control git repositories.
- Execute a git command asynchronously (|job|)
- List candidates of a result of a git command
- Perform actions on candidates above to control a git repository
Latest version:~
https://github.com/lambdalisue/gina.vim
=============================================================================
USAGE *gina-usage*
The following is a schematic image of general working-flow with gina.
>
┌─────┬──────────┐
│ │ │
#DIRTY# │ ▼
▲ │ :Gina status │ << : stage
│ │ │ │ >> : unstage
│ │ │ │ -- : toggle
:write │ #STAGED# │ == : discard
▲ │ │ │ pp : patch
│ ├──────────┤ │ dd : diff
│ │ ▼
#CLEAN# │ :Gina commit │ ! : switch --amend
│ │ │ │ :w : save cache
│ ▼ │ │ :q : commit changes (confirm)
└────────────────┘ │ :wq : commit changes (immediate)
<
So basically user would
1. Edit contents in a git repository
2. Stage changes with |:Gina-status|
- "<<" to stage
- ">>" to unstage
- etc.
3. Commit changes with |:Gina-commit|
- |:w| to save message into a cache
- |:q| to commit changes (user will be asked if they want)
- |:wq| to commit changes (immediately the commit will be performed)
Read further to learn more basic of gina.
-----------------------------------------------------------------------------
COMMAND *gina-usage-command*
gina provides a single command |:Gina| which takes at least one argument.
When |:Gina| is executed with a |bang| modifier (|:Gina!|), it executes a
corresponding git command asynchronously and echo the result.
For example, when users execute ":Gina! status", it echos the current status
of a git repository like
>
:Gina! status
[gina] On branch master
[gina] Your branch is up-to-date with 'origin/master'.
...
[gina]
[gina] no changes added to commit (use "git add" and/or "git ...
<
When |:Gina| is executed with a double |bang| modifier (|:Gina!!|), it
executes a corresponding git command under the shell by |:!| or |:terminal|.
It is mainly for supporting an interactive features, such as "git add -p" or
"git rebase -i". Note that the command is not executed asynchronously.
When |:Gina| is executed without a |bang| modifier, it tries to find a
corresponding gina command from a "gina#command#..." namespace and execute.
If no corresponding command is found, it fallbacks to the above behavior,
namely non-gina conmmand executes a raw git command.
For example, when user executes ":Gina add", it fallbacks to ":Gina! add"
while there is no corresponding gina command for "add" exist.
>
:Gina add
[gina] Nothing specified, nothing added.
[gina] Maybe you wanted to say 'git add .'?
<
And when user executes ":Gina status", it opens a "gina-status" buffer while
"status" is found in "gina#command#..." namespace and the function
opens a "gina-status" buffer of the current git repository.
>
:Gina status
--> Opens a "gina-status" window instead
<
And on the buffer, users can execute pre-defined actions which is explained
in the next section.
-----------------------------------------------------------------------------
ACTION *gina-usage-action*
When |:Gina| opens a non file-like buffer (e.g. "gina-status" buffer), users
may perform pre-defined actions on candidates shown in the buffer.
For example, ":Gina status -s" opens a "gina-status" buffer with short format
which looks like
>
M foo.txt
M bar.txt
<
The buffer contents indiceate the index status of each files.
The first line indicates that a "foo.txt" is staged and the last line
indicates a "bar.txt" isn't.
When users hit "a" on the last line, users will be asked to select an
action to perform with a prompt like
>
action:
<
So now, type "sta" on that prompt like
>
action: sta
<
And now, hit <Tab> and "stage" is completed. This is a basic behavior of
|cmdline-completion| so read that if you are not familiar with.
And now, hit <Return> to perform the action. This will perform an
"index:stage" action which is aliased to "stage", what users just input.
And then the buffer content will becomes
>
M foo.txt
M bar.txt
<
Which indicates all changes are staged into the index.
So now, let's unstage "foo.txt" with an "index:unstage" action which is
aliased to "unstage".
Start a prompt by hitting "a" on the first line and type "uns" like
>
action: uns
<
And this time, hit <Return> instead of <Tab>.
It should execute a "index:unstage" action and the buffer content will become
>
M foo.txt
M bar.txt
<
Action name is guessed from the input, mean that users do not need to input
complete action name/alias if there is no confliction.
You may lazy to type an action name/alias everytime.
Fortunately, "gina-status" buffer provides some default mappings for
fundemental actions. The "stage" and "unstage" are mapped to "<<" and ">>" so
hitting these keys on a candidate will perform the corresponding action.
Additionally, some actions are allowed in |visual-mode|. For example, if you
would like to stage all files, use "ggVG<<" to perform an "index:stage"
action on all candidates listed in the buffer.
*gina-usage-action-mark*
Actions in some buffer are defined as "markable", mean that users can mark
candidates by "builtin:mark" action and all further actions are applied to the
selected candidates (only when the action is defined to use marks).
In default, the follwoing mappings are provided.
mm Mark/Unmark the selection [nv]
m+ Mark the selection [nv]
m- Unmark the selection [nv]
m* Unmark all marks [n]
<C-j> Move to the below line and mark/unmark [n]
<C-k> Mark/Unmark the line and move to the above line [n]
Note that marks are removed after users call any actions.
*gina-usage-action-repeat*
You may want to repeat a previous action. In that case, use a "builtin:repeat"
action which is mapped to "." in default.
Note that actions executed from "builtin:choice" action become repeatable.
Note that some actions are not repeatable. While most of actions are
repeatable, there is no way to confirm if an action is repeatable or not for
now.
The "gina-status" buffer provides a lot more pre-defined actions and default
mappings.
To see what kind of actions and mappings are defined, hit "?" and a help
message like below will be displayed.
>
browse [browse] Bro..... <Plug>(gina-a...)[n]
...
a b..choice [choice] Sel..... <Plug>(gina-a...)[nvi]
? b..help [help] Sho..... <Plug>(gina-a...)[n]
...
<
Each columns in the message indicates
1. A keymap assigned to the action (e.g. ?)
2. An action full name (e.g. builtin:help)
3. An action alias used for completion (e.g. [help])
4. A description of an action
5. A <Plug> mapping for customization (e.g. <Plug>(gina-action-builtin-help))
6. A mapping mode which the <Plug> mapping supports (e.g. [n])
If you would like to define custom aliases or mappings, see the next section.
*gina-usage-action-mods*
Most of actions support command modifiers. For example, if you would like to
see a debug message on the action, prepend |verbose| modifier like
>
action: verbose show
<
When you hit <CR>, the "show" action will be executed with |verbose| modifier.
To customize the mark, users can use the followings
|g:gina#action#mark_sign_text|
|hl-GinaActionMarkSelected|
-----------------------------------------------------------------------------
COMPONENT *gina-usage-component*
Gina provides component functions which return a cached string for
|statusline| and/or |tabline|.
For example, if users want to show an information about the git repository,
they can use the following code to show it on a |statusline|.
>
set statusline=...%{gina#component#repo#preset()}...
<
Or if users prefer to use non ASCII characters, specify "fancy" to the
first attribute like:
>
set statusline=...%{gina#component#repo#preset('fancy')}...
<
Gina provides the following preset component functions
function description~
|gina#component#repo#preset()| A general information.
|gina#component#status#preset()| A current git status.
|gina#component#traffic#preset()| A traffic information.
If users want to control the looks of the component, they can use a raw
component functions like
>
set statusline=...%{MyGitStatus()}...
function MyGitStatus() abort
let staged = gina#component#status#staged()
let unstaged = gina#component#status#unstaged()
let conflicted = gina#component#status#conflicted()
return printf(
\ 's: %s, u: %s, c: %s',
\ staged,
\ unstaged,
\ conflicted,
\)
endfunction
<
Gina provides the following raw component functions
function description~
|gina#component#repo#name()| A name of the current git
repository. Namely, this is a
directory name of the git
repository top.
|gina#component#repo#branch()| A name of the current branch.
|gina#component#repo#track()| A name of the current tracking
branch.
|gina#component#status#staged()| A number of staged files.
|gina#component#status#unstaged()| A number of unstaged files.
|gina#component#status#conflicted()| A number of conflicted files.
|gina#component#traffic#ahead()| A number of commits ahead of
the tracking branch.
|gina#component#traffic#behind()| A number of commits behind of
the tracking branch.
Note that the values are cached to improve the performance.
See also
|g:gina#component#repo#commit_length|
=============================================================================
CUSTOM *gina-custom*
Users can customize the behavior by the following functions.
function description~
|gina#custom#action#alias()| Define an action alias on a specified
gina-xxxxx buffer
|gina#custom#action#shorten()| Alt. to |gina#custom#action#alias()|.
It removes a scheme prefix from a
specified action scheme.
|gina#custom#mapping#map()| Define a custom mapping on a
specified gina-xxxxx buffer
|gina#custom#mapping#nmap()| Alt. to |gina#custom#mapping#map()|.
This function use |nmap| internally.
|gina#custom#mapping#vmap()| Alt. to |gina#custom#mapping#map()|.
This function use |vmap| internally.
|gina#custom#mapping#imap()| Alt. to |gina#custom#mapping#map()|.
This function use |imap| internally.
|gina#custom#command#option()| Define a default option for a
specified :Gina xxxxx command
|gina#custom#command#alias()| Define a command alias for a
specified :Gina xxxxx command
|gina#custom#execute()| Execute a command on a specified
gina-xxxxx buffer
The first argument of these function is {scheme} which indicates a buffer
type or a command.
If you are not satisfied with the functions above, use |autocmd|, |ftplugin|, or
|ftplugin| in the |after| directory to do more complex customization.
-----------------------------------------------------------------------------
ACTION *gina-custom-action*
Assume that you want to add a custom action alias for checking out a remote
branch with tracking state ("commit:checkout:track" action) by "track".
In this case, use |gina#custom#action#alias()| function to define a custom
action alias for "gina-branch" buffer by
>
" Alias 'track' to 'commit:checkout:track'
call gina#custom#action#alias(
\ 'branch', 'track', 'commit:checkout:track',
\)
<
The function above only affect actions for "gina-branch" buffer. If you would
like to apply aliases to more than one buffer, use "/{pattern}" in {scheme}.
Assume that you want to add global custom action alias for opening a diff
content of a candidate in 'previewwindow' by "dp", add the following code
in your |.vimrc|
>
" Alias 'dp' to 'diff:preview' globally
call gina#custom#action#alias(
\ '/.*', 'dp', 'diff:preview'
\)
<
Note that the value of the {scheme} attribute starts from "/".
If the {scheme} is "/{pattern}", the value without a leading "/" is assumed
as a |pattern| and the function is applied to all buffer with the {pattern}.
*gina-custom-action-shorten*
gina provides an alternative function |gina#custom#action#shorten()| which is
used to define "short-form" aliases of actions. For example, the following
will define short-form aliases of "show".
>
call gina#custom#action#shorten('status', 'show')
<
The code above will define the following aliases
short-form alias action~
"show" "show"
"split" "show:split"
"vsplit" "show:vsplit"
"tab" "show:tab"
"preview" "show:preview"
If you want to exclude some actions to make aliases, specify the action names
to the third argument like
>
call gina#custom#action#shorten(
\ 'status',
\ 'show',
\ ['show:tab', 'show:preview']
\)
<
Then short-form aliases except for "show:tab" and "show:preview" will be
defined on "gina-status" buffer.
Note that "/{pattern}" is available on this function as well.
-----------------------------------------------------------------------------
MAPPING *gina-custom-mapping*
Assume that you want to add custom mappings for switching buffers between
"gina-status" and "gina-commit" by "<C-^>".
In this case, use |gina#custom#mapping#nmap()| function to define a custom
mapping for "gina-status" and "gina-commit" buffers by
>
" Execute :Gina commit with <C-^> on "gina-status" buffer
call gina#custom#mapping#nmap(
\ 'status', '<C-^>',
\ ':<C-u>Gina commit<CR>',
\ {'noremap': 1, 'silent': 1},
\)
" Execute :Gina status with <C-^> on "gina-commit" buffer
call gina#custom#mapping#nmap(
\ 'commit', '<C-^>',
\ ':<C-u>Gina status<CR>',
\ {'noremap': 1, 'silent': 1},
\)
<
The function above only affect mappings for "gina-status" and "gina-commit"
buffers. Use "/{pattern}" in {scheme} to apply mappings to more than one
buffer.
Assume that you want to add global custom mappings for opening a candidate in
a new tabpage by "g<CR>", add the following code in your |.vimrc|
>
" Use g<CR> to open a candidate on a new tabpage
call gina#custom#mapping#nmap(
\ '/.*', 'g<CR>',
\ '<Plug>(gina-edit-tab)'
\)
<
Note that the value of the {scheme} attribute starts from "/".
If the {scheme} is "/{pattern}", the value without a leading "/" is assumed
as a |pattern| and the function is applied to all buffer with the {pattern}.
To map aliases or actions with <mods>, use |gina#action#call()| function like:
>
" Use <Left> to open a candidate on a leftest
call gina#custom#mapping#nmap(
\ 'status', '<Left>',
\ ':call gina#action#call(''show:leftest'')<CR>',
\ {'noremap': 1, 'silent': 1},
\)
" Use g<Left> to open a candidate on a leftest with verbose
call gina#custom#mapping#nmap(
\ 'status', 'g<Left>',
\ ':call gina#action#call(''verbose show:leftest'')<CR>',
\ {'noremap': 1, 'silent': 1},
\)
<
-----------------------------------------------------------------------------
COMMAND *gina-custom-command*
Assume that you would like to always open a "gina-log" buffer with |vsplit|
rather than the default opener by |:Gina-log|.
In this case, use |gina#custom#command#option()| function to define a default
option for the "log" command by
>
call gina#custom#command#option('log', '--opener', 'vsplit')
<
Then gina will automatically add "--opener=vsplit" to ":Gina log" if a
corresponding option has not manually specified (":Gina log --opener=tabedit"
still works even with the above code).
The second argument of the function is called {query}. Users can specify
multiple options with a bar ("|") separated string like
>
call gina#custom#command#option('commit', '-v|--verbose')
<
In this case, the option "-v" and "--verbose" are assumed as a same option.
When user execute ":Gina commit", gina automatically add "--verbose" option
but when user execute ":Gina commit -v" or ":Gina commit --verbose", gina
ignore the default option defined above.
Additionally, if the option is for switch the feature like "--verbose" on
":Gina commit", users can remove the default option by adding "--no-{option}"
like
>
call gina#custom#command#option('commit', '-v|--verbose')
:Gina commit
" --> Open "gina-commit" with "--verbose" option
:Gina commit --no-verbose
" --> Open "gina-commit" without "--verbose" option
<
Note that this "--no-{option}" is only available for options which default
value is specified to 1 (or omitted).
Assume that you want to add "--opener=vsplit" for all commands which opens
a non file-like buffer. Then add the following code in your |.vimrc|
>
" Add "--opener=vsplit" to branch/changes/grep/log
call gina#custom#command#option(
\ '/\%(branch\|changes\|grep\|log\)',
\ '--opener', 'vsplit'
\)
<
Note that the value of the {scheme} attribute starts from "/".
If the {scheme} is "/{pattern}", the value without a leading "/" is assumed
as a |pattern| and the function is applied to all buffer with the {pattern}.
*gina-custom-command-alias*
Assume that you want to use "st" for "status" command.
In this case, use |gina#custom#command#alias()| function to define a custom
command alias for "status" command by
>
call gina#custom#command#alias('status', 'st')
<
Then ":Gina st" will execute ":Gina status" instead of ":Gina! st"
It's worth to know that the command alias has its own default option space,
mean that defalt options assigned to "status" by |gina#custom#command#option()|
does not affect the command alias "st" for example
>
call gina#custom#command#option('status', '--ignore-submodules')
call gina#custom#command#alias('status', 'st')
:Gina status
" --> Open "gina-status" with "--ignore-submodules"
:Gina st
" --> Open "gina-status" without "--ignore-submodules"
>
If you would like to make a command alias for a git raw command rather than
gina's command, assign 1 to the third argument like
>
call gina#custom#command#alias('status', 'st', 1)
:Gina st
[gina] On branch master
[gina] Your branch is up-to-date with 'origin/master'.
...
[gina]
[gina] no changes added to commit (use "git add" and/or "git ...
Note that "/{pattern}" for {scheme} cannot be used in this function.
-----------------------------------------------------------------------------
EXECUTE *gina-custom-execute*
This is a most powerful custom function which |execute| an arbital {expr} on a
{scheme} buffer.
Assume that you would like to set 'winfixheight' on "gina-status" buffer to
fix the window height. Then the following code would help you.
>
call gina#custom#execute('status', 'setlocal winfixheight')
<
As like other custom functions, "/{pattern}" is allowed for {scheme} so you
can perform "setlocal winfixwidth" in multiple buffers like
>
call gina#custom#execute(
\ '/\%(status\|branch\|grep\)',
\ 'setlocal winfixheight'
\)
<
This is the most powerful custom function so use it with great care.
-----------------------------------------------------------------------------
EXAMPLE *gina-custom-example*
The following is what I use for now to customize gina.
>
call gina#custom#command#alias('branch', 'br')
call gina#custom#command#option('br', '-v', 'v')
call gina#custom#command#option(
\ '/\%(log\|reflog\)',
\ '--opener', 'vsplit'
\)
call gina#custom#command#option(
\ 'log', '--group', 'log-viewer'
\)
call gina#custom#command#option(
\ 'reflog', '--group', 'reflog-viewer'
\)
call gina#custom#command#option(
\ 'commit', '-v|--verbose'
\)
call gina#custom#command#option(
\ '/\%(status\|commit\)',
\ '-u|--untracked-files'
\)
call gina#custom#command#option(
\ '/\%(status\|changes\)',
\ '--ignore-submodules'
\)
call gina#custom#action#alias(
\ 'branch', 'track',
\ 'checkout:track'
\)
call gina#custom#action#alias(
\ 'branch', 'merge',
\ 'commit:merge'
\)
call gina#custom#action#alias(
\ 'branch', 'rebase',
\ 'commit:rebase'
\)
call gina#custom#mapping#nmap(
\ 'branch', 'g<CR>',
\ '<Plug>(gina-commit-checkout-track)'
\)
call gina#custom#mapping#nmap(
\ 'status', '<C-^>',
\ ':<C-u>Gina commit<CR>',
\ {'noremap': 1, 'silent': 1}
\)
call gina#custom#mapping#nmap(
\ 'commit', '<C-^>',
\ ':<C-u>Gina status<CR>',
\ {'noremap': 1, 'silent': 1}
\)
call gina#custom#execute(
\ '/\%(status\|branch\|ls\|grep\|changes\|tag\)',
\ 'setlocal winfixheight',
\)
<
Latest version:~
"home/.config/nvim/rc.d/gina.vim" on https://github.com/lambdalisue/rook/
=============================================================================
BUFFER *gina-buffer*
gina uses two kind of buffers internally. One is called a "file-like" buffer
and another is called "non file-like" buffer.
The main difference between "file-like" and "non file-like" is options.
Some options are forcedly assigned by the command (upper part) and other
options are defined in a corresponding |ftplugin| (lower part).
The following table visualize the difference of options between file-like and
non file-like ("?" in the table indicates the default value)
option file-like non file-like~
'buftype' nowrite nofile
'bufhidden' ? hide
'swapfile' ? 0
'modifiable' 0 0
option file-like non file-like~
'buflisted' 1 0
'list' ? 0
'spell' ? 0
'wrap' ? 0
'foldenable' ? 0
'number' ? 0
'relativenumber' ? 0
'foldcolumn' ? 0
'colorcolumn' ? 0
If you are not satisfied with this options, use a |ftplugin| in an |after|
directory to overwrite.
Additinal difference is |gina-actions|. Most of "non file-like" buffer
pre-define some actions while non of "file-like" buffer does.
*gina-buffer-naming*
A buffer which shown by gina is one of the following
gina://{refname}:{scheme}[:{params}]
gina://{refname}:{scheme}[:{params}]/{rev}
gina://{refname}:{scheme}[:{params}]/{treeish}
Where
{refname} An unique name for a git repository
e.g. "gina.vim"
{scheme} A command scheme
e.g. "status", "commit"
{params} Optional parameters splitted by ":"
e.g. "cached", "cached:--"
{rev} A target revision
e.g. "HEAD", "master"
{treeish} A target treeish which is {rev}:{path}
e.g. "HEAD:README.md", ":autoload/gina.vim"
When a command supports filtering candidates by "-- {pathspec}..." and the
filteration has performed, "--" is applied to {params} like
>
:Gina log
" --> Open gina://xxxxx:log for entire log
:Gina log -- **/*.vim
" --> Open gina://xxxxx:log:-- for filtered log
<
The {treeish} is similar to the one used in "git show" command.
See |gina-misc-treeish| for the detail about {treeish}
*gina-buffer-+cmd*
When a buffer is opend by gina, [+cmd] specified to the command is recognized
and performed. See ":h +cmd" for the detail.
*gina-buffer-++opt*
When a buffer is opend by gina, [++opt] specified to the command is recognized
and respected. Users can use this feature to open a buffer with a particular
encoding or format like
>
:Gina show ++enc=sjis ++ff=mac HEAD:README.md
" --> Open README.md in HEAD with sjis/mac
<
See ":h ++opt" for more detail.
Note that automatical detection by 'fileencodings' or 'fileformats' are not
supported. Upvote https://github.com/lambdalisue/gina.vim/issues/24 if need.
-----------------------------------------------------------------------------
BLAME *gina-buffer-blame*
{scheme}: blame
'filetype': gina-blame
This is a "non file-like" buffer which is shown by |:Gina-blame| command.
It shows a content of the file with a blame navigator looks like (note that
SHA1 indicators are represented as a shade block but it is colored columns in
real world)
>
Navigation buffer Content buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
Add badges o... on yesterday ░ | ![...](...)
Add badges o... on yesterday ░ | ![...](...)
...
Initial commit on 14, Feb | FOOBAR HOGEHOGE
Some refactoring on today |█ | ![...](...)
│ │ ││
│ │ │└ SHA1 indicator column(s) (N chars)
│ │ └ Current revision mark
│ └ Timestamp (relative or absolute)
└ Commit summary
<
Continuous lines with a same revision (commit) is called a "chunk". Not like
a git raw blame command, gina does not show a revision of each chunks/lines.
Instead, gina uses SHA1 indicator column(s) to distinguish revisions.
SHA1 indicator column(s) is a colored column or combinations of colored
columns which indicate an unique revision in a blame content. The number of
columns used to indicate a single revision is determined from the total
numbers of revisions shown in a blame content. Namely, same colored column or
same colored columns combination indicate a same revision so that users can
easily distinguish which lines are continuous or which chunks are equal.
When a revision of a chunk is equal to a revision of a blame content, a
current revision mark (default is "|") is shown just next to the SHA1
indicator. In this case, "blame:open" action would open a related parent
commit if exists rather than the commit itself.
The navigation content is width dependent. When the window width of the
"gina-blame" buffer has changed, the content will be redrawn when
- Users hit <C-L> (<Plug>(gina-blame-C-L))
- Focus is moved from/to the buffer (|WinLeave| or |WinEnter|)
- Vim's window is resized (|VimResized|)
In this buffer, users can use the following action groups.
|gina-actions-blame| (shorten)
|gina-actions-browse|
|gina-actions-changes|
|gina-actions-compare|
|gina-actions-diff|
|gina-actions-ls|
|gina-actions-show|
|gina-actions-yank|
And the following <Plug> mappings additional to the <Plug> mappings comes from
actions above
<Plug>(gina-blame-redraw) Redraw content with the current width
<Plug>(gina-blame-C-L) Redraw content and <C-L> to refresh
And the following default keymappings
<Return> Open a blame with the selected chunk
<Backspace> Back to navigationally historical previous blame
<C-L> Redraw content and <C-L> to refresh
Users can disable the default aliases (shorten) and/or mappings by
|g:gina#command#blame#use_default_aliases|
|g:gina#command#blame#use_default_mappings|
Additionally, users can customize the content via the following variables.
|g:gina#command#blame#formatter#format|
|g:gina#command#blame#formatter#separator|
|g:gina#command#blame#formatter#current_mark|
|g:gina#command#blame#formatter#timestamp_months|
|g:gina#command#blame#formatter#timestamp_format1|
|g:gina#command#blame#formatter#timestamp_format2|
>
The following is a recommended customization while gina does not show exact
SHA1 of the revision of the chunk.
>
" Echo chunk info with j/k
call gina#custom#mapping#nmap(
\ 'blame', 'j',
\ 'j<Plug>(gina-blame-echo)'
\)
call gina#custom#mapping#nmap(
\ 'blame', 'k',
\ 'k<Plug>(gina-blame-echo)'
\)
<
The above may influence the performance so it is not defined in default.
-----------------------------------------------------------------------------
BRANCH *gina-buffer-branch*
{scheme}: branch
'filetype': gina-branch
'autoread': 1
This is a "non file-like" buffer which is shown by |:Gina-branch| command.
In this buffer, users can use the following action groups.
|gina-actions-branch| (shorten)
|gina-actions-browse|
|gina-actions-changes|
|gina-actions-commit|
"commit:checkout" is aliased to "checkout"
"commit:checkout:track" is aliased to "checkout:track"
|gina-actions-ls|
|gina-actions-show|
|gina-actions-yank|
And the following default keymappings
<Return> Checkout a branch (detached head for remote)
Users can disable the default aliases (shorten) and/or mappings by
|g:gina#command#branch#use_default_aliases|
|g:gina#command#branch#use_default_mappings|
Note that actions are defined as "markable" in this buffer.
See |gina-usage-action-mark| for the detail.
-----------------------------------------------------------------------------
CHANGES *gina-buffer-changes*
{scheme}: changes
'filetype': gina-changes
This is a "non file-like" buffer which is shown by |:Gina-changes| command.
In this buffer, users can use the following action groups.
|gina-actions-browse|
|gina-actions-compare|
|gina-actions-diff|
|gina-actions-edit| (shorten)
|gina-actions-show|
|gina-actions-yank|
And the following default keymappings are defined
<Return> Edit a file
dd Open a unified-diff
DD Open a unified-diff (vsplit)
cc Open two buffers to compare
CC Open two buffers to compare (tab)
Users can disable the default aliases (shorten) and/or mappings by
|g:gina#command#changes#use_default_aliases|
|g:gina#command#changes#use_default_mappings|
-----------------------------------------------------------------------------
COMMIT *gina-buffer-commit*
{scheme}: commit
'filetype': gina-commit
This is a "non file-like" buffer which is shown by |:Gina-commit| command.
When users save a content with |:write| command, the content is cached.
To read from content and discard the current modification which has not cached
yet, use |:edit!|. Note that there are two content cache exist. One for commit
without "--amend" and another for commit with "--amend".
When users close the buffer with |:quit| command, users will be asked if they
want to commit the changes like
>
[gina] Do you want to commit changes? [Y(es)/n(o)]
<
"Y" is capital mean that if user hit <Return> without answering, that mean
"Yes". If user type "n" or "no" and hit <Return>, the commit is canceled.
Note that if users cache the content with |:w|, the cached message will be used
when users open a "gina-commit" buffer again.
When users close the buffer with |:wq| command, no confirmation prompt will
appear and the commit is immediately performed.
When users close the buffer with |:q!| command, no confirmation prompt will
appear and the commit is canceled.
Note that no actions are available on this buffer.
The following <Plug> mapping is available on this buffer
<Plug>(gina-commit-amend) Toggle "--amend" option
<Plug>(gina-diff-jump) Jump to a corresponding file with a
corresponding line number.
If jumps to the source file when the
cursor is on removed line (the line
starts from '-') or destination file
when the cursor is on non modified or
added line (the line starts from ' '
or '+').
Works only on diff content visibled
when '-v' or '--verbose' option is
specified.
And the following default keymapping is defined
! Switch --amend option
<Return> Jump to a corresponding file
Users can disable the default mappings by
|g:gina#command#commit#use_default_mappings|
-----------------------------------------------------------------------------
DIFF *gina-buffer-diff*
{scheme}: diff
'filetype': diff
This is a "file-like" buffer which is shown by |:Gina-diff| command.
The following <Plug> mapping is available on this buffer
<Plug>(gina-diff-jump) Jump to a corresponding file with a
corresponding line number.
If jumps to the source file when the
cursor is on removed line (the line
starts from '-') or destination file
when the cursor is on non modified or
added line (the line starts from ' '
or '+')
And the following default keymapping is defined
<Return> Jump to a corresponding file
Users can disable the default mappings by
|g:gina#command#diff#use_default_mappings|
Note that no actions are available on this buffer.
-----------------------------------------------------------------------------
GREP *gina-buffer-grep*
{scheme}: grep
'filetype': gina-grep
This is a "non file-like" buffer which is shown by |:Gina-grep| command.
The aliases of actions and default mappings are rely on {rev} part of the
buffer name (|gina-buffer-naming|).
In this buffer, users can use the following action groups.
|gina-actions-browse|
|gina-actions-compare|
|gina-actions-diff|
|gina-actions-edit| (shorten when {rev} is missing)
|gina-actions-export|
|gina-actions-ls|
|gina-actions-show| (shorten when {rev} exists)
|gina-actions-yank|
And the following default keymappings are defined
<Return> Edit/Show a file (depends on {rev})
Users can disable the default aliases (shorten) and/or mappings by
|g:gina#command#qrep#use_default_aliases|
|g:gina#command#qrep#use_default_mappings|
Note that actions are defined as "markable" in this buffer.
See |gina-usage-action-mark| for the detail.
-----------------------------------------------------------------------------
LOG *gina-buffer-log*
{scheme}: log
'filetype': gina-log