-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
197 lines (162 loc) · 5.21 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sean Kelly's vimrc configuration
"
" Ideas/settings thanks to:
" - Allan MacGregor
" (https://github.com/amacgregor/dot-files/blob/master/vimrc)
" - Sidney Liebrand
" (https://medium.com/@sidneyliebrand/a-collection-of-vim-key-binds-4d227c9a455)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Environment
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has('win32') || has('win64')
let g:env = 'WINDOWS'
else
let g:env = 'LINUX'
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('$HOME/.vim/plugged')
" Use vim-sensible for defaults
Plug 'tpope/vim-sensible'
" General functionality/tools
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-vinegar'
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
"Plug 'vim-syntastic/syntastic'
Plug 'ntpeters/vim-better-whitespace'
Plug 'tmux-plugins/vim-tmux-focus-events'
if (g:env == 'LINUX')
Plug 'junegunn/fzf', { 'dir': '$HOME/.fzf', 'do': './install --all' }
"Plug 'ycm-core/YouCompleteMe', { 'do': './install.py --clang-completer' }
"Plug 'rdnetto/YCM-Generator', { 'branch': 'stable'}
"Plug 'jeaye/color_coded'
else " WINDOWS
" Note -- requires FZF be installed via chocolately
Plug 'junegunn/fzf'
endif
Plug 'junegunn/fzf.vim'
" Themes
Plug 'morhetz/gruvbox'
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General Configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nowrap
set mouse=a
" Show linenumbers
set number
set relativenumber
augroup toggle_relative_number
autocmd InsertEnter * :setlocal norelativenumber
autocmd InsertLeave * :setlocal relativenumber
" Enable highlighting of the current line
set cursorline
" Draw a vertical line on column 80 (for wrapping)
set colorcolumn=80
set splitright
set autoread
" Always use system clipboard
set clipboard^=unnamed,unnamedplus
" Tab settings
set tabstop=4
set shiftwidth=4
set expandtab
" Autocomplete settings
set wildmode=longest,list,full
set wildmenu
" Make vimdiff open for write
set noro
" Put backup/swp files in dedicated directory to avoid cluttering projects
set backupdir=$HOME/.vim/backup//
set directory=$HOME/.vim/swp//
" Custom search path for tags
set tags=./tags,./TAGS,tags,TAGS,~/tags
" Enable powerline
" Recommended settings from documentation
set noshowmode
set showtabline=2
set laststatus=2
python3 from powerline.vim import setup as powerline_setup
python3 powerline_setup()
python3 del powerline_setup
" FZF
" Prevent fzf from searching on the filename returned by rg
" Thanks to https://github.com/junegunn/fzf.vim/issues/346#issuecomment-518087788
" Also add preview window, thanks to https://github.com/junegunn/fzf.vim/issues/676#issuecomment-407964464
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ "rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>),
\ 0,
\ fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}), <bang>0)
"" Recommended Syntastic settings
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_cpp_config_file = '.syntastic_cpp_config'
let g:syntastic_cpp_include_dirs = [ 'build' ]
" vim-better-whitespace
let g:better_whitespace_enabled = 1
let g:strip_whitespace_on_save = 1
let g:strip_whitespace_confirm = 0
let g:strip_only_modified_lines = 1
" YouCompleteMe
let g:ycm_confirm_extra_conf = 0
let g:ycm_autoclose_preview_windows_after_insertion = 1
" Workaround to enable block cursor on mintty
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
" Theme and Appearance
set background=dark
set t_Co=256
let g:gruvbox_italic=1
colorscheme gruvbox
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Leader Key
let mapleader = "\<Space>"
" Edit/reload vimrc
nnoremap <Leader>ve :e $MYVIMRC<CR>
nnoremap <Leader>vr :source $MYVIMRC<CR>
" Basic functions
nnoremap <Leader>w :w<CR>
nnoremap <Leader>q :q<CR>
" Navigation functions
noremap K {
noremap J }
noremap H ^
noremap L $
nnoremap <C-h> <C-W><C-h>
nnoremap <C-j> <C-W><C-j>
nnoremap <C-k> <C-W><C-k>
nnoremap <C-l> <C-W><C-l>
" Make Y consistent with C and D (c$, d$, y$ instead of c$, d$, yy)
nnoremap Y y$
" Use tab to manage indentation
nmap >> <Nop>
nmap << <Nop>
vmap << <Nop>
vmap >> <Nop>
nnoremap <Tab> >>
nnoremap <S-Tab> <<
vnoremap <Tab> >><Esc>gv
vnoremap <S-Tab> <<<Esc>gv
" Extension bindings
nnoremap <Leader>a :Rg <C-r><C-w><CR>
nnoremap <Leader>b :Buffers<CR>
nnoremap <Leader>f :Rg<CR>
nnoremap <Leader>m :TagbarToggle<CR>
nnoremap <Leader>p :Files<CR>
nnoremap <Leader>s :%s/\<<C-r><C-w>\>//g<Left><Left>
nnoremap <Leader>g :Gstatus<CR>