Skip to content

Commit 398e34b

Browse files
authored
Merge pull request #397 from lambdalisue/fix-syntax
Use `syntax/fern.vim` instead to define syntax/highlight
2 parents d2ceaeb + c5a11af commit 398e34b

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

autoload/fern/internal/viewer.vim

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ function! s:init() abort
5757
autocmd! * <buffer>
5858
autocmd BufEnter <buffer> setlocal nobuflisted
5959
autocmd BufReadCmd <buffer> nested call s:BufReadCmd()
60-
autocmd Syntax <buffer> call s:Syntax()
61-
autocmd ColorScheme <buffer> call s:ColorScheme()
6260
autocmd CursorMoved,CursorMovedI,BufLeave <buffer> let b:fern_cursor = getcurpos()[1:2]
6361
augroup END
6462
call fern#internal#viewer#auto_duplication#init()
@@ -94,9 +92,6 @@ function! s:init() abort
9492
if !g:fern#disable_viewer_spinner
9593
call fern#internal#spinner#start()
9694
endif
97-
call helper.fern.renderer.highlight()
98-
call fern#hook#emit('viewer:highlight', helper)
99-
doautocmd <nomodeline> User FernHighlight
10095

10196
" now the buffer is ready so set filetype to emit FileType
10297
setlocal filetype=fern
@@ -139,20 +134,6 @@ function! s:BufReadCmd() abort
139134
\.catch({ e -> fern#logger#error(e) })
140135
endfunction
141136

142-
function! s:Syntax() abort
143-
let helper = fern#helper#new()
144-
call helper.fern.renderer.syntax()
145-
call fern#hook#emit('viewer:syntax', helper)
146-
doautocmd <nomodeline> User FernSyntax
147-
endfunction
148-
149-
function! s:ColorScheme() abort
150-
let helper = fern#helper#new()
151-
call helper.fern.renderer.highlight()
152-
call fern#hook#emit('viewer:highlight', helper)
153-
doautocmd <nomodeline> User FernHighlight
154-
endfunction
155-
156137
augroup fern_internal_viewer
157138
autocmd!
158139
autocmd User FernSyntax :

syntax/fern.vim

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
if exists('b:current_syntax')
2+
finish
3+
endif
4+
let b:current_syntax = 'fern'
5+
6+
syntax clear
7+
8+
function! s:ColorScheme() abort
9+
let helper = fern#helper#new()
10+
call helper.fern.renderer.highlight()
11+
call fern#hook#emit('viewer:highlight', helper)
12+
doautocmd <nomodeline> User FernHighlight
13+
endfunction
14+
15+
function! s:Syntax() abort
16+
let helper = fern#helper#new()
17+
call helper.fern.renderer.syntax()
18+
call fern#hook#emit('viewer:syntax', helper)
19+
doautocmd <nomodeline> User FernSyntax
20+
endfunction
21+
22+
augroup fern_syntax_internal
23+
autocmd! * <buffer>
24+
autocmd ColorScheme <buffer> call s:ColorScheme()
25+
augroup END
26+
27+
call s:ColorScheme()
28+
call s:Syntax()

0 commit comments

Comments
 (0)