Skip to content

Commit

Permalink
Merge pull request #397 from lambdalisue/fix-syntax
Browse files Browse the repository at this point in the history
Use `syntax/fern.vim` instead to define syntax/highlight
  • Loading branch information
lambdalisue authored Mar 3, 2022
2 parents d2ceaeb + c5a11af commit 398e34b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
19 changes: 0 additions & 19 deletions autoload/fern/internal/viewer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ function! s:init() abort
autocmd! * <buffer>
autocmd BufEnter <buffer> setlocal nobuflisted
autocmd BufReadCmd <buffer> nested call s:BufReadCmd()
autocmd Syntax <buffer> call s:Syntax()
autocmd ColorScheme <buffer> call s:ColorScheme()
autocmd CursorMoved,CursorMovedI,BufLeave <buffer> let b:fern_cursor = getcurpos()[1:2]
augroup END
call fern#internal#viewer#auto_duplication#init()
Expand Down Expand Up @@ -94,9 +92,6 @@ function! s:init() abort
if !g:fern#disable_viewer_spinner
call fern#internal#spinner#start()
endif
call helper.fern.renderer.highlight()
call fern#hook#emit('viewer:highlight', helper)
doautocmd <nomodeline> User FernHighlight

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

function! s:Syntax() abort
let helper = fern#helper#new()
call helper.fern.renderer.syntax()
call fern#hook#emit('viewer:syntax', helper)
doautocmd <nomodeline> User FernSyntax
endfunction

function! s:ColorScheme() abort
let helper = fern#helper#new()
call helper.fern.renderer.highlight()
call fern#hook#emit('viewer:highlight', helper)
doautocmd <nomodeline> User FernHighlight
endfunction

augroup fern_internal_viewer
autocmd!
autocmd User FernSyntax :
Expand Down
28 changes: 28 additions & 0 deletions syntax/fern.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
if exists('b:current_syntax')
finish
endif
let b:current_syntax = 'fern'

syntax clear

function! s:ColorScheme() abort
let helper = fern#helper#new()
call helper.fern.renderer.highlight()
call fern#hook#emit('viewer:highlight', helper)
doautocmd <nomodeline> User FernHighlight
endfunction

function! s:Syntax() abort
let helper = fern#helper#new()
call helper.fern.renderer.syntax()
call fern#hook#emit('viewer:syntax', helper)
doautocmd <nomodeline> User FernSyntax
endfunction

augroup fern_syntax_internal
autocmd! * <buffer>
autocmd ColorScheme <buffer> call s:ColorScheme()
augroup END

call s:ColorScheme()
call s:Syntax()

0 comments on commit 398e34b

Please sign in to comment.