-
Notifications
You must be signed in to change notification settings - Fork 4
/
vimrc
executable file
·496 lines (432 loc) · 13.7 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
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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
" |-----------------------------|
" | Author: Stephen Huh |
" | Email: stephenhuh@gmail.com |
" |-----------------------------|
" [ Plugin Setup ]{{{1
set nocompatible
filetype off
call plug#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" Delimiter - Close Quotes, Brackets, Etc
Plugin 'raimondi/delimitmate'
" Github Wrapper
Plugin 'tpope/vim-fugitive'
" Surround Text Shortcuts
Plugin 'tpope/vim-surround'
" Commenting Shortcuts
Plugin 'scrooloose/nerdtree'
" Syntax Checker
Plugin 'scrooloose/syntastic'
" Visualize Undos
Plugin 'sjl/gundo.vim'
" Github Gist Wrapper
Plugin 'mattn/gist-vim'
Plugin 'bling/vim-airline'
Plugin 'airblade/vim-gitgutter'
Plugin 'edkolev/promptline.vim'
Plugin 'tommcdo/vim-exchange'
Plugin 'terryma/vim-multiple-cursors'
" Code Completion using native search via tab
Plugin 'ervandew/supertab'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'mattn/emmet-vim'
Plugin 'gabesoft/vim-ags'
" Load Schemes Automatically
Plugin 'flazz/vim-colorschemes'
Plugin 'catpuccin/nvim', { 'as' : 'catpuccin' }
Plugin 'marcweber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
" Sick Snippets - See Customs within Shellconfig
Plugin 'honza/vim-snippets'
Plugin 'garbas/vim-snipmate'
Plugin 'heavenshell/vim-jsdoc'
Plugin 'evidens/vim-twig'
" es6
Plugin 'isRuslan/vim-es6'
" vim-scripts
Plugin 'Tabular'
" File Explorer
Plugin 'ctrlp.vim'
Plugin 'matchit.zip'
Plugin 'ack.vim'
" Seti Theme
Plugin 'trusktr/seti.vim'
" Syntax highlighting for Pug/Jade
Plugin 'digitaltoad/vim-jade'
" Elm Compilation and Formatting
"Plugin 'elmcast/elm-vim'
" CTags Viewer
Plugin 'majutsushi/tagbar'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-easytags'
"Javascript
Plugin 'pangloss/vim-javascript'
"Plugin 'mxw/vim-jsx'
let g:jsx_ext_required = 0
"let g:syntastic_javascript_jsxhint_exec = 'jsx-jshint-wrapper'
call plug#end()
filetype plugin indent on
" [ Preferences ] {{{1
let mapleader = " " " Set global mapleader to space
set noswapfile
set autoindent
set smartindent
set hidden " Useful for auto setting hidden buffers
syntax enable " Enable syntax highlighting
set nostartofline " Don't reset cursor to start of line when moving around
set ttyfast
set history=1000
" Reduce delay in switching modes
" https://www.johnhawthorn.com/2012/09/vi-escape-delays/
" Needs time to process "j k" keys
set timeoutlen=150 ttimeoutlen=0
" Searching/Moving {{{2
" nnoremap / /\v
" vnoremap / /\v
set gdefault " Add the g flag to search/replace by default
set incsearch " Highlight dynamically as pattern is typed
" set hlsearch
set ignorecase " Ignore case when searching
set smartcase " Try and be smart about cases
nnoremap j gj
nnoremap k gk
" Appearance {{{2
set number " Always show line numbers
set numberwidth=3 " Changed the width of line number columns
set listchars=tab:\|\ ,trail:·,eol:¬ " Use new symbols for tabstops and EOLs
set tabstop=2 " The width of a TAB is set to 4.
" Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
set shiftwidth=2 " Indents will have a width of 4
set softtabstop=2 " Sets the number of columns for a TAB
set expandtab " Expand TABs to spaces
set backspace=indent,eol,start
set showcmd " Shows incomplete command
execute "set colorcolumn=" . join(range(101,335), ',')
set novb noeb " Turn off visual bell and remove error beeps
set splitbelow " New window goes below
set splitright " New windows goes right
set wildmenu " Enhance command-line completion
set wildmode=longest:full,full
set wildignore+=*.jpg,*.jpeg,*.gif,*.png,*.gif,*.psd,*.o,*.obj
set wildignore+=*/smarty/*,*/vendor/*,*/node_modules/*,*/.hg/*,*/.svn/*,*/.sass-cache/*,*/log/*,*/tmp/*,*/build/*,*/ckeditor/*,*.DS_Store
set encoding=utf-8
set cursorline " Highlight current line
set laststatus=2 " Always show the statusline
set t_Co=256 " Explicitly tell Vim that the terminal supports 256 colors
" Colors and Theme {{{2
set background=dark
colorscheme catpuccin
" [ Auto Commands ] {{{1
" Auto source vimrc on save {{{2
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }
" Restore cursor position {{{2
if has("autocmd")
filetype plugin indent on
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
" Set filetype {{{2
if has("autocmd")
au BufNewFile,BufRead *.hbs set ft=html
endif
" Save on losing focus {{{2
au FocusLost * :wa
" Resize splits when window is resized {{{2
au VimResized * exe "normal! \<c-w>="
" Clean up nasty wysiwig html {{{2
" Install pandoc first
" https://code.google.com/p/pandoc/downloads/list
function! FormatprgLocal(filter)
if !empty(v:char)
return 1
else
let l:command = v:lnum.','.(v:lnum+v:count-1).'!'.a:filter
echo l:command
execute l:command
endif
endfunction
if has("autocmd")
let pandoc_pipeline = "pandoc --from=html --to=markdown"
let pandoc_pipeline .= " | pandoc --from=markdown --to=html"
autocmd FileType html setlocal formatexpr=FormatprgLocal(pandoc_pipeline)
endif
" [ Mappings ] {{{1
" Stuff {{{2
cmap w!! %!sudo tee> /dev/null %
command! W w " Remap :W to :w
nnoremap Y y$ " Yank to end of line with Y
nnoremap D d$ " Delete to end of line with D
nmap _j vipJV"+yu " For a SO question i answered, joins lines and copies to system clipboard
" like gv but for pasted text
" nnoremap <leader>v V`]
" :Wrap to wrap lines command! -nargs=* Wrap set wrap linebreak nolist
" Visual Selection {{{2
" Fix linewise visual selection of various text objects
nnoremap Vat vatV
nnoremap Vab vabV
nnoremap VaB vaBV
" Don't move on *
nnoremap * *<c-o>
" Visually select the text that was last edited/pasted
nmap gV `[v`]
" Escaping {{{2
inoremap <C-c> <ESC>
inoremap jk <ESC>
" Enable esc for people using my computer lol
" vno v <esc>
" inoremap <esc> <NOP>
" Force quit that bitch
nmap fq :q!<CR>
" Filetype {{{2
nmap _ht :set ft=html<CR>
nmap _ph :set ft=php<CR>
nmap _py :set ft=python<CR>
nmap _rb :set ft=ruby<CR>
nmap _js :set ft=javascript<CR>
nmap _zs :set ft=zsh<CR>
nmap _md :set ft=mkd<CR>
nmap _vi :set ft=vim<CR>
nmap <F7> :TagbarToggle<CR>
" Folding {{{2
nnoremap <Tab> za
" Use leader z to "focus" the current fold
nnoremap <leader>z zMzvzz
" Auto load views
" http://vim.wikia.com/wiki/Make_views_automatic
autocmd BufWinLeave *.* mkview!
autocmd BufWinEnter *.* silent loadview
" Bubble single lines {{{2
nmap <C-Up> [e
nmap <C-Down> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
" Window Switching {{{2
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Window Resizing {{{2
" nnoremap <Left> :vertical resize +1<CR>
" nnoremap <Right> :vertical resize -1<CR>
" nnoremap <Up> :resize +1<CR>
" nnoremap <Down> :resize -1<CR>
" Insert Movement {{{2
imap <C-e> <C-o>$
imap <C-a> <C-o>0
imap <C-f> <C-o>l
imap <C-b> <C-o>h
" Indent Mapping {{{2
nmap <D-[> <<
nmap <D-]> >>
vmap <D-[> <gv
vmap <D-[> >gv
" Viewport Scrolling {{{2
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Syntax highlighting groups for word under cursor {{{2
" nmap <C-S-P> :call <SID>SynStack()<CR>
" function! <SID>SynStack()
" if !exists("*synstack")
" return
" endif
" echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
" endfunc
" Awesome fucking pasting {{{2
function! WrapForTmux(s)
if !exists('$TMUX')
return a:s
endif
let tmux_start = "\<Esc>Ptmux;"
let tmux_end = "\<Esc>\\"
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
endfunction
let &t_SI .= WrapForTmux("\<Esc>[?2004h")
let &t_EI .= WrapForTmux("\<Esc>[?2004l")
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
" Fuck F1 one help to rule them all :h {{{2
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" [ Leader Mappings ] {{{1
" Save a file -- fs {{{2
nmap <leader>fs :w<CR>
" Update vimrc -- v OR ev {{{2
nmap <leader>v :tabedit $MYVIMRC<CR>
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
" Update snipmate -- sc {{{2
nmap <leader>sc :tabedit ~/.vim/bundle/vim-snippets/snippets<CR>
" Toggle Highlighting -- h {{{2
nmap <silent> <leader>h :set hlsearch!<CR>
" Toggle Spell Checking -- s {{{2
nmap <silent> <leader>s :set spell!<CR>
" Toggle set list -- l {{{2
nmap <Leader>l :set list!<CR>
" Ag -- a {{{2
nmap <Leader>a :Ags<SPACE>
" Surround selection with -- ` ' " {{{2
" Surround selection with backticks
nnoremap <leader>` 0v$S`
" Surround selection with "
nmap <leader>" viwS"
" Surround selection with '
nmap <leader>' viwS'
" Tab Editing {{{2
" Useful mappings for managing taps
" map <leader>tn :tabnew<cr>
" map <leader>to :tabonly<cr>
" map <leader>tc :tabclose<cr>
" map <leader>tm :tabmove<cr>
" map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Buffers {{{2
nmap <leader>T :enew<cr>
" Move between buffer (Prefer default mappings)
nmap <leader>l :bnext<CR>"
nmap <leader>h :bprevious<CR>
" Show all open buffers
nmap <leader>bl :ls<CR>
" Extras for now {{{2
"Fold an html container
nnoremap <leader>ft Vatzf
"I think this sorts css
nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
vnoremap <leader>y "*y
" Alphabetically sort CSS properties in file with :SortCSS
" :command! SortCSS :g#\({\n\)\@<=#.,/}/sort
" [ Functions ]{{{1
" Remove trailing white space {{{2
function! Preserve(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
execute a:command
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nmap _$ :call Preserve("%s/\\s\\+$//e")<CR>
nmap _= :call Preserve("normal gg=G")<CR>
" Prune the arglist for matches
command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()
function! QuickfixFilenames()
" Building a hash ensures we get each buffer only once
let buffer_numbers = { }
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
endfunction
" map <leader>t :call RunTestFile()<cr>
" map <leader>T :call RunNearestTest()<cr>
" Visual Mode */# from Scrooloose {{{2
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o>
" [ Plugins ] {{{1
" SnipMate & DelimitMate Compatibiity {{{2
" Prevent S-Tab conflict with DelimitMate
imap <C-d> <Plug>snipMateBack
" vmath {{{2
vmap <expr> ++ VMATH_YankAndAnalyse()
nmap ++ vip++
" Easy-motion {{{2
let g:EasyMotion_leader_key = ','
hi EasyMotionTarget ctermbg=none ctermfg=DarkRed
" hi EasyMotionShade ctermbg=none ctermfg=DarkGray
" Emmet {{{2
let g:user_emmet_leader_key = '<c-e>'
"Fugitive Git {{{2
nmap <leader>ga :Git add -A<CR>
nmap <leader>gc :Gcommit -a<CR>
nmap <leader>gp :Git push<CR>
" CtrlP {{{2
let g:ctrlp_match_window_bottom = 0 " Show at top of window
let g:ctrlp_working_path_mode = 2 " Smart path mode
let g:ctrlp_mru_files = 1 " Enable Most Recently Used files feature
let g:ctrlp_jump_to_buffer = 2 " Jump to tab AND buffer if already open
let g:ctrlp_split_window = 1 " <CR> = New Tab
let g:ctrlp_max_files=0
let g:ctrlp_max_depth=40
" MultipleCursors {{{2
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_quit_key='<C-c>'
" Mustache {{{2
let g:mustache_abbreviations = 1
" NerdTree {{{2
" autocmd vimenter * if !argc() | NERDTree | endif " Load NERDTree by default for directory
map <C-n><C-t> :NERDTreeToggle<CR>
map <leader>n :NERDTreeToggle<CR>
" Airline {{{2
" comment line below to run on Ubuntu
let g:airline#extensions#tabline#enabled = 1
" Syntastic {{{2
let g:syntastic_auto_loc_list = 1
let g:syntastic_loc_list_height = 5
let g:syntastic_python_python_exec = '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3'
nmap <leader>st :SyntasticToggleMode<cr>
nmap <leader>sc :SyntasticCheck<cr>
let g:syntastic_mode_map = {"mode" : "passive", 'passive_filetypes': ['java','cpp', 'py', 'html']}
let g:jsx_ext_required = 1
let g:syntastic_javascript_checkers = ['eslint']
" Toggle errors
" Tabularize {{{2
if exists(":Tabularize")
nmap <leader>t= :Tabularize /=<CR>
vmap <leader>t= :Tabularize /=<CR>
nmap <leader>t: :Tabularize /:\zs<CR>
vmap <leader>t: :Tabularize /:\zs<CR>
nmap <leader>t> :Tabularize /=><CR>
vmap <leader>t> :Tabularize /=><CR>
endif
" Ag The Silver Searcher {{{2
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" JsDoc {{{2
nmap <silent> <leader>js <Plug>(jsdoc)
" Git Gutter {{{2
let g:gitgutter_enabled = 0
let g:gitgutter_highlight_lines = 1
nmap <leader>gt :GitGutterToggle<cr>
" Some other syntax {{{2
au BufNewFile,BufRead *.ejs set filetype=html
" au BufNewFile,BufRead *.jade set filetype=html
" au BufNewFile,BufRead *.pug set filetype=html
"}}}
" [ Modeline ] {{{1
set modelines=1
" }}}
" [ C/C++ ] {{{1
" map <F8> :w <CR> :!gcc -std=c++1y % -o %< && ./%< <CR>
map <F9> :w <CR> :!cc % -o %< && ./%< <CR>
set shell=bash\ -i
" [ Elm ] {{{1
let g:elm_format_autosave = 1
" }}}
" [ Project Specific VIMRC ] {{{1
set exrc
" }}