@@ -57,6 +57,7 @@ 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 ()
6061 autocmd ColorScheme <buffer> call s: ColorScheme ()
6162 autocmd CursorMoved ,CursorMovedI ,BufLeave <buffer> let b: fern_cursor = getcurpos ()[1 :2 ]
6263 augroup END
@@ -99,9 +100,6 @@ function! s:init() abort
99100
100101 " now the buffer is ready so set filetype to emit FileType
101102 setlocal filetype = fern
102- call helper.fern.renderer.syntax ()
103- call fern#hook#emit (' viewer:syntax' , helper)
104- doautocmd <nomodeline> User FernSyntax
105103 call fern#action#_init ()
106104
107105 let l: Profile = fern#profile#start (' fern#internal#viewer:init' )
@@ -129,9 +127,6 @@ endfunction
129127function ! s: BufReadCmd () abort
130128 let helper = fern#helper#new ()
131129 setlocal filetype = fern
132- call helper.fern.renderer.syntax ()
133- call fern#hook#emit (' viewer:syntax' , helper)
134- doautocmd <nomodeline> User FernSyntax
135130 setlocal modifiable
136131 call setline (1 , get (b: , ' fern_viewer_cache_content' , []))
137132 setlocal nomodifiable
@@ -144,6 +139,13 @@ function! s:BufReadCmd() abort
144139 \. catch ({ e - > fern#logger#error (e ) })
145140endfunction
146141
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+
147149function ! s: ColorScheme () abort
148150 let helper = fern#helper#new ()
149151 call helper.fern.renderer.highlight ()
0 commit comments