Skip to content
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

Add the tagJump preview as bat command. #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions autoload/fzf_tags.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ scriptencoding utf-8
let s:actions = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
\ 'ctrl-v': 'vsplit'
\ }

let s:preview_cmd = [
\ '--with-nth 1,2,3',
\ '--preview-window="up:50%"',
\ '--preview="',
\ 'bat ',
\ '--number',
\ '--color always',
\ '--theme OneHalfDark',
\ '--line-range {4}:',
\ '--highlight-line {3} {2}"'
\ ]

function! fzf_tags#FindCommand(identifier)
return fzf_tags#Find(empty(a:identifier) ? expand('<cword>') : a:identifier)
Expand All @@ -21,11 +34,12 @@ function! fzf_tags#Find(identifier)
execute 'tag' identifier
else
let expect_keys = join(keys(s:actions), ',')
let preview_source_cmd = join(s:preview_cmd, ' ')
call fzf#run({
\ 'source': source_lines,
\ 'sink*': function('s:sink', [identifier]),
\ 'options': '--expect=' . expect_keys . ' --ansi --no-sort --tiebreak index --prompt " 🔎 \"' . identifier . '\" > "',
\ 'down': '40%',
\ 'options': preview_source_cmd . ' --expect=' . expect_keys . ' --ansi --no-sort --tiebreak index --prompt " \"' . identifier . '\" > "',
\ 'window': { 'width': 0.90, 'height': 0.90, 'border': 'sharp'}
\ })
endif
endfunction
Expand All @@ -51,11 +65,13 @@ function! s:tag_to_string(index, tag_dict)
if has_key(a:tag_dict, 'filename')
call add(components, s:magenta(a:tag_dict['filename']))
endif
if has_key(a:tag_dict, 'class')
call add(components, s:green(a:tag_dict['class']))
endif
if has_key(a:tag_dict, 'cmd')
call add(components, s:red(a:tag_dict['cmd']))
if has_key(a:tag_dict, 'line')
call add(components, s:green(a:tag_dict['line']))
if (a:tag_dict['line'] > 8)
call add(components, s:green(a:tag_dict['line'] - 8))
else
call add(components, s:green(a:tag_dict['line']))
endif
endif
return components
endfunction
Expand Down