Skip to content

Commit

Permalink
Better fzf-completion
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
deathbeam committed Apr 11, 2017
1 parent 30e85bd commit 3bc8560
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions vim/.vim/bundle/fzf-contrib/autoload/fzf/contrib.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
function! fzf#contrib#completefunc(findstart, base) abort
let Func = function(get(g:, 'fzf#contrib#completefunc', &omnifunc))
let results = Func(a:findstart, a:base)
echom a:base

if a:findstart
return results
Expand All @@ -21,18 +20,16 @@ function! fzf#contrib#completefunc(findstart, base) abort
\ && len(results) == 1
\ && len(results[0]) > 1
\ && split(results[0], "\t")[1] =~? '\[snip\]'
call feedkeys("\<c-r>=UltiSnips#ExpandSnippet()\<cr>")
call feedkeys("\<c-r>=UltiSnips#ExpandSnippet()\<cr>", 'n')
endif

return map(results, 'split(v:val, "\t")[0]')
endfunction

function! fzf#contrib#complete(...) abort
if len(a:000) && a:000[0]
if getline('.')[col('.') - 1] !~# '\S'
call feedkeys("\<tab>", 'n')
return
endif
if len(a:000) && a:000[0] && getline('.')[col('.') - 1] !~# '\S'
call feedkeys("\<tab>", 'n')
return
endif

setlocal completefunc=fzf#contrib#completefunc
Expand All @@ -46,7 +43,10 @@ function! fzf#contrib#grep(query, ...) abort
let args = copy(a:000)
let opts = len(args) > 1 ? remove(args, 0) : ''
let command = opts . ' ' . "'".substitute(query, "'", "'\\\\''", 'g')."'"
return call('fzf#vim#grep', extend(['rg --no-heading --column --color always '.command, 1], args))

return call('fzf#vim#grep', extend(
\ ['rg --no-heading --column --color always '.command, 1],
\ args))
endif

return call('fzf#vim#ag', insert(copy(a:000), a:query, 0))
Expand Down

0 comments on commit 3bc8560

Please sign in to comment.