Created
February 22, 2016 08:32
-
-
Save chemzqm/43fe9044df1eb37cdfd1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if exists('did_completes_me_loaded') || v:version < 700 | |
finish | |
endif | |
let did_completes_me_loaded = 1 | |
function! s:completes_me(shift_tab) | |
let dirs = ["\<c-p>", "\<c-n>"] | |
if get(b:, 'complete_disable', 0) | |
return a:shift_tab ? "\<S-Tab>" : "\<Tab>" | |
endif | |
if pumvisible() | |
if a:shift_tab | |
return dirs[0] | |
else | |
return dirs[1] | |
endif | |
endif | |
" Figure out whether we should indent. | |
let pos = getpos('.') | |
let substr = matchstr(strpart(getline(pos[1]), 0, pos[2]-1), "[^ \t]*$") | |
if strlen(substr) == 0 | return "\<Tab>" | endif | |
if a:shift_tab | |
return "\<c-p>" | |
else | |
return "\<c-n>" | |
endif | |
endfunction | |
inoremap <expr> <plug>completes_me_forward <SID>completes_me(0) | |
inoremap <expr> <plug>completes_me_backward <SID>completes_me(1) | |
imap <Tab> <plug>completes_me_forward | |
imap <S-Tab> <plug>completes_me_backward |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment