Closed bangedorrunt closed 4 years ago
What do you mean by "preview"? You can open it.
i mean when i travel through the tree up and down, a temporary preview buffer would show up without opening the file. this will work just like fzf preview
.
What is a temporary preview buffer? Vim itself has preview window. Are you talking about that? Or are you talking about the floating window in Neovim and popup in Vim8?
Anyway, I cannot imagine what you are exactly talking about. Please explain the feature with some screenshots and more detailed definitions (what is the preview window, where it should be placed, or whatever) for both styles (project drawer style, split window style)
sorry for any confusion. if you use vscode you might come across this behaviour aka preview mode
I'm sorry but that link doesn't help me... I could not get any actual image or behavior or whatever from a screenshot pasted on that link (a part of the screenshot of VS code?)
with preview mode
without preview mode
pls look at the tab, new file will not open a new tab in preview mode unless you edit this file.
in (neo)vim, preview mode will reuse current buffer without creating a new buffer when we use j
, k
to navigate up and down. it would work like fzf.vim
with --preview
option
i'm not sure if it's possible to do so.
Now I got it. Well, I'm not sure if it's useful as VS code while it would cause some performance issue but combinations of fern#smart#leaf()
, fern#smart#drawer()
and <C-w>p
would mimic that behavior like
The entier code is something like:
function! s:fern_preview_init() abort
nmap <buffer><expr>
\ <Plug>(fern-my-preview-or-nop)
\ fern#smart#leaf(
\ "\<Plug>(fern-action-open:edit)\<C-w>p",
\ "",
\ )
nmap <buffer><expr> j
\ fern#smart#drawer(
\ "j\<Plug>(fern-my-preview-or-nop)",
\ "j",
\ )
nmap <buffer><expr> k
\ fern#smart#drawer(
\ "k\<Plug>(fern-my-preview-or-nop)",
\ "k",
\ )
endfunction
augroup my-fern-preview
autocmd! *
autocmd FileType fern call s:fern_preview_init()
augroup END
" You need this otherwise you cannot switch modified buffer
set hidden
awesome! that's exactly what i want. imho, you could make it as an option for the plugin let g:fern#previewmode=0
etc.
thank you so much!
imho, you could make it as an option for the plugin let g:fern#previewmode=0 etc.
I'm sorry but I'm trying to avoid adding features as much as possible to keep the fern.vim itself simple and clean. Instead of adding the feature, I've added Wiki section for that https://github.com/lambdalisue/fern.vim/wiki/Tips#preview-leaf-content-by-jk-like-vs-code
it would be helpful if we could see the content of file while traveling through fern tree