2019-01-03 16:38:39 +00:00
|
|
|
" vim: set et sw=2 ts=2 tw=80 :
|
2018-12-18 21:22:11 +00:00
|
|
|
|
|
|
|
" SETTINGS
|
|
|
|
|
2018-12-30 19:31:26 +00:00
|
|
|
if !has('nvim')
|
|
|
|
setlocal cm=blowfish2
|
|
|
|
end
|
|
|
|
|
2018-12-10 19:36:10 +00:00
|
|
|
" set relative line numbers
|
|
|
|
set number relativenumber
|
2018-12-18 21:22:11 +00:00
|
|
|
|
|
|
|
" set highlighting and continous search
|
2018-12-10 19:36:10 +00:00
|
|
|
set hlsearch incsearch
|
2018-12-18 21:22:11 +00:00
|
|
|
|
|
|
|
" show n-column limiter when textwidth is set
|
2018-12-10 19:36:10 +00:00
|
|
|
set colorcolumn=+1
|
2018-12-18 21:22:11 +00:00
|
|
|
|
2018-12-30 19:31:26 +00:00
|
|
|
if has('nvim')
|
|
|
|
" prevent terminal buffers to be closed when changing buffer
|
|
|
|
autocmd TermOpen * set bufhidden=hide
|
2018-12-18 21:22:11 +00:00
|
|
|
|
2018-12-30 19:31:26 +00:00
|
|
|
" remove line numbers to terminale
|
|
|
|
autocmd TermOpen * set nornu nonu
|
|
|
|
end
|
2018-12-18 21:22:11 +00:00
|
|
|
|
|
|
|
" set autoindent on`
|
|
|
|
set autoindent
|
|
|
|
|
|
|
|
" Make :find work on all files in :pwd
|
|
|
|
set path+=**
|
2019-01-21 19:50:15 +00:00
|
|
|
set wildignore+=**/node_modules/**,*~
|
2018-12-18 21:22:11 +00:00
|
|
|
|
2019-01-20 12:28:38 +00:00
|
|
|
" set netrw preferred style to tree
|
|
|
|
let g:netrw_liststyle = 3
|
|
|
|
|
|
|
|
" remove netrw top banner
|
|
|
|
let g:netrw_banner = 0
|
2018-12-18 21:22:11 +00:00
|
|
|
|
2019-02-05 13:54:59 +00:00
|
|
|
let g:netrw_list_hide = netrw_gitignore#Hide()
|
|
|
|
|
2018-12-18 21:22:11 +00:00
|
|
|
" ADDITIONAL COMMANDS
|
|
|
|
|
2019-02-02 22:25:50 +00:00
|
|
|
" emulate system clipboard
|
|
|
|
inoremap <C-v> <ESC>"+pa
|
|
|
|
vnoremap <C-c> "+y
|
|
|
|
|
2019-01-03 16:38:39 +00:00
|
|
|
inoremap <S-tab> <C-d>
|
|
|
|
|
2018-12-18 09:15:06 +00:00
|
|
|
" make escape work in terminal and send ESC to terminal with C-Esc
|
|
|
|
tnoremap <Esc> <C-\><C-n>
|
|
|
|
tnoremap <C-Esc> <Esc>
|
|
|
|
|
2019-01-03 16:38:39 +00:00
|
|
|
" 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>
|
2018-12-18 21:22:11 +00:00
|
|
|
|
2018-12-27 12:20:34 +00:00
|
|
|
" Use "," as leader
|
|
|
|
let mapleader = ","
|
2018-12-18 21:22:11 +00:00
|
|
|
|
2019-01-03 16:47:04 +00:00
|
|
|
" Git grep with Leader g
|
|
|
|
nnoremap <Leader>g :Grepper -tool git<CR>
|
|
|
|
|
2018-12-27 12:20:34 +00:00
|
|
|
" Switch between Windows with: Leader w
|
|
|
|
nnoremap <Leader>w <C-w><C-w>
|
|
|
|
|
2019-01-03 21:58:42 +00:00
|
|
|
" show next buffer with: leader n
|
|
|
|
nnoremap <leader>n :bn<cr>
|
|
|
|
|
|
|
|
" show previous buffer with: leader n
|
|
|
|
nnoremap <leader>p :bp<cr>
|
2019-01-03 16:38:39 +00:00
|
|
|
|
|
|
|
" Fix indentation with: Leader i
|
|
|
|
nnoremap <Leader>i mzgg=G`z
|
2018-12-27 12:20:34 +00:00
|
|
|
|
|
|
|
" Delete buffer with: Leader d
|
2019-01-03 21:58:42 +00:00
|
|
|
nnoremap <Leader>d :bp\|bd #<CR>
|
|
|
|
|
|
|
|
" move to next tab with: Leader t
|
|
|
|
nnoremap <Leader>t :tabnext<CR>
|
|
|
|
tnoremap <C-e> <C-\><C-n>:tabnext<CR>
|
2019-01-03 16:38:39 +00:00
|
|
|
|
2019-02-05 13:54:59 +00:00
|
|
|
nnoremap <unique> <Leader>I <Plug>WildignoreFromGitignore
|
|
|
|
|
2019-01-03 16:38:39 +00:00
|
|
|
" clear trailing spaces in file
|
|
|
|
function! g:ClearTrailingSpaces()
|
|
|
|
silent! %s/\s *$//g
|
|
|
|
let @/ = "" " clear last search
|
|
|
|
endfunction
|
2018-12-27 12:20:34 +00:00
|
|
|
|
2019-01-03 16:38:39 +00:00
|
|
|
" remove trailing spaces with: Leader t s
|
2019-02-05 13:54:59 +00:00
|
|
|
nnoremap <silent> <Leader>s :call ClearTrailingSpaces()<CR>
|
2019-01-03 16:38:39 +00:00
|
|
|
|
|
|
|
" automatically remove trailing spaces when saving a file
|
|
|
|
autocmd BufWrite * call ClearTrailingSpaces()
|
2018-12-27 12:20:34 +00:00
|
|
|
|
|
|
|
" Reload config with: Leader R
|
2019-01-03 16:38:39 +00:00
|
|
|
nnoremap <Leader>R :source ~/.config/nvim/init.vim<CR>
|
2018-12-27 12:20:34 +00:00
|
|
|
|
|
|
|
" show Vim's true competitor with: Leader r c m
|
|
|
|
nnoremap <Leader>rcm :!open https://youtu.be/jn40Ugz0vuk<CR><CR>
|
2018-12-18 21:22:11 +00:00
|
|
|
|
2019-01-20 12:28:38 +00:00
|
|
|
" open netrw in directory of current file
|
|
|
|
nnoremap <Leader>e :Ex<CR>
|
|
|
|
|
2019-01-21 19:50:15 +00:00
|
|
|
" close quickfix window with: Leader Q
|
|
|
|
nnoremap <Leader>Q :ccl<CR>
|
|
|
|
|
|
|
|
" Go files: launch go lint quickfix with: Leader q
|
|
|
|
autocmd FileType go nnoremap <Leader>q :w<CR>:GoLint<CR>
|
|
|
|
|
|
|
|
" TypeScript files: launch TypeScript lint quickfix with: Leader q
|
|
|
|
autocmd FileType typescript nnoremap <Leader>q :TsuQuickFix<CR>
|
|
|
|
|
|
|
|
|
2018-12-18 21:22:11 +00:00
|
|
|
" COLORSCHEME
|
|
|
|
|
2018-12-27 12:20:34 +00:00
|
|
|
" set colorscheme to onedark.im for nvim and airline
|
2018-12-18 21:22:11 +00:00
|
|
|
packadd! onedark.vim
|
|
|
|
colorscheme onedark
|
|
|
|
let g:airline_theme='onedark'
|
|
|
|
|
|
|
|
" PACKAGES
|
|
|
|
|
|
|
|
" vim-fish setup
|
2018-12-18 09:15:06 +00:00
|
|
|
syntax enable
|
|
|
|
filetype plugin indent on
|
|
|
|
" Set up :make to use fish for syntax checking.
|
|
|
|
autocmd FileType fish compiler fish
|
2018-12-10 19:36:10 +00:00
|
|
|
|
|
|
|
if has("vms")
|
|
|
|
set nobackup " do not keep a backup file, use versions instead
|
|
|
|
else
|
|
|
|
set backup " keep a backup file (restore to previous version)
|
|
|
|
if has('persistent_undo')
|
|
|
|
set undofile " keep an undo file (undo changes after closing)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|