-
-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to enable code preview #184
Comments
It's a little more complicated as we have to extract the file name and the line number from the output. This can be a start: command! -bang -nargs=* AgRaw call fzf#vim#ag_raw(<q-args>, fzf#wrap('ag-raw',
\ {'options': "--preview 'coderay $(cut -d: -f1 <<< {}) | sed -n $(cut -d: -f2 <<< {}),\\$p | head -".&lines."'"})) |
Thank you for giving a hint, I am using this now, works great! autocmd! VimEnter * command! -nargs=* -complete=file Ag :call fzf#vim#ag_raw(<q-args>, fzf#wrap('ag-raw',
\ {'options': "--preview 'coderay $(cut -d: -f1 <<< {}) 2> /dev/null | sed -n $(cut -d: -f2 <<< {}),\\$p | head -".&lines."'"})) |
Preview works, but files are not opening. nvim receive the piece of code instead of file name. |
@junegunn I've spent a night by trying to do the same for GitFiles (I'm not familiar with vimscript, at least a day ago). But the only option I found is to directly edit FZF plugin. |
@termosa Something like this? call fzf#vim#gitfiles('', fzf#vim#with_preview('right')) |
@junegunn thank you for the support! Have a nice day! |
I am trying to get preview on marks: call fzf#vim#marks('', fzf#vim#with_preview('right')) |
The above solution is no longer working. Thoughts? |
@junegunn Just wondering, the preview window is really really useful, but the preview window is only enabled for git by default, the normal :Files is does not show the preview window and unless I instead call |
Use cat for preview is just too plain text, no highlight We can use less and source-highlight to enhance the preview result on ubuntu. #install source-highlight |
So, is there a way to enable preview on |
If you can come up with a command/script that generates preview output for each line of call fzf#vim#marks({'options': ['--preview', 'echo line = {}']}) |
Was looking for preview on Marks, thanks for the hint. |
have the same issue with nvim. Did you find the solution? |
If current buffer is open, nvim return the line instead of file name. I use something like this: |
Here is preview for marks. (Took from https://github.com/chengzeyi/fzf-preview.vim) function! s:fzf_preview_p(bang, ...) abort
let preview_args = get(g:, 'fzf_preview_window', ['up:50%', 'ctrl-/'])
if empty(preview_args)
return { 'options': ['--preview-window', 'hidden'] }
endif
" For backward-compatiblity
if type(preview_args) == type('')
let preview_args = [preview_args]
endif
return call('fzf#vim#with_preview', extend(copy(a:000), preview_args))
endfunction
command! -bar -bang MP
\ call fzf#vim#marks(
\ s:fzf_preview_p(<bang>0, {'placeholder': '$([ -r $(echo {4} | sed "s#^~#$HOME#") ] && echo {4} || echo ' . fzf#shellescape(expand('%')) . '):{2}',
\ 'options': '--preview-window +{2}-/2'}),
\ <bang>0)
|
Thx! Changing the command as below doesn't fail to display marks in the current file on an empty line: command! -bar -bang MP
\ call fzf#vim#marks(
\ s:fzf_preview_p(<bang>0, {'placeholder': '$([ -r $(echo {4} | sed "s#^~#$HOME#") ] && [ -n {4} ] || echo ' . fzf#shellescape(expand('%')) . '):{2}',
\ 'options': '--preview-window +{2}-/2'}),
\ <bang>0) |
Code preview works with Files command, and how to enable code preview for other commands, eg: Ag_raw
The text was updated successfully, but these errors were encountered: