Skip to content

Instantly share code, notes, and snippets.

@vheon
Forked from qstrahl/minimal-autocomplete.vim
Last active February 24, 2024 06:45
Show Gist options
  • Save vheon/10104517 to your computer and use it in GitHub Desktop.
Save vheon/10104517 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
@7c00
Copy link

7c00 commented Jan 22, 2016

A tiny patch

--- inoremap <expr> <CR>    pumvisible() ? "\<C-y>" : ""
+++ inoremap <expr> <CR>    pumvisible() ? "\<C-y>" : "\<CR>"

@samEngineering
Copy link

This is great. Thank you! ^_^
the menuone option does not seem to work for me. Anyone else have this problem? I don't have any other popup menu options set anywhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment