Skip to content

Commit 1856f03

Browse files
authored
Merge pull request #464 from brandon1024/syntax-leader
introduce separate syntax group for leader symbol
2 parents 4841c88 + e1857a8 commit 1856f03

File tree

2 files changed

+61
-49
lines changed

2 files changed

+61
-49
lines changed

autoload/fern/renderer/default.vim

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,26 @@ function! s:lnum(index) abort
3838
endfunction
3939

4040
function! s:syntax() abort
41-
syntax match FernLeaf /^.*[^/].*$/ transparent contains=FernLeafSymbol
42-
syntax match FernBranch /^.*\/.*$/ transparent contains=FernBranchSymbol
41+
syntax match FernLeaf /^.*[^/].*$/ transparent contains=FernLeaderSymbol
42+
syntax match FernBranch /^.*\/.*$/ transparent contains=FernLeaderSymbol
4343
syntax match FernRoot /\%1l.*/ transparent contains=FernRootSymbol
4444
execute printf(
4545
\ 'syntax match FernRootSymbol /%s/ contained nextgroup=FernRootText',
4646
\ escape(g:fern#renderer#default#root_symbol, s:ESCAPE_PATTERN),
4747
\)
4848
execute printf(
49-
\ 'syntax match FernLeafSymbol /^\%%(%s\)*%s/ contained nextgroup=FernLeafText',
50-
\ escape(g:fern#renderer#default#leading, s:ESCAPE_PATTERN),
49+
\ 'syntax match FernLeafSymbol /%s/ contained nextgroup=FernLeafText',
5150
\ escape(g:fern#renderer#default#leaf_symbol, s:ESCAPE_PATTERN),
5251
\)
5352
execute printf(
54-
\ 'syntax match FernBranchSymbol /^\%%(%s\)*\%%(%s\|%s\)/ contained nextgroup=FernBranchText',
55-
\ escape(g:fern#renderer#default#leading, s:ESCAPE_PATTERN),
53+
\ 'syntax match FernBranchSymbol /\%%(%s\|%s\)/ contained nextgroup=FernBranchText',
5654
\ escape(g:fern#renderer#default#collapsed_symbol, s:ESCAPE_PATTERN),
5755
\ escape(g:fern#renderer#default#expanded_symbol, s:ESCAPE_PATTERN),
5856
\)
57+
execute printf(
58+
\ 'syntax match FernLeaderSymbol /^\%%(%s\)*/ contained nextgroup=FernBranchSymbol,FernLeafSymbol',
59+
\ escape(g:fern#renderer#default#leading, s:ESCAPE_PATTERN),
60+
\)
5961
syntax match FernRootText /.*\ze.*$/ contained nextgroup=FernBadgeSep
6062
syntax match FernLeafText /.*\ze.*$/ contained nextgroup=FernBadgeSep
6163
syntax match FernBranchText /.*\ze.*$/ contained nextgroup=FernBadgeSep
@@ -71,6 +73,7 @@ function! s:highlight() abort
7173
highlight default link FernLeafText None
7274
highlight default link FernBranchSymbol Directory
7375
highlight default link FernBranchText Directory
76+
highlight default link FernLeaderSymbol Directory
7477
endfunction
7578

7679
function! s:render_node(node, base, options) abort

doc/fern.txt

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,38 @@ No external dependencies~
4646
https://github.com/lambdalisue/vital-Whisky/issues/31
4747

4848
Asynchronous~
49-
Fern uses asynchronous technique to perform most of operations so Vim
50-
would not freeze during operations. It is probably obvious in Windows
49+
Fern uses asynchronous technique to perform most of operations so Vim
50+
would not freeze during operations. It is probably obvious in Windows
5151
while file operations in Windows are relatively slow.
5252

5353
Split windows or project drawer~
5454
Fern supports both styles; split windows (e.g. netrw) and project
5555
drawer (e.g. NERDTree); officially.
5656

5757
Buffer name base~
58-
Fern is developed based on |BufReadCmd| technique like netrw. Thus any
59-
buffer starts from "fern://" are handled by fern and required
60-
arguments and options are read from the buffer name. That's why fern
58+
Fern is developed based on |BufReadCmd| technique like netrw. Thus any
59+
buffer starts from "fern://" are handled by fern and required
60+
arguments and options are read from the buffer name. That's why fern
6161
integrate well with |session|.
6262

6363
Action~
6464
Fern provides operation as action. When user hit "?", all actions and
65-
corresponding mapping (if exist) are shown. When user hit "a", an
65+
corresponding mapping (if exist) are shown. When user hit "a", an
6666
action prompt will popped up and user can input an action to execute.
67-
So users don't have to remember complex mappings to execute operation
67+
So users don't have to remember complex mappings to execute operation
6868
which is not often required.
6969

7070
Window selector~
71-
Fern has an internal window selector which works like
72-
t9md/vim-choosewin. Users can quickly select which window to open a
71+
Fern has an internal window selector which works like
72+
t9md/vim-choosewin. Users can quickly select which window to open a
7373
selected node.
7474
See |hl-FernWindowSelectIndicator| and |hl-FernWindowSelectStatusLine|
7575
to customize the statusline when selecting a window.
7676
https://github.com/t9md/vim-choosewin
7777

7878
Renamer (A.k.a exrename)~
7979
Fern has an internal renamer which works like "exrename" in
80-
Shougo/vimfiler. Users can edit multiple path of nodes in Vim's
80+
Shougo/vimfiler. Users can edit multiple path of nodes in Vim's
8181
buffer and ":w" to apply changes to actual nodes (file, directory,
8282
bookmark, etc.)
8383
https://github.com/Shougo/vimfiler
@@ -88,13 +88,13 @@ System CRUD operations ("file" scheme)~
8888

8989
System program support ("file" scheme)~
9090
Fern supports to open a file/directory through a system default
91-
program. So it's quite easy to open a directory with Explorer
91+
program. So it's quite easy to open a directory with Explorer
9292
(Windows), Finder (macOS), or whatever.
9393

9494
System trash-bin support ("file" scheme)~
95-
Fern supports system trash-bin by PowerShell (Windows), osascript
96-
(macOS), and 3rd party applications (Linux). Any files/directories
97-
deleted by "trash" action are sent to system trash-bin rather than
95+
Fern supports system trash-bin by PowerShell (Windows), osascript
96+
(macOS), and 3rd party applications (Linux). Any files/directories
97+
deleted by "trash" action are sent to system trash-bin rather than
9898
actual delete.
9999

100100
-----------------------------------------------------------------------------
@@ -504,7 +504,7 @@ VARIABLE *fern-variable*
504504
| | |
505505
+---------------+---------------+
506506
<
507-
Default: 0
507+
Default: 0
508508

509509
*g:fern#default_hidden*
510510
Set 1 to enter hidden mode (show hidden files) in default.
@@ -611,7 +611,7 @@ COMMAND *fern-command*
611611
the specified value. (See |g:fern#drawer_width|)
612612
If "-keep" option is specified, the buffer won't close even if only
613613
this window exists. (See |g:fern#drawer_keep|)
614-
If "-toggle" option is specified, an existing fern buffer will be
614+
If "-toggle" option is specified, an existing fern buffer will be
615615
closed rather than opening a new one.
616616
If "-right" option is specified, the drawer is placed on the right
617617
side.
@@ -745,32 +745,41 @@ FernMarkedText *hl-FernMarkedText*
745745

746746
FernRootSymbol *hl-FernRootSymbol*
747747
A |highlight| group of renderer used for root node symbol.
748-
An actual appearance will be determined by the |fern-renderer| thus
748+
An actual appearance will be determined by the |fern-renderer| thus
749749
this highlight might not be referred.
750-
750+
751751
FernRootText *hl-FernRootText*
752752
A |highlight| group of renderer used for root node text.
753-
An actual appearance will be determined by the |fern-renderer| thus
753+
An actual appearance will be determined by the |fern-renderer| thus
754754
this highlight might not be referred.
755755

756756
FernLeafSymbol *hl-FernLeafSymbol*
757757
A |highlight| group of renderer used for leaf node symbol.
758-
An actual appearance will be determined by the |fern-renderer| thus
758+
See |g:fern#renderer#default#leaf_symbol|.
759+
An actual appearance will be determined by the |fern-renderer| thus
759760
this highlight might not be referred.
760-
761+
761762
FernLeafText *hl-FernLeafText*
762763
A |highlight| group of renderer used for leaf node text.
763-
An actual appearance will be determined by the |fern-renderer| thus
764+
An actual appearance will be determined by the |fern-renderer| thus
764765
this highlight might not be referred.
765766

766767
FernBranchSymbol *hl-FernBranchSymbol*
767768
A |highlight| group of renderer used for branch node symbol.
768-
An actual appearance will be determined by the |fern-renderer| thus
769+
See |g:fern#renderer#default#expanded_symbol| and
770+
|g:fern#renderer#default#collapsed_symbol|.
771+
An actual appearance will be determined by the |fern-renderer| thus
769772
this highlight might not be referred.
770-
773+
771774
FernBranchText *hl-FernBranchText*
772775
A |highlight| group of renderer used for branch node text.
773-
An actual appearance will be determined by the |fern-renderer| thus
776+
An actual appearance will be determined by the |fern-renderer| thus
777+
this highlight might not be referred.
778+
779+
FernLeaderSymbol *hl-FernLeaderSymbol*
780+
A |highlight| group of renderer used for the node leading symbol.
781+
See |g:fern#renderer#default#leading|.
782+
An actual appearance will be determined by the |fern-renderer| thus
774783
this highlight might not be referred.
775784

776785
FernWindowSelectIndicator *hl-FernWindowSelectIndicator*
@@ -810,7 +819,7 @@ GLOBAL *fern-mapping-global*
810819
*<Plug>(fern-action-hidden:set)*
811820
Show hidden nodes. For example hidden nodes in file:// scheme is a
812821
file or directory starts from '.' character.
813-
822+
814823
*<Plug>(fern-action-hidden:unset)*
815824
Hide hidden nodes. For example hidden nodes in file:// scheme is a
816825
file or directory starts from '.' character.
@@ -860,7 +869,7 @@ GLOBAL *fern-mapping-global*
860869
Toggle marks on cursor node(s).
861870

862871
*<Plug>(fern-action-mark)*
863-
An alias to "mark:toggle" action. Users can overwrite this mapping to
872+
An alias to "mark:toggle" action. Users can overwrite this mapping to
864873
change the default behavior of "mark" action.
865874

866875
*<Plug>(fern-action-debug)*
@@ -876,7 +885,7 @@ GLOBAL *fern-mapping-global*
876885
An alias to "reload:all" action. Users can overwrite this mapping to
877886
change the default behavior of "reload" action like:
878887
>
879-
nmap <buffer>
888+
nmap <buffer>
880889
\ <Plug>(fern-action-reload)
881890
\ <Plug>(fern-action-reload:cursor)
882891
<
@@ -891,7 +900,7 @@ GLOBAL *fern-mapping-global*
891900
An alias to "expand:in" action. Users can overwrite this mapping to
892901
change the default behavior of "expand" action like:
893902
>
894-
nmap <buffer>
903+
nmap <buffer>
895904
\ <Plug>(fern-action-expand)
896905
\ <Plug>(fern-action-expand:stay)
897906
<
@@ -918,7 +927,7 @@ GLOBAL *fern-mapping-global*
918927
word, get enter the directory.
919928

920929
*<Plug>(fern-action-leave)*
921-
Open a new fern buffer which root node is a parent node of the current
930+
Open a new fern buffer which root node is a parent node of the current
922931
root node. In other word, go up directory.
923932

924933
*<Plug>(fern-action-open:select)*
@@ -938,7 +947,7 @@ GLOBAL *fern-mapping-global*
938947

939948
*<Plug>(fern-action-open:edit-or-error)*
940949
Open a cursor node or marked nodes with |edit| command or fallback
941-
to print an error.
950+
to print an error.
942951
Note that when 'hidden' has set or 'bufhidden' is "hide", the |edit|
943952
command will never fails.
944953

@@ -985,15 +994,15 @@ GLOBAL *fern-mapping-global*
985994
An alias to "open:edit-or-error" action. Users can overwrite this
986995
mapping to change the default behavior of "open:edit" action like:
987996
>
988-
nmap <buffer>
997+
nmap <buffer>
989998
\ <Plug>(fern-action-open:edit)
990999
\ <Plug>(fern-action-open:edit-or-tabedit)
9911000
<
9921001
*<Plug>(fern-action-open)*
9931002
An alias to "open:edit" action. Users can overwrite this mapping to
9941003
change the default behavior of "open" action like:
9951004
>
996-
nmap <buffer>
1005+
nmap <buffer>
9971006
\ <Plug>(fern-action-open)
9981007
\ <Plug>(fern-action-open:select)
9991008
<
@@ -1029,7 +1038,7 @@ GLOBAL *fern-mapping-global*
10291038
*<Plug>(fern-action-diff:edit-or-vsplit:vert)*
10301039
*<Plug>(fern-action-diff:edit-or-tabedit)*
10311040
*<Plug>(fern-action-diff:edit-or-tabedit:vert)*
1032-
Open a first marked node with |edit| command or fallback to a
1041+
Open a first marked node with |edit| command or fallback to a
10331042
corresponding command then .
10341043
Note that when 'hidden' has set or 'bufhidden' is "hide", the |edit|
10351044
command will never fails.
@@ -1074,15 +1083,15 @@ GLOBAL *fern-mapping-global*
10741083
An alias to "diff:edit-or-error" action. Users can overwrite this
10751084
mapping to change the default behavior of "diff:edit" action like:
10761085
>
1077-
nmap <buffer>
1086+
nmap <buffer>
10781087
\ <Plug>(fern-action-diff:edit)
10791088
\ <Plug>(fern-action-diff:edit-or-tabedit)
10801089
<
10811090
*<Plug>(fern-action-diff)*
10821091
An alias to "diff:edit" action. Users can overwrite this mapping to
10831092
change the default behavior of "diff" action like:
10841093
>
1085-
nmap <buffer>
1094+
nmap <buffer>
10861095
\ <Plug>(fern-action-diff)
10871096
\ <Plug>(fern-action-diff:select)
10881097
<
@@ -1101,15 +1110,15 @@ GLOBAL *fern-mapping-global*
11011110
An alias to "yank:bufname" action. Users can overwrite this mapping to
11021111
change the default behavior of "yank" action like:
11031112
>
1104-
nmap <buffer>
1113+
nmap <buffer>
11051114
\ <Plug>(fern-action-yank)
11061115
\ <Plug>(fern-action-yank:label)
11071116
<
11081117
Note that this mapping is overwritten in FILE scheme.
11091118

11101119
*<Plug>(fern-wait)*
1111-
Wait until the fern buffer become ready which would opened just before
1112-
this mapping. This is required while fern buffers are loaded
1120+
Wait until the fern buffer become ready which would opened just before
1121+
this mapping. This is required while fern buffers are loaded
11131122
asynchronously but mappings are inovked synchronously.
11141123
Note this is not action.
11151124

@@ -1121,7 +1130,7 @@ The following mappings/actions are only available on file:// scheme.
11211130

11221131
*<Plug>(fern-action-ex)*
11231132
*<Plug>(fern-action-ex=)*
1124-
Open a prompt to execute an Ex command with a path of cursor node or
1133+
Open a prompt to execute an Ex command with a path of cursor node or
11251134
paths of marked nodes.
11261135
You can use a "=" variant to apply values to the prompt and/or submit
11271136
a value like:
@@ -1161,7 +1170,7 @@ The following mappings/actions are only available on file:// scheme.
11611170
<
11621171
*<Plug>(fern-action-new-dir)*
11631172
*<Plug>(fern-action-new-dir=)*
1164-
Open a prompt to ask a path and create a directory of the input path
1173+
Open a prompt to ask a path and create a directory of the input path
11651174
from the path of a cursor node.
11661175
Any intermediate directories of the destination will be created.
11671176
You can use a "=" variant to apply values to the prompt and/or submit
@@ -1234,7 +1243,7 @@ The following mappings/actions are only available on file:// scheme.
12341243
An alias to "cd:cursor", "lcd:cursor", and "tcd:cursor" action.
12351244
Users can overwrite this mapping to change the default behavior like:
12361245
>
1237-
nmap <buffer>
1246+
nmap <buffer>
12381247
\ <Plug>(fern-action-cd)
12391248
\ <Plug>(fern-action-cd:root)
12401249
<
@@ -1317,7 +1326,7 @@ The following mappings/actions are only available on file:// scheme.
13171326
*<Plug>(fern-action-terminal:edit)*
13181327
*<Plug>(fern-action-terminal:side)*
13191328
*<Plug>(fern-action-terminal)*
1320-
Open terminal window(s) on or on parent of a cursor node or marked
1329+
Open terminal window(s) on or on parent of a cursor node or marked
13211330
nodes in similar manners of global "open" actions.
13221331

13231332
*<Plug>(fern-action-yank:path)*

0 commit comments

Comments
 (0)