-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
311 lines (253 loc) · 8.86 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" same shortcuts to move around vim windows and tmux panes
Plugin 'christoomey/vim-tmux-navigator'
" single and multiline comments
Plugin 'tpope/vim-commentary'
" git diff signs in gutter
Plugin 'airblade/vim-gitgutter'
" insert or delete brackets, parens, quotes in pair
Plugin 'jiangmiao/auto-pairs'
Plugin 'rhysd/vim-clang-format'
let g:clang_format#style_options = {
\ "AccessModifierOffset" : -4,
\ "AllowShortIfStatementsOnASingleLine" : "true",
\ "AlwaysBreakTemplateDeclarations" : "true",
\ "Standard" : "C++11"}
" map to <Leader>cf in C++ code
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>cf :ClangFormat<CR>
Plugin 'octol/vim-cpp-enhanced-highlight'
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
" code folding
Plugin 'tmhedberg/SimpylFold'
let g:SimpylFold_docstring_preview=1
" syntax check using syntastic
Plugin 'vim-syntastic/syntastic'
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_error_symbol = "✗"
let g:syntastic_mode_map={'mode': 'passive'}
" python settings
let g:syntastic_python_checkers = ["flake8"]
let g:syntastic_python_flake8_args='--ignore=E501,E266,E722,E126,E131,E221,E241,E201,E202,E402,F841'
" run syntastic
nnoremap <silent> rr :SyntasticCheck<CR>
" reset syntastic
nnoremap <silent> RR :SyntasticReset<CR>
" toggle errors window
nnoremap <silent> xr :<C-u>call ToggleErrors()<CR>
function! ToggleErrors()
let old_last_winnr = winnr('$')
lclose
if old_last_winnr == winnr('$')
" Nothing was closed, open syntastic error location panel
Errors
endif
endfunction
let python_highlight_all=1
syntax on
" autocomplete
Plugin 'Valloric/YouCompleteMe'
let g:ycm_confirm_extra_conf = 0
let g:ycm_python_binary_path = 'python'
let g:ycm_show_diagnostics_ui = 0
let g:ycm_autoclose_preview_window_after_insertion = 1
" file manager
Plugin 'scrooloose/nerdtree'
" shortcut to open NERDTree
map <C-n> :NERDTreeToggle<CR>
" open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" open a NERDTree automatically when vim starts up if no files were specified
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeAutoDeleteBuffer = 1
let NERDTreeMinimalUI = 1
let NERDTreeIgnore=['\.pyc$', '\~$'] " ignore files in NERDTree
nnoremap <silent> <Leader>v :NERDTreeFind<CR>
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-surround'
" Plugin 'python-mode/python-mode'
Plugin 'kien/ctrlp.vim'
let g:ctrlp_root_markers = ['.ctrlp']
let g:ctrlp_custom_ignore = 'node_modules\|git'
" javascript and react
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
syntax enable
set t_Co=256
colorscheme monokai
set encoding=utf-8
" Sets how many lines of history VIM has to remember
set history=500
" Set to auto read when a file is changed from the outside
set autoread
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on ???
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" show a visual line under the cursor's current line
set cursorline
" show the matching part of the pair for [] {} and ()
set showmatch
" With a map leader it's possible to do extra key combinations
let mapleader = "\\"
let g:mapleader = "\\"
" Smart way to move between windows
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
" Always show the status line
set laststatus=2
set cmdheight=1
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
endif
return ''
endfunction
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
" highlight extra whitespace
:highlight ExtraWhitespace ctermbg=red guibg=red
:match ExtraWhitespace /\s\+$/
" short message for some situations
set shortmess+=c
" use system clipboard
set clipboard=unnamed
" toggle paste mode
set pastetoggle=<leader>p
" better split positions
set splitbelow
set splitright
" enable folding
set foldmethod=indent
set foldlevel=60
" enable folding with the spacebar
nnoremap <space> za
" python and web full-stack indentations
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=120 |
\ set colorcolumn=120 |
\ set expandtab |
\ set smarttab |
\ set autoindent |
\ set fileformat=unix
au BufNewFile,BufRead *.js,*.html,*.css,*.cpp,*.h,*rc,*.sh,*.json
\ set tabstop=2 |
\ set softtabstop=2 |
\ set shiftwidth=2 |
\ set expandtab |
\ set smarttab |
\ set autoindent |
\ set fileformat=unix
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Leader commands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
" Insert ipdb breakpoint
map <silent> <leader>b Oimport ipdb; ipdb.set_trace()<esc>
map <silent> <leader>B oimport ipdb; ipdb.set_trace()<esc>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Line numbers: settings and commands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" show line numbers
set number
" show relative line numbers
set relativenumber
function! ToggleRelativeNumber()
if &number == 0
return
endif
let &relativenumber = &relativenumber?0:1
let g:my_relative_number = &relativenumber
endfunction
function! ToggleNumber()
let &number = &number? 0:1
if &number == 1
let &relativenumber = get(g:, 'my_relative_number', 1)
GitGutterSignsEnable
elseif &number == 0
let &relativenumber = 0
GitGutterSignsDisable
endif
endfunction
nnoremap <silent> <Leader>l :call ToggleNumber()<cr>
nnoremap <silent> <Leader>r :call ToggleRelativeNumber()<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Tags for searching usage in codebase i.e. ~/dev
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tags=~/mytags