aboutsummaryrefslogtreecommitdiff
path: root/.vim/vimrc
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-03-22 18:11:28 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-03-22 18:11:28 +0100
commit0d7c827359dd35d0069532a829b6728b3ca84ad4 (patch)
treee76511458dcc45761fe6d8ce7df700ca02b1f79a /.vim/vimrc
parent399065f7793eec9778f3e4486c6ca5e5fbdd091e (diff)
downloaddotfiles-0d7c827359dd35d0069532a829b6728b3ca84ad4.tar.gz
vim updates
Diffstat (limited to '.vim/vimrc')
-rw-r--r--.vim/vimrc29
1 files changed, 29 insertions, 0 deletions
diff --git a/.vim/vimrc b/.vim/vimrc
index d98bb5f..bda5c62 100644
--- a/.vim/vimrc
+++ b/.vim/vimrc
@@ -15,6 +15,8 @@ let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#whitespace#enabled = 1
let g:airline_powerline_fonts = 1
+let g:completor_clang_binary = '/usr/bin/clang'
+
"All things cursor
set guicursor+=a:blinkon0 "disable blinking
if &term =~ "xterm\\|rxvt"
@@ -97,6 +99,12 @@ inoremap {} {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
+" completor
+
+inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
+inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
+inoremap <expr> <Tab> Tab_Or_Complete()
+
" ===========
" COMMANDS
" ===========
@@ -138,6 +146,27 @@ function Run_in_terminal(prog)
startinsert
endfunction
+" Use TAB to complete when typing words, else inserts TABs as usual. Uses
+" dictionary, source files, and completor to find matching words to complete.
+
+" Note: usual completion is on <C-n> but more trouble to press all the time.
+" Never type the same word twice and maybe learn a new spellings!
+" Use the Linux dictionary when spelling is in doubt.
+function! Tab_Or_Complete() abort
+ " If completor is already open the `tab` cycles through suggested completions.
+ if pumvisible()
+ return "\<C-N>"
+ " If completor is not open and we are in the middle of typing a word then
+ " `tab` opens completor menu.
+ elseif col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^[[:keyword:][:ident:]]'
+ return "\<C-R>=completor#do('complete')\<CR>"
+ else
+ " If we aren't typing a word and we press `tab` simply do the normal `tab`
+ " action.
+ return "\<Tab>"
+ endif
+endfunction
+
" helper function to toggle hex mode
function ToggleHex()
" hex mode should be considered a read-only operation