[Tags] Disable colored output when tags file is larger than 20M

This commit is contained in:
Junegunn Choi
2015-09-12 23:12:01 +09:00
parent 47fb2c3eb6
commit c9c49f6722

View File

@@ -425,11 +425,19 @@ function! fzf#vim#tags(...)
endif endif
let tagfile = tagfiles()[0] let tagfile = tagfiles()[0]
" We don't want to apply --ansi option when tags file is large as it makes
" processing much slower.
if getfsize(tagfile) > 1024 * 1024 * 20
let proc = 'grep -v ''^!'' '
let copt = ''
else
let proc = 'perl -ne ''unless (/^!/) { s/^(.*?)\t(.*?)\t/\x1b[33m\1\x1b[m\t\x1b[34m\2\x1b[m\t/; print }'' '
let copt = '--ansi '
endif
call s:fzf({ call s:fzf({
\ 'source': 'cat '.shellescape(tagfile). \ 'source': proc.shellescape(tagfile),
\ '| grep -v "^!" | perl -pe "s/^(.*?)\t(.*?)\t/\x1b[33m\1\x1b[m\t\x1b[34m\2\x1b[m\t/"',
\ 'dir': fnamemodify(tagfile, ':h'), \ 'dir': fnamemodify(tagfile, ':h'),
\ 'options': '--ansi +m --tiebreak=begin --prompt "Tags> "'.s:expect(), \ 'options': copt.'+m --tiebreak=begin --prompt "Tags> "'.s:expect(),
\ 'sink*': function('s:tags_sink')}, a:000) \ 'sink*': function('s:tags_sink')}, a:000)
endfunction endfunction