Skip to content

Commit 31e0689

Browse files
committed
lazy-load fern
1 parent 5989a1a commit 31e0689

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plugin/fern_hijack.vim

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ if exists('g:loaded_fern_hijack') || ( !has('nvim') && v:version < 801 )
33
endif
44
let g:loaded_fern_hijack = 1
55

6-
function! s:hijack_directory() abort
7-
let path = s:expand('%:p')
8-
if !isdirectory(path)
6+
function! s:hijack_directory(path) abort
7+
if !isdirectory(a:path)
98
return
109
endif
1110
let bufnr = bufnr()
12-
execute printf('keepjumps keepalt Fern %s', fnameescape(path))
11+
execute printf('keepjumps keepalt Fern %s', fnameescape(a:path))
1312
execute printf('silent! bwipeout %d', bufnr)
1413
endfunction
1514

@@ -27,8 +26,13 @@ function! s:expand(expr) abort
2726
endtry
2827
endfunction
2928

29+
function! s:initial_hijack() abort
30+
call s:hijack_directory(expand('%:p'))
31+
autocmd fern-hijack BufEnter * ++nested call s:hijack_directory(s:expand('%:p'))
32+
endfunction
33+
3034
augroup fern-hijack
3135
autocmd!
3236
autocmd VimEnter * call s:suppress_netrw()
33-
autocmd BufEnter * ++nested call s:hijack_directory()
37+
autocmd BufEnter * ++once ++nested call s:initial_hijack()
3438
augroup END

0 commit comments

Comments
 (0)