" https://github.com/neitanod/vim-clevertab function! Juliana#Init() let g:Juliana#has_selection = 0 augroup JulianaPersistAu autocmd ModeChanged [V\x16]*:i let g:Juliana#has_selection = 1 autocmd InsertLeave * let g:Juliana#has_selection = 0 augroup END endfunction function! Juliana#CompleteTab(type) if a:type == "START" let g:Juliana#stop=0 return "" endif if !g:Juliana#stop " Vanilla if we are at the front of a line. if a:type == "TAB" && col(".") >= col("$") && !pumvisible() let g:Juliana#stop=1 return "\" elseif a:type == "ALIGN" && !pumvisible() " Align if !pumvisible(). let g:Juliana#stop=1 if g:Juliana#has_selection return "\gv=i" else return "\\=i" endif elseif a:type == "NEXT" " If pumvisible(), goto the next result. let g:Juliana#stop=1 return "\" endif endif return "" endfunction function! Juliana#CompleteSTab(type) if a:type == "PREV" if pumvisible() " If pumvisible(), goto the previous result. return "\" else return "\" " = endif endif endfunction