Auto trim trailing spaces on save. Tab autocompletes when under a word. F2 cleans search pattern. Added i3config syntax plugin

This commit is contained in:
Claudio Maggioni 2019-01-03 17:38:39 +01:00
parent 7a068225c8
commit d9d9e898e5
3 changed files with 49 additions and 10 deletions

3
.gitmodules vendored
View file

@ -22,3 +22,6 @@
[submodule "pack/plugins/start/vimproc.vim"]
path = pack/plugins/start/vimproc.vim
url = https://github.com/Shougo/vimproc.vim.git
[submodule "pack/plugins/start/i3config.vim"]
path = pack/plugins/start/i3config.vim
url = https://github.com/mboughaba/i3config.vim.git

View file

@ -1,4 +1,4 @@
" vim: set tw=80 :
" vim: set et sw=2 ts=2 tw=80 :
" SETTINGS
@ -32,12 +32,37 @@ set wildignore+=**/node_modules/**
" ADDITIONAL COMMANDS
inoremap <S-tab> <C-d>
" make escape work in terminal and send ESC to terminal with C-Esc
tnoremap <Esc> <C-\><C-n>
tnoremap <C-Esc> <Esc>
" clear search with F2
nnoremap <F2> noh
" activate autocompletion using `key` when under a 'keyword' char
" (a-zA-Z + relevant characters for current language), otherwise just send TAB
function! AutocompleteIfKeyword()
let curcol = col('.') - 1 " column position before the cursor
if !curcol " if at the beginning of the line
return "\<tab>" " insert TAB character
elseif getline('.')[curcol - 1] =~ '\k' " if current character is a 'keyword'
return g:autocomplete_key " activate autocompletion for current word
else " if the current char is not a 'keyword'
return "\<tab>" " insert TAB characher
end
endfunction
" autocomplete using `key` with tab if cursor is under a 'keyword' char.
" for <C-r>= see: https://stackoverflow.com/questions/10862457
inoremap <silent> <tab> <C-r>=AutocompleteIfKeyword()<CR>
" use standard vim autocomplete as fallback
let g:autocomplete_key = "\<C-n>"
" autocomplete with Tsuquyomi on TypeScript files
autocmd FileType typescript let g:autocomplete_key = "\<C-x>\<C-o>"
" clear search pattern with F2
noremap <F2> :let @/ = ""<CR>
" Use "," as leader
let mapleader = ","
@ -46,22 +71,32 @@ let mapleader = ","
nnoremap <Leader>w <C-w><C-w>
" Show next buffer with: Leader n
nnoremap <Leader>n :bn<cr>
nnoremap <Leader>n :bn<CR>
" Fix indentation with: Leader i
nnoremap <Leader>i mzgg=G`z
" Delete buffer with: Leader d
nnoremap <Leader>d :bd<cr>
nnoremap <Leader>d :bd<CR>
" clear trailing spaces with: Leader t s
nnoremap <Leader>ts :%s/\s *$//g<CR>
" clear trailing spaces in file
function! g:ClearTrailingSpaces()
silent! %s/\s *$//g
let @/ = "" " clear last search
endfunction
" remove trailing spaces with: Leader t s
nnoremap <silent> <Leader>ts :call ClearTrailingSpaces()<CR>
" automatically remove trailing spaces when saving a file
autocmd BufWrite * call ClearTrailingSpaces()
" Reload config with: Leader R
nnoremap <Leader>R :source ~/.config/nvim/init.vim<cr>
nnoremap <Leader>R :source ~/.config/nvim/init.vim<CR>
" show Vim's true competitor with: Leader r c m
nnoremap <Leader>rcm :!open https://youtu.be/jn40Ugz0vuk<CR><CR>
autocmd FileType typescript imap <tab> <C-x><C-o>
" COLORSCHEME
" set colorscheme to onedark.im for nvim and airline

@ -0,0 +1 @@
Subproject commit c68bbb54d97ab8cea46b866e86a584f4d7a9db4a