Skip to content

Commit 3d5da30

Browse files
committed
Add FernHighlight/FernSyntax autocmd and document
1 parent 393715b commit 3d5da30

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

autoload/fern/internal/viewer.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,18 @@ function! s:init() abort
6767
call fern#internal#drawer#init()
6868
call fern#internal#spinner#start()
6969
call helper.fern.renderer.highlight()
70+
" Notify plugins
7071
call fern#hook#emit('renderer:highlight', helper)
72+
" Notify users
73+
doautocmd <nomodeline> User FernHighlight
7174

7275
" now the buffer is ready so set filetype to emit FileType
7376
setlocal filetype=fern
7477
call helper.fern.renderer.syntax()
78+
" Notify plugins
7579
call fern#hook#emit('renderer:syntax', helper)
80+
" Notify users
81+
doautocmd <nomodeline> User FernSyntax
7682
call fern#internal#action#init()
7783

7884
let reveal = split(fri.fragment, '/')
@@ -108,7 +114,10 @@ function! s:BufReadCmd() abort
108114
let helper = fern#helper#new()
109115
setlocal filetype=fern
110116
call helper.fern.renderer.syntax()
117+
" Notify plugins
111118
call fern#hook#emit('renderer:syntax', helper)
119+
" Notify users
120+
doautocmd <nomodeline> User FernSyntax
112121
let root = helper.sync.get_root_node()
113122
let cursor = get(b:, 'fern_cursor', getcurpos())
114123
call s:Promise.resolve()
@@ -123,5 +132,14 @@ endfunction
123132
function! s:ColorScheme() abort
124133
let helper = fern#helper#new()
125134
call helper.fern.renderer.highlight()
135+
" Notify plugins
126136
call fern#hook#emit('renderer:highlight', helper)
137+
" Notify users
138+
doautocmd <nomodeline> User FernHighlight
127139
endfunction
140+
141+
augroup fern-internal-viewer-internal
142+
autocmd!
143+
autocmd User FernSyntax :
144+
autocmd User FernHighlight :
145+
augroup END

doc/fern.txt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ INTERFACE |fern-interface|
1717
VARIABLE |fern-variable|
1818
COMMAND |fern-command|
1919
FUNCTION |fern-function|
20+
AUTOCMD |fern-autocmd|
21+
HIGHLIGHT |fern-highlight|
2022
CHANGELOG |fern-changelog|
2123

2224

@@ -272,6 +274,8 @@ Users can customize above appearance by the following variables.
272274
OBSOLETE(v1.6.0)~
273275
No alternative feature is provided.
274276

277+
See |FernHighlight| and |fern-highlight| to change pre-defeined |highlight|.
278+
275279
Or create user custom renderer to change the appearance completely.
276280
See |fern-develop-renderer| for more details.
277281

@@ -548,7 +552,74 @@ fern#smart#scheme({default}, {schemes})
548552
\ 'bookmark': "\<C-^>",
549553
\ },
550554
\ )
555+
556+
-----------------------------------------------------------------------------
557+
AUTOCMD *fern-autocmd*
558+
559+
*FernHighlight*
560+
FernHighlight
561+
Invoked after a fern renderer and 3rd party plugins defined highlight.
562+
Use this autocmd to overwrite existing |highlight| like:
563+
>
564+
function! s:on_highlight() abort
565+
" Use brighter highlight on root node
566+
highlight link FernRootSymbol Title
567+
highlight link FernRootText Title
568+
endfunction
569+
570+
augroup my-fern-highlight
571+
autocmd!
572+
autocmd User FernHighlight call s:on_highlight()
573+
augroup END
551574
<
575+
See |fern-highlight| for pre-defined |highlight|.
576+
577+
*FernSyntax*
578+
FernSyntax
579+
Invoked after a fern renderer and 3rd party plugins defined syntax.
580+
Use this |autocmd| to overwrite existing |syntax|.
581+
Note that if you'd like to change color/highlight, use |FernHighlight|
582+
autocmd instead. This autocmd exists for more complex (heavy) use.
583+
584+
-----------------------------------------------------------------------------
585+
HIGHLIGHT *fern-highlight*
586+
587+
FernMarkedLine *hl-FernMarkedLine*
588+
A |highlight| group used as a line highlight of mark |sign|.
589+
590+
FernMarkedText *hl-FernMarkedText*
591+
A |highlight| group used as a text highlight of mark |sign|.
592+
593+
FernRootSymbol *hl-FernRootSymbol*
594+
A |highlight| group of renderer used for root node symbol.
595+
An actual appearance will be determined by the |fern-renderer| thus
596+
this highlight might not be referred.
597+
598+
FernRootText *hl-FernRootText*
599+
A |highlight| group of renderer used for root node text.
600+
An actual appearance will be determined by the |fern-renderer| thus
601+
this highlight might not be referred.
602+
603+
FernLeafSymbol *hl-FernLeafSymbol*
604+
A |highlight| group of renderer used for leaf node symbol.
605+
An actual appearance will be determined by the |fern-renderer| thus
606+
this highlight might not be referred.
607+
608+
FernLeafText *hl-FernLeafText*
609+
A |highlight| group of renderer used for leaf node text.
610+
An actual appearance will be determined by the |fern-renderer| thus
611+
this highlight might not be referred.
612+
613+
FernBranchSymbol *hl-FernBranchSymbol*
614+
A |highlight| group of renderer used for branch node symbol.
615+
An actual appearance will be determined by the |fern-renderer| thus
616+
this highlight might not be referred.
617+
618+
FernBranchText *hl-FernBranchText*
619+
A |highlight| group of renderer used for branch node text.
620+
An actual appearance will be determined by the |fern-renderer| thus
621+
this highlight might not be referred.
622+
552623

553624
=============================================================================
554625
CHANGELOG *fern-changelog*

0 commit comments

Comments
 (0)