From b5b01a4314f2ada0eb56a25a7c6e193f1d7a8bf9 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Wed, 4 Mar 2015 18:15:02 +0000 Subject: [PATCH] vim: use tab for completing snippets as well --- vim/vimrc | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index cbcc9ac..e5a69e6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -396,7 +396,7 @@ autocmd BufWinEnter *.* silent loadview " save with sudo cnoremap w!! w !sudo tee % > /dev/null -" plugins {{{1 +" plugins options {{{1 " ag {{{2 let g:AgSmartCase = 1 nnoremap ag yiw:Ag " @@ -484,9 +484,31 @@ let g:tagbar_iconchars = ['+', '-'] let g:UltiSnipsEditSplit = 'vertical' let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips") let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"] -let g:UltiSnipsExpandTrigger = "" -let g:UltiSnipsJumpForwardTrigger = "" -let g:UltiSnipsJumpBackwardTrigger = "" +let g:UltiSnipsExpandTrigger = "" +let g:UltiSnipsJumpForwardTrigger = "" +let g:UltiSnipsJumpBackwardTrigger = "" + +" UltiSnips completion function that tries to expand a snippet. If there's no +" snippet for expanding, it checks for completion window and if it's shown, +" selects first element. If there's no completion window it tries to jump to +" next placeholder. If there's no placeholder it just returns TAB key +" https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411 +function! g:UltiSnips_Complete() + call UltiSnips#ExpandSnippet() + if g:ulti_expand_res == 0 + if pumvisible() + return "\" + else + call UltiSnips#JumpForwards() + if g:ulti_jump_forwards_res == 0 + return "\" + endif + endif + endif + return "" +endfunction +au InsertEnter * exec "inoremap " . g:UltiSnipsExpandTrigger . " =g:UltiSnips_Complete()" +let g:UltiSnipsListSnippets="" " yankring {{{2 nnoremap p :YRShow -- 2.48.1