Last active
February 24, 2024 06:43
-
-
Save qstrahl/7795524 to your computer and use it in GitHub Desktop.
Super lightweight autocomplete using vim's built-in <C-n> completion
This file contains 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
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> | |
ino <CR> <C-r>=pumvisible()?"\<lt>C-y>":""<CR><CR> | |
ino <Tab> <C-r>=pumvisible()?"\<lt>C-n>":"\<lt>Tab>"<CR> | |
ino <S-Tab> <C-r>=pumvisible()?"\<lt>C-p>":"\<lt>S-Tab>"<CR> | |
augroup MyAutoComplete | |
au! | |
au InsertCharPre * if | |
\ !exists('s:complete') && | |
\ !pumvisible() && | |
\ getline('.')[col('.')-2].v:char =~# '\k\k' | | |
\ let s:complete = 1 | | |
\ noautocmd call feedkeys("\<C-n>\<C-p>", "nt") | | |
\ endif | |
au CompleteDone * if exists('s:complete') | unlet s:complete | endif | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment