-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create fzf-contrib for Vim, cleanup .vimrc
Signed-off-by: Tomas Slusny <[email protected]>
- Loading branch information
Showing
8 changed files
with
85 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
function! fzf#contrib#complete(findstart, base) | ||
let Func = function(get(g:, 'fzf#contrib#completefunc', &omnifunc)) | ||
let results = Func(a:findstart, a:base) | ||
echom a:base | ||
|
||
if a:findstart | ||
return results | ||
endif | ||
|
||
let words = type(results) == type({}) && has_key(results, 'words') | ||
\ ? map(results.words, 'v:val.word . "\t" . v:val.menu') | ||
\ : results | ||
|
||
let results = fzf#run({ | ||
\ 'source': words, | ||
\ 'down': '~40%', | ||
\ 'options': printf('--query "%s" +s -m', a:base) | ||
\ }) | ||
|
||
if exists('*UltiSnips#ExpandSnippet') | ||
\ && len(results) == 1 | ||
\ && len(results[0]) > 1 | ||
\ && match(split(results[0], "\t")[1], '\[snip\]') != -1 | ||
call feedkeys("\<c-r>=UltiSnips#ExpandSnippet()\<cr>") | ||
endif | ||
|
||
return map(results, 'split(v:val, "\t")[0]') | ||
endfunction | ||
|
||
function! fzf#contrib#trigger_complete() | ||
setlocal completefunc=fzf#contrib#complete | ||
setlocal completeopt=menu | ||
call feedkeys("\<c-x>\<c-u>", 'n') | ||
endfunction | ||
|
||
function! fzf#contrib#tab_complete() | ||
let col = col('.') - 1 | ||
|
||
if !col || getline('.')[col - 1] !~# '\k' | ||
call feedkeys("\<tab>", 'n') | ||
else | ||
call fzf#contrib#trigger_complete() | ||
endif | ||
endfunction | ||
|
||
function! fzf#contrib#grep(query, ...) | ||
if executable('rg') | ||
let query = empty(a:query) ? '^.' : a:query | ||
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)) | ||
endif | ||
|
||
return call('fzf#vim#ag', insert(copy(a:000), a:query, 0)) | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
imap <c-x><c-j> <c-o>:call fzf#contrib#trigger_complete()<cr> | ||
inoremap <silent> <tab> <c-o>:call fzf#contrib#tab_complete()<cr> | ||
command! -bang -nargs=* Grep call fzf#contrib#grep(<q-args>, <bang>0) |
Submodule vim-snippets
updated
3 files
+23 −1 | UltiSnips/tex.snippets | |
+2 −2 | snippets/ruby.snippets | |
+2 −2 | snippets/tex.snippets |
Submodule vim-test
updated
from 9bcdb4 to c3ed26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters