-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows_vimrc
468 lines (346 loc) · 12.1 KB
/
windows_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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
" -----------------
" Windows specific config
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
" -----------------
" End Windows specific config
" Begin vim-plug configuration, see https://github.com/junegunn/vim-plug
call plug#begin()
" ===== START Plug BUNDLES =======
Plug 'altercation/vim-colors-solarized'
Plug 'christoomey/vim-tmux-navigator'
Plug 'freeo/vim-kalisi'
Plug 'croaky/vim-colors-github'
Plug 'bling/vim-airline'
Plug 'kien/ctrlp.vim'
Plug 'scrooloose/syntastic'
Plug 'scrooloose/nerdtree'
Plug 'jeetsukumaran/vim-buffergator'
Plug 'xolox/vim-misc'
Plug 'xolox/vim-easytags'
Plug 'nanotech/jellybeans.vim'
Plug 'Valloric/YouCompleteMe'
Plug 'tpope/vim-surround'
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable'}
Plug 'Raimondi/delimitMate'
Plug 'mdlerch/vim-tungsten'
Plug 'morhetz/gruvbox'
Plug 'romainl/Apprentice'
Plug 'scrooloose/nerdcommenter'
Plug 'tmhedberg/SimpylFold'
" ===== END Plug BUNDLES =========
call plug#begin('~/vimfiles/bundle')
" Based on partially on .vimrc file from http://www.stripey.com/vim/vimrc.html
" set hidden hides buffers instead of closing them. This means you can have
" unwritten changes to a file and open a new file using :e without being
" forced to commit a write or undo your changes to the first file. Also,
" undo buffers and marks are preservede while the buffer is open.
set hidden
" Map/remap the leader keybinding
:let mapleader = ","
" :let mapleader = ";"
" set ms-windows behavior, see :help :behave to see exactly what this does
behave mswin
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Set default color scheme
set t_Co=256
if has('gui_running')
set background=dark
else
set background=dark
endif
" colorscheme kalisi
colorscheme gruvbox
" Set encoding to utf-8, just in case
"set encoding=utf-8
" if this is gvim, turn off toolbar by default
:set guioptions-=T
" First things first, let's clear out any existing autocommands shall we?
autocmd!
" Set vim's current working directory to the directory of the file you're
" opening.
autocmd BufEnter * lcd %:p:h
" Now setting a command line history of 50 lines
set history=50
" And showing the cursor positionat all times
set ruler
" Highlight current line
set cursorline
" Highlight current column
" set cursorcolumn
" ignore case in search, display line numbers, display current mode and
" partially typed commands in status line
set showmode
set showcmd
set ignorecase
set number
" We don't need Vim to write a backup file; there are better ways to backup
" than to rely on Vim
set nobackup
set noswapfile
" set pastetoggle to F2 so that when it's on and you paste, Vim doesn't
" apply autoindenting and other crap which you don't need when pasting
set pastetoggle=<F2>
" enable mouse, to disable, set mouse to -a instead of a
" set mouse=a
:set mouse=a
" turn on syntax highlighting
if has('syntax')
syntax on
endif
" briefly flash the matching brace/parenthesis/bracket when you type
" a closing or opening brace/parenthesis/bracket. Awesome? Awesome.
set showmatch
" Let's also make sure rainbow highlighting is turned on for Lisp
let g:lisp_rainbow = 1
" speaking of brief flashes, how about we get rid of those annoying
" beeps and replace them with brief screen flashes when a command doesn't work.
set vb t_vb=
" command-line completion <Tab> (ie. filenames, help topics, option names)
" lists available options and completes the longest common part, then
" further <Tab>s will cycle through possibilities
set wildmode=list:longest,full
" displays status line that shows name of file currently being edited
" as well as whether or not it has been modified since opening.
set laststatus=2
" ---------
" GVIM Window settings
if has("gui_running")
set lines=40
set columns=80
endif
" Windows GVIM only setting:
" Setting font to Powerline Consolas, 9pt bold
set guifont=Powerline_Consolas:h9:b:cANSI
" ---------
" Treat lines with quote mark as comments
set comments+=b:\"
" Enable filetype detection
filetype on
" Let's show the best match so far as we type
set incsearch
" Show whitespace and tabs
:set list
:set listchars=tab:>-,trail:~,extends:>,precedes:<
" -----------------
" Tabs and formatting
" indents of 4 characters (NO SPACES), smart and auto-indent are on,
" indents are copied down lines
" set nowrap " turn off line wrapping
set formatoptions=l " turn on word wrapping
set lbr " make sure word wrapping doesn't break in middle of words
set shiftwidth=2 " how much to auto-indent by
set ts=2 " sets tab stops to whatever for text input
"set expandtab " turn tab keypresses into spaces (set this or the one below, NOT BOTH)
set noexpandtab " leave tab keys as real tabs (either set this or the above)
set shiftround
set autoindent
set nosmartindent
set tabstop=2 " forces tabs to be X spaces
" End Tabs and formatting
" -----------------
" -----------------
" Custom formatting for specific filetypes:
" So, since we need actual tab characters in make files, we probably
" shouldn't expand them into space characters, right?
autocmd FileType make set noexpandtab shiftwidth=2
" Oh, and let's keep textwidth for all text files to 78 chars
autocmd FileType text setlocal textwidth=80
" setup vim so that python files automatically use PEP8-compliant indentation
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 textwidth=79 fileformat=unix nosmartindent
"au BufNewFile,BufRead *.py
"\ set tabstop=4
"\ set softtabstop=4
"\ set shiftwidth=4
"\ set textwidth=79
"\ set expandtab
"\ set autoindent
"\ set fileformat=un
autocmd Filetype ruby setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2 textwidth=80 fileformat=unix
" formatting for full stack development
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2
\ set softtabstop=2
\ set shiftwidth=2
" formatting for sql files (use spaces instead of tabs for example)
autocmd Filetype sql setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 textwidth=79 fileformat=unix
" This should set .X68 files as 68k assembly files for syntax purposes
let filetype_X68 = "asm68k"
let filetype_pal = "pascal"
" End custom formatting for specific filetypes
" --------
" -----------------
" Keystrokes
" Alternate mappings to escape so it's easier to get out of insert mode
" currently just using <Esc> and <C-[>
" Map new keybind to Escape in insert mode
imap <A-i> <Esc>
" imap <A-.> <Esc>
"imap <S-space> <Esc>
imap jk <Esc>
imap kj <Esc>
" Remap semicolon (;) to function as colon (:), saving me from holding down
" Shift everytime I want to execute a command like save (:w)
:nmap ; :
" page down with <Space> and page up with -
" noremap <Space> <PageDown>
" noremap - <PageUp>
" Change <C-e> and <C-y> from scrolling down/up 1 line to 3 lines, so we don't
" have to keep hitting it over and over as much
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" End Keystrokes
" -----------------
" in normal mode F2 will save the file
" nmap <F2> :w<CR>
" in insert mode F2 will exit insert, save, enters insert again
" imap <F2> <ESC>:w<CR>i
" -----------------
" NERDTree settings
" F2 now used for opening NERDTree and F3 for taglist
map <F2> :NERDTreeToggle<CR>
imap <F2> <C-o>:NERDTreeToggle<CR>
map <F3> :TlistToggle<CR>
imap <F3> <C-o>:TlistToggle<CR>
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let g:NERDTreeWinSize=45
" End NERDTree settings
" -----------------
" -----------------
" Highlight settings
" Turn off highlighting by double-tapping Escape
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>
" End Highlight settings
" -----------------
" -----------------
" Code folding
" see https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/#.Vi9-CN7uzXY.reddit
" Enable folding
set foldmethod=indent
set foldlevel=99
" Enable folding with spacebar
noremap <space> za
" End Code Folding settings
" -----------------
" -----------------
" Vim-Airline settings
" Enable displaying buffers at the top of the viewable area with airline
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
" Enable powerline symbols (ie. the little arrows)
let g:airline_powerline_fonts = 1
" End Vim-Airline settings
" -----------------
" -----------------
" CtrlP Settings
"
" Setup some default ignores
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|\_site)$',
\ 'file': '\v\.(exe|so|dll|class|gif|png|jpg|jpeg)$',
\}
" Use the nearest .git directory as the cwd
" This makes a lot of sense if you are working on a project that is in version
" control. It also supports works with .svn, .hg, .bzr.
let g:ctrlp_working_path_mode = 'r'
" Use a leader instead of the actual named binding
nmap <leader>p :CtrlP<cr>
" Binding to clear CtrlP cache so that on next invocation of CtrlP it will
" rescan all directories. Useful if a new file has been added since the last
" time CtrlP was used
nmap <leader>rr :CtrlPClearAllCaches<cr>
" Easy bindings for its various modes
nmap <leader>bb :CtrlPBuffer<cr>
nmap <leader>bm :CtrlPMixed<cr>
nmap <leader>bs :CtrlPMRU<cr>
" End CtrlP settings
" -----------------
" -----------------
" Buffergator settings
"
" Use right side of screen
let g:buffergator_viewport_split_policy = 'R'
" I want my own keymappings
let g:buffergator_suppress_keymaps = 1
" for some reason, using BuffergatorMruCyclePrev and BuffergatorMruCycleNext
" leads to unusual behavior once more than a few (3?) tabs are open. Switching
" to :bnext and :bprev to see if that leads to more consistent behavior
" Go to previous buffer open
nmap <leader>jj :bprev<cr>
nmap <leader>hh :bprev<cr>
" Go to next buffer open
nmap <leader>kk :bnext<cr>
nmap <leader>ll :bnext<cr>
" View the entire list of buffers open
nmap <leader>bl :BuffergatorOpen<cr>
" <comma> then T for new tab
nmap <leader>T :enew<cr>
" Close the current buffer and move to the previous one. <comma> bq
nmap <leader>bq :bp <BAR> bd #<cr>
" End Buffergator settings
" -----------------
" --------
" enable system clipboard for vim, allowing copy/paste to and from the system
" clipboard
set clipboard=unnamedplus
"---------
"---------
" Syntastic options
" Disable syntastic unless manually invoked for files that end in .html or
" .cpp
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['html','c', 'cpp', 'h'] }
"------- end Syntastic options
" --------
" YouCompleteMe settings (vim auto-completion plugin)
" references:
" * http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/
" * http://vimawesome.com/plugin/youcompleteme
" * https://github.com/neovim/neovim/issues/1315
" * https://github.com/Valloric/YouCompleteMe
" Auto-remove preview window after exiting insert mode
" (see: https://valloric.github.io/YouCompleteMe/)
let g:ycm_autoclose_preview_window_after_insertion = 1
" Global white/black list for ycm_extra_conf.py configs.
" See https://github.com/Valloric/YouCompleteMe
let g:ycm_extra_conf_globlist = ['~/sandbox/*','!~/*']
" Disable confirmation dialog asking if you want to load the ycm_extra_conf.py
" EVERY time you launch vim (which is excessive IMHO)
let g:ycm_confirm_extra_conf = 1
" let g:ycm_confirm_extra_conf = 0
" Alternate options:
" auto-close after selecting a completion string
" g:ycm_autoclose_preview_window_after_completion = 1
" Don't open the preview window at all
" set completeopt-=preview
" g:ycm_add_preview_to_completeopt = 0
" --------- End YouCompleteMe (YCM) options