diff --git a/.gitmodules b/.gitmodules index 8f554f68..798fcd36 100644 --- a/.gitmodules +++ b/.gitmodules @@ -113,6 +113,6 @@ [submodule "zsh/.zsh/bundle/alias-tips"] path = zsh/.zsh/bundle/alias-tips url = https://github.com/djui/alias-tips -[submodule "vim/.vim/bundle/supertab"] - path = vim/.vim/bundle/supertab - url = https://github.com/ervandew/supertab +[submodule "vim/.vim/bundle/completor.vim"] + path = vim/.vim/bundle/completor.vim + url = https://github.com/maralla/completor.vim diff --git a/README.md b/README.md index 7953f63f..0a6cbbe9 100644 --- a/README.md +++ b/README.md @@ -88,11 +88,11 @@ To add your own Vim, Tmux or Zsh plugin you can just clone it to proper :notebook_with_decorative_cover: The interactive scratchpad for hackers. * [comittia.vim](https://github.com/rhysd/committia.vim): A Vim plugin for more pleasant editing on commit messages + * [completor.vim](https://github.com/maralla/completor.vim): Async completion + framework made ease * [editorconfig-vim](https://github.com/editorconfig/editorconfig-vim): EditorConfig plugin for Vim * [fzf.vim](https://github.com/junegunn/fzf.vim): fzf :heart: vim - * [supertab](https://github.com/ervandew/supertab/): Perform all your vim - insert mode completions with Tab * [syntastic](https://github.com/scrooloose/syntastic): Syntax checking hacks for vim * [tsuquyomi](https://github.com/Quramy/tsuquyomi): A Vim plugin for TypeScript diff --git a/vim/.vim/bundle/completor.vim b/vim/.vim/bundle/completor.vim new file mode 160000 index 00000000..7bffb652 --- /dev/null +++ b/vim/.vim/bundle/completor.vim @@ -0,0 +1 @@ +Subproject commit 7bffb6525318bfd7d9f05af40127c1866e3afb4a diff --git a/vim/.vim/bundle/supertab b/vim/.vim/bundle/supertab deleted file mode 160000 index cdaa5c27..00000000 --- a/vim/.vim/bundle/supertab +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cdaa5c27c5a7f8b08a43d0b2e65929512299e33a diff --git a/vim/.vimrc b/vim/.vimrc index 7c806747..63ee13d7 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -354,6 +354,13 @@ function! Session() endfunction command! -bar Session :call Session() +" Ultisnips +let g:UltiSnipsExpandTrigger = '' + +" Completor +let g:completor_auto_trigger = 0 +let g:completor_min_chars = 1 + " VimWiki let g:vimwiki_list = [{'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}] let g:vimwiki_global_ext=0 @@ -363,13 +370,6 @@ let g:vimwiki_table_mappings = 0 let g:EditorConfig_core_mode = 'external_command' " Speed up editorconfig plugin let g:EditorConfig_exclude_patterns = ['fugitive://.*'] " Fix EditorConfig for fugitive -" Supertab -let g:SuperTabDefaultCompletionType='context' -let g:SuperTabContextDefaultCompletionType='' -let g:SuperTabLongestEnhanced=1 -let g:SuperTabLongestHighlight=1 -let g:SuperTabCrMapping=1 - " Fugitive autocmd VimRc BufReadPost fugitive://* set bufhidden=delete nnoremap gs :Gstatus @@ -397,19 +397,44 @@ nmap mtt :TestNearest " Fuzzy completion function! FzfCompletionPop(findstart, base) - if !a:findstart - " let b:SuperTabChain = ( &omnifunc, &tmuxcomplete#complete, "" ) - " let res = SuperTabCodeComplete(a:findstart, a:base) - let l:res = function(&omnifunc)(a:findstart, a:base) - call fzf#complete(l:res) + let l:res = completor#completefunc(a:findstart, a:base) + + if a:findstart + return l:res endif - return '' + let l:words = [] + + for word in l:res.words + call add(l:words, word['word'] . ' ' . word['menu']) + endfor + + let l:result = fzf#run({ 'source': l:words, 'down': '~40%', 'options': printf('--query "%s" +s', a:base) }) + + if empty(l:result) + return [ a:base ] + endif + + return [ split(l:result[0])[0] ] +endfunction + +function! FzfCompletionTrigger() + setlocal completefunc=FzfCompletionPop + setlocal completeopt=menu + call feedkeys("\\", 'n') +endfunction +imap :call FzfCompletionTrigger() + +" Awesome TAB fuzzy completion +function! Smart_TabComplete() + let col = col('.') - 1 + if !col || getline('.')[col - 1] !~ '\k' + call feedkeys("\", 'n') + return + endif + call feedkeys("\\") endfunction -set completefunc=FzfCompletionPop -imap (fzf-complete-word) -imap (fzf-complete-path) -imap (fzf-complete-line) +inoremap :call Smart_TabComplete() " rg command suffix, [options] function! VRg_raw(command_suffix, ...)