Skip to content

Instantly share code, notes, and snippets.

@7c00
Forked from vheon/minimal-autocomplete.vim
Created January 22, 2016 04:27
Show Gist options
  • Save 7c00/55722b69a99d8fc26325 to your computer and use it in GitHub Desktop.
Save 7c00/55722b69a99d8fc26325 to your computer and use it in GitHub Desktop.
set cot=menu,menuone
ino <BS> <BS><C-r>=getline('.')[col('.')-3:col('.')-2]=~#'\k\k'?!pumvisible()?"\<lt>C-n>\<lt>C-p>":'':pumvisible()?"\<lt>C-y>":''<CR>
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : ""
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
function! s:skinny_insert(char)
if !pumvisible() && !exists('s:skinny_complete') &&
\ getline('.')[col('.') - 2].a:char =~# '\k\k'
let s:skinny_complete = 1
noautocmd call feedkeys("\<C-n>\<C-p>", "nt")
endif
endfunction
augroup SkinnyAutoComplete
autocmd!
autocmd InsertCharPre * call <SID>skinny_insert(v:char)
autocmd CompleteDone * if exists('s:skinny_complete') | unlet s:skinny_complete | endif
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment