-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
341 lines (272 loc) · 8.9 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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
" General
set fileformats=unix,dos
set ruler
set hlsearch
set laststatus=2
set nocompatible " Enter the current Millenium
set softtabstop=2 " number of space chars a tab counts for
set shiftwidth=2 " number of space chars for indentation
" set expandtab " insert space characters whenever the tab key is pressed
set tabstop=2 " space chars inserted when tab key is pressed (In honor of C!)
set smarttab
set noerrorbells visualbell t_vb= " turn off bells
" set nowrap
set showmatch " set show matching parenthesis
" Indent
set autoindent
set copyindent
" Insert mode with paste
set paste
" Fuzzy Finder feature
filetype plugin on
set path+=** " adds $CWD to the search path
set wildmenu " enables wildcards for completion (menus, buffers, files...)
"END
" Higlight column #n with color
set colorcolumn=80
" Show line numbers
set number
" Highlight the line with a cursor
set cursorline
" Detect encoding
set ffs=unix
set fencs=utf-8,cp1251,koi8-r,ucs-2,cp866
" Python syntax highlight
let python_highlight_all = 1
" If it's macOS, adds command that fix backspace behaviour
" for the Insert Mode
if $OSTYPE =~ 'darwin'
set backspace=indent,eol,start
endif
"Undo
set undodir=~/.vim/undo
set undofile
set undolevels=1000 " maximum number of changes that can be undone
set undoreload=10000 " maximum number lines to save for undo on a buffer reload
"Backup and *.swp
set backupdir=~/.vim/tmp,
set directory=~/.vim/tmp,
"Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=darkred guibg=#382424
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
"The above flashes annoyingly while typing, be calmer in insert mode
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
"This means that you can have unwritten changes to a file and open a new file
"using :e, without being forced to write or undo your changes first. Also,
"undo buffers and marks are preserved while the buffer is open
set hidden
"Color
syntax enable
" colorscheme solarized
" set t_Co=256
" colorscheme bvemu
" colorscheme autumn
colorscheme Monokai
" colorscheme railscasts
" colorscheme bubblegum-256-dark
" colorscheme bubblegum-256-light
" colorscheme burnttoast256
" colorscheme lapis256
" colorscheme last256
" colorscheme wasabi256
" colorscheme 256-grayvim
" colorscheme woju
" colorscheme wolfpack
" colorscheme wombat256mod
" colorscheme zenburn
highlight Cursor guibg=Green guifg=NONE
" Netrw
" let g:netrw_banner = 0
" let g:netrw_liststyle = 3
" let g:netrw_browse_split = 4
" let g:netrw_altv = 1
" let g:netrw_winsize = 25
" augroup ProjectDrawer
" autocmd!
" autocmd VimEnter * :Vexplore
" augroup END
" vim-session
let g:session_autoload="yes"
let g:session_autosave="yes"
let g:session_default_to_last="yes"
"================================[ Bundler block: Plug ]=======================
" On a first launch, it autoloads Plug & installs all required plugins
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" all about surroundings: parentheses, brackets, quotes
" Plug 'surround.vim'
" Collection of snippets
" Bundle 'snipMate'
" Comments/Uncomments line/visual block with \c
Plug 'tomtom/tcomment_vim'
" Support of .editorconfig
Plug 'editorconfig/editorconfig-vim'
" Emmet completions
Plug 'mattn/emmet-vim'
" File system explorer
Plug 'scrooloose/nerdtree'
" NERDTree panel, independent of tabs
Plug 'jistr/vim-nerdtree-tabs'
" Neat Status Line //github.com/Cu7ious/vim-neatstatus
Plug 'Cu7ious/vim-neatstatus'
" Drags selected blocks with arrow keys in VISUAL mode
Plug 'gavinbeatty/dragvisuals.vim'
" Colorschemes //github.com/flazz/vim-colorschemes
Plug 'flazz/vim-colorschemes'
" Automatic closing of quotes parenthesis brackets etc.
Plug 'Raimondi/delimitMate'
" Syntax highlighting and improved indentation of .js, .jsx & .tsx files
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'leafgarland/typescript-vim'
Plug 'ianks/vim-tsx'
" :saves <newfile> then rms old filename on disk
Plug 'wojtekmach/vim-rename'
" Opens header files automatically
Plug 'vim-scripts/a.vim'
" Error checking: shows the offending line next to the line numbers
" Plug 'vim-syntastic/syntastic'
Plug 'w0rp/ale'
" Plug 'majutsushi/tagbar'
" Plug 'ludovicchabant/vim-gutentags'
" ----- Working with Git ----------------------------------------------
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
" Man pages right in vim
" Plug 'jez/vim-superman'
" ----- Python --------------------------------------------------------
" Pep8 auto formatter
" Plugin 'tell-k/vim-autopep8'
" Initialize plugin system
call plug#end()
let b:ale_linters = {'typescript': ['tslint']}
let g:EditorConfig_core_mode = 'python_external'
"==============================[ HOTKEYS BLOCK ]===============================
" Turns off the ruler and line numbers to make it ready for copy/paste
command CPMode :call CPModeToggle()
function! CPModeToggle()
if IsNerdTreeEnabled()
:call C7NERDTreeTabsToggle()
endif
if &number
set nonumber | set colorcolumn=0 | set cursorline!
execute 'GitGutterToggle'
else
set number | set colorcolumn=80 | set cursorline
execute 'GitGutterToggle'
endif
endfunction
command Paste :call PasteToggle()
function! PasteToggle()
if &paste
set paste
else
set nopaste
endif
endfunction
" Comment toggle. Requires tComment plugin
map <leader>c <c-_><c-_>
" Emmet
let g:user_emmet_settings = {
\ 'javascript.jsx': {
\ 'extends': 'jsx',
\ 'quote_char': "'"
\ },
\}
let g:user_emmet_install_global = 0
autocmd FileType html,jsx,css EmmetInstall
" NEDRTree Tabs Toggle. Requires nerdtree & vim-nerdtree-tabs plugins
" map <leader>t :NERDTreeTabsToggle<CR>
map <leader>t :call C7NERDTreeTabsToggle()<CR>
function! C7NERDTreeTabsToggle()
NERDTreeTabsToggle
:call ToggleStatusLine()
endfunction
function! IsNerdTreeEnabled()
return exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1
endfunction
function! ToggleStatusLine()
if IsNerdTreeEnabled()
set ls=0
else
set ls=2
endif
endfunction
"====[ Make the 81st column stand out ]====================
" EITHER just the 81st column of wide lines...
" highlight ColorColumn ctermbg=magenta
" call matchadd('ColorColumn', '\%81v', 100)
"=====[ Highlight matches when jumping to next ]=============
" This rewires n and N to do the highlighing...
nnoremap <silent> n n:call HLNext(0.1)<cr>
nnoremap <silent> N N:call HLNext(0.1)<cr>
" EITHER blink the line containing the match...
function! HLNext (blinktime)
set invcursorline
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
set invcursorline
redraw
endfunction
"====[ Always turn on syntax highlighting for diffs ]=========================
" EITHER select by the file-suffix directly...
augroup PatchDiffHighlight
autocmd!
autocmd BufEnter *.patch,*.rej,*.diff syntax enable
augroup END
" OR ELSE use the filetype mechanism to select automatically...
filetype on
augroup PatchDiffHighlight
autocmd!
autocmd FileType diff syntax enable
augroup END
"====[ Drag Visual Blocks"]====================================================
runtime plugin/dragvisuals.vim
vmap <expr> <LEFT> DVB_Drag('left')
vmap <expr> <RIGHT> DVB_Drag('right')
vmap <expr> <DOWN> DVB_Drag('down')
vmap <expr> <UP> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
" Remove any introduced trailing whitespace after moving...
let g:DVB_TrimWS = 1
"====[ Swap v and CTRL-V, because Block mode is more useful than Visual mode ]=
nnoremap v <C-V>
nnoremap <C-V> v
vnoremap v <C-V>
vnoremap <C-V> v
"===========================[ Syntastic Settings ]============================
" We need this for plugins like Syntastic and vim-gitgutter which put symbols
" in the sign column.
" hi clear SignColumn
"
" " Checks file when it's open
" let g:syntastic_check_on_open = 1
"
" " C++
" let g:syntastic_cpp_compiler = 'g++'
" let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
"
" " Python3
" let g:syntastic_python_python_exec = '/usr/local/bin/python3'
"
" " JavaScript
" let g:syntastic_javascript_checkers = ['standard']
" let g:syntastic_javascript_standard_exec = 'semistandard'
"
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
"
" augroup mySyntastic
" au!
" au FileType tex let b:syntastic_mode = 'passive'
" augroup END
"================================[ Syntastic ]=================================
" better man page support
" noremap K :SuperMan <cword><CR>