-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
392 lines (325 loc) · 9.21 KB
/
vimrc
File metadata and controls
392 lines (325 loc) · 9.21 KB
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
"{{{
call plug#begin('~/.vim/plugged')
let mapleader = ","
"}}}
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-fugitive'
Plug 'tmhedberg/matchit'
Plug 'groenewege/vim-less'
Plug 'othree/html5.vim'
Plug 'chr4/nginx.vim'
Plug 'ap/vim-css-color'
Plug 'vim-scripts/Arduino-syntax-file'
" Plug 'vim-javascript'"{{{
Plug 'pangloss/vim-javascript', { 'frozen': 'true' }
let javascript_enable_domhtmlcss = 1
"}}}
" Plug 'ctrlp.vim'"{{{
Plug 'ctrlpvim/ctrlp.vim'
nmap <silent> <leader>p :CtrlP<cr>
nmap <silent> <leader>t :CtrlPMRU<cr>
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_clear_cache_on_exit = 1
"}}}
" Plug 'vim-jsx'"{{{
Plug 'mxw/vim-jsx'
let g:jsx_ext_required = 0
"}}}
" Plug 'tcomment_vim'"{{{
Plug 'tomtom/tcomment_vim'
nmap <silent> <leader>/ :TComment<cr>
xmap <silent> <leader>/ :TComment<cr>
"}}}
" Plug 'elzr/vim-json'{{{
Plug 'elzr/vim-json'
" g:vim_json_syntax_conceal = 0
let g:indentLine_concealcursor=""
"}}}
" Plug 'jiangmiao/auto-pairs'{{{
Plug 'jiangmiao/auto-pairs'
let g:AutoPairsFlyMode = 1
let g:AutoPairsCenterLine = 0
let g:AutoPairsMultilineClose = 0
"}}}
" Plug 'vim-easy-align'"{{{
Plug 'junegunn/vim-easy-align'
vmap <Enter> <Plug>(EasyAlign)
"}}}
" Plug 'vim-gitgutter'"{{{
Plug 'airblade/vim-gitgutter'
let g:gitgutter_sign_modified = '▪'
let g:gitgutter_sign_modified_removed = '▪'
" let g:gitgutter_sign_column_always = 1
"}}}
" Plug 'vim-searchant'"{{{
Plug 'timakro/vim-searchant'
let g:searchant_map_stop = 0
nmap <esc><esc> <Plug>SearchantStop
"}}}
" Plug 'MatchTagAlways'{{{
Plug 'Valloric/MatchTagAlways'
let g:mta_filetypes = { 'javascript.jsx': 1, 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1 }
"}}}
if has("mac")
set macmeta
" Plug 'YouCompleteMe'"{{{
Plug 'Valloric/YouCompleteMe'
let g:ycm_complete_in_comments = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_seed_identifiers_with_syntax = 1
"}}}
" Plug 'ultisnips'"{{{
Plug 'SirVer/ultisnips'
let g:UltiSnipsSnippetsDir='~/.vim/snips'
let g:UltiSnipsSnippetDirectories=['snips' , 'UltiSnips']
"}}}
" Plug 'emmet-vim'"{{{
Plug 'mattn/emmet-vim'
let g:user_emmet_expandabbr_key = '<S-space>'
"}}}
" Plug 'syntastic'"{{{
Plug 'scrooloose/syntastic'
let g:syntastic_auto_jump = 1
let g:syntastic_enable_signs = 1
let g:syntastic_mode_map = {
\ 'mode': 'active',
\ 'passive_filetypes': ['html'] }
let g:syntastic_javascript_checkers = ['eslint']
" }}}
endif
if has("gui_running")
Plug 'gerw/vim-HiLinkTrace'
" Plug 'indentLine'"{{{
Plug 'Yggdroot/indentLine'
let g:indentLine_char = ''
let g:indentLine_color_gui = '#393939'
"}}}
endif
call plug#end()
" MISC KEY MAPS"{{{
nmap <tab> %
nmap k gk
nmap j gj
imap jj <esc>
nnoremap <silent>K :bd<cr>
map . .`[
nnoremap Q @q
nnoremap <silent> * eb:let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
nmap <silent> gn :cnext<cr>
nmap <silent> gN :cprev<cr>
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <silent> <cr> :w<cr>
nnoremap <space> za
nnoremap <S-space> zM
nmap <silent> <leader>ev :e ~/.vim/vimrc<cr>
nmap <silent> <leader>b :b#<cr>
"}}}
" BASIC EDITING CONFIGURATION"{{{
set encoding=utf-8
set mouse=a
" allow unsaved background buffers and remember marks/undo for them
set hidden
" remember more commands and search history
set history=10000
set expandtab
set tabstop=3
set shiftwidth=3
set softtabstop=3
set autoindent
set laststatus=2
set showmatch
set matchtime=2
set incsearch
" make searches case-sensitive only if they contain upper-case characters
set ignorecase smartcase
set number
set cmdheight=1
set switchbuf=useopen
set numberwidth=5
set winwidth=79
" set shell=/bin/zsh
set shell=/bin/bash\ -l
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" keep more context when scrolling off the end of a buffer
set scrolloff=2
" Store temporary files in a central spot
set nobackup
set noswapfile
" set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" display incomplete commands
set showcmd
set completeopt-=preview
" Enable highlighting for syntax
syntax on
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Use OSX/Win Clipboard
set clipboard=unnamed
" Get rid of the left scrollbar in vsplit
set go-=L
set foldmethod=marker
set foldcolumn=0
set foldopen-=block
set autoread
set wildignore+=.git,node_modules/**,.git/**
set pumheight=10
let &previewheight=&lines / 2
set lines=50
set columns=120
" Get rid of wrapping
set textwidth=0
set wrapmargin=0
set nowrap
set autochdir
"}}}
" COLOR AND GUI"{{{
set background=dark
colorscheme monokaibright
set list
set cursorline
set listchars=tab:\ \ ,eol:¬
set fillchars=fold:\
set guifont=Menlo:h14
set linespace=1
set guioptions-=T
set guioptions-=m
set guioptions-=r
set guicursor+=n-v-ve:blinkoff0-Cursor
set guicursor+=i:ver25-iCursor
set statusline=%<%.99f\ %h%w%m%r\
set statusline+=%{SL('fugitive#statusline')}\ %#errormsg#%{SL('SyntasticStatuslineFlag')}%*
set statusline+=%=
set statusline+=\ %y\
set statusline+=[%{&ff}]\
set statusline+=[%{\"\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"\\"}%k]\
"}}}
" SUPERTAB"{{{
if has("mac")
function! g:UltiSnips_Complete()
call UltiSnips#ExpandSnippet()
if g:ulti_expand_res == 0
if pumvisible()
return "\<C-n>"
else
call UltiSnips#JumpForwards()
if g:ulti_jump_forwards_res == 0
return "\<TAB>"
endif
endif
endif
return ""
endfunction
function! g:UltiSnips_Reverse()
call UltiSnips#JumpBackwards()
if g:ulti_jump_backwards_res == 0
return "\<C-P>"
endif
return ""
endfunction
if !exists("g:UltiSnipsJumpForwardTrigger")
let g:UltiSnipsJumpForwardTrigger = "<tab>"
endif
if !exists("g:UltiSnipsJumpBackwardTrigger")
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
endif
au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsJumpBackwardTrigger . " <C-R>=g:UltiSnips_Reverse()<cr>"
endif
"}}}
" AUTOCMD"{{{
" Reload on save
autocmd! bufwritepost ~/.vim/vimrc source ~/.vim/vimrc
autocmd! bufwritepost monokaibright.vim colorscheme monokaibright
" Tap indent in visual mode
autocmd VimEnter * xmap <tab> >gv
autocmd VimEnter * xmap <s-tab> <gv
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" No bell
autocmd VimEnter * set vb t_vb=
autocmd BufNewFile,BufRead *rc set filetype=json
autocmd BufNewFile,BufRead vimrc set filetype=vim
autocmd BufNewFile,BufRead nginx.conf setlocal commentstring=#\ %s
"}}}
" FUNCTIONS"{{{
" GoFile {{{
fun! g:GoFile()
if !empty(matchstr(getline("."), '<'))
if !empty(matchstr(getline("."), '<Route'))
if !empty(matchstr(getline("."), 'require'))
exe 'norm! $F.gf'
else
exe "norm! mz0/component\<cr>/{\<cr>wve\"xygg"
call search(@x)
exe "norm! \"xyi\"`z"
exe "edit " . @x
endif
else
exe "norm! mz0f<wve\"xygg"
call search(@x)
exe "norm! \"xyi\"`z"
exe "edit " . @x
endif
else
exe 'norm! $F.gf'
endif
endf
"}}}
nnoremap <silent> gf :call g:GoFile()<cr>
set foldtext=MyFoldText()
" StripFoldText"{{{
fun! StripFoldText(f, m)
let c = substitute(&commentstring, '%s', a:m, '') " replace the commentstring %s with the real one
let c = substitute(c, '\*', '\\*', 'g') " escape * if present
let f = substitute(a:f, c, '', '') " strip the commentstring with marker
let f = substitute(f, a:m, '', '') " strip the marker only
return f
endf
"}}}
" MyFoldText"{{{
fun! MyFoldText()
let markerstart = strpart(&foldmarker, 0, 3)
let markerend = strpart(&foldmarker, 4, 3)
let foldstart = StripFoldText(getline(v:foldstart), markerstart)
let foldend = StripFoldText(getline(v:foldend), markerend)
let foldend = substitute(foldend,'^\s\+', '', '')
if (foldend == "")
if (foldstart == "")
return "..."
else
return foldstart . " ..."
endif
else
return foldstart . " ... " . foldend
endif
endf
"}}}
" SL"{{{
fun! SL(function)
if exists('*'.a:function)
return call(a:function,[])
else
return ''
endif
endf
"}}}
"}}}
" fixme:
autocmd FileType php setlocal omnifunc=
" autocmd FileType javascript set formatprg=prettier\ --stdin\ --tab-width=2
" autocmd BufWritePre *.js exe "normal! gggqG\<C-o>\<C-o>"
" autocmd FileType javascript.jsx,javascript setlocal formatprg=prettier\ --stdin\ --tab-width=3