-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc
351 lines (287 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
342
343
344
345
346
347
348
349
350
"------------------------------------------------------------------[Vundle]----
source ~/.vim/bundles.vim
"------------------------------------------------------------------[General]----
" Create the 'vimrc' autocmd group, used below, and immediately clear it in
" case this file is being sourced a second time.
augroup vimrc | execute 'autocmd!' | augroup END
filetype plugin indent on " required!
syntax on
"default vim background color for monokai theme:
let g:molokai_original=1
set t_Co=256
colorscheme molokai
"run syntax check on entire document
autocmd BufEnter * :syntax sync fromstart
" typescript template syntax
"attempt to fix weird background color issues
"shouldn't need to mess with this because tmux alias yay
"set term=screen-256color
"set term=xterm-256color
set shell=/bin/zsh
set lazyredraw
set nowrap
set colorcolumn=90
"disable auto commenting:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
set backspace=indent,eol,start
" to disable the global markers
" set shada="NONE"
" set tabstop=4
" set softtabstop=4
" set shiftwidth=4
set expandtab
set background=dark
set autoindent
" set smartindent
"generic folding settings
set foldmethod=syntax
set foldcolumn=1
let javaScript_fold=1
set foldnestmax=10 "allowed depth of sub-folds
set nofoldenable "dont fold by default
set foldlevelstart=99 "needed for some reason to not fold everything
" set foldlevel=1 "this is just what i use
set mouse=r
set number
"change the leader from backslash
let mapleader=","
"set working directory to current file path
set autochdir
"when pasting into vim:
set pastetoggle=<F10>
"---------------------------------[Search]----
set hlsearch
set incsearch
set smartcase
set ignorecase
set wildmenu
"window split settings
set splitbelow
set splitright
"allow vilual block cursor to go anywhere
set virtualedit=block
"powerline/airline stuffs:
" Always show statusline
set laststatus=2
let g:airline_powerline_fonts = 1
" let g:airline_theme='powerlineish'
let g:airline_theme='murmur'
" let g:airline_theme='molokai'
" let g:airline_theme='luna'
" Enable the list of buffers
" let g:airline#extensions#tabline#enabled = 1
" " Show just the filename
" let g:airline#extensions#tabline#fnamemod = ':t'
" workaround to deal with laggy response
if ! has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
"potatoes
"green
" vnoremap yy "py
"easier window navigation
nnoremap <silent> <Tab> :wincmd w<CR>
nnoremap <silent> <S-Tab> :wincmd W<CR>
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
"jumping to beginning and end of lines
noremap B ^
noremap E $
" vim quickscope repurposing t to jump to second blue match
" noremap t 2f
" noremap T 2F
"open file looking thing in new tab
"map gf :tabedit <cfile><CR>
"syntax coloring for arduino
au BufRead,BufNewFile *.ino set filetype=cpp
au BufRead,BufNewFile *.vue set filetype=html
" workaround for neovim and tcomment plugin bug
au BufNewFile,BufRead *.jsx setlocal filetype=javascript.jsx
"javascript folding
" function! s:JavascriptFileType()
" "set nofoldenable
" " set foldlevelstart=0
" " fold methods available: syntax indent marker
" " set foldmethod=indent
" " set foldignore=
" " set foldnestmax=1
"
"
" " "Refocus" folds
" nnoremap ,z zMzvzz
"
" " Make zO recursively open whatever top level fold we're in, no matter where the
" " cursor happens to be.
" nnoremap zO zCzO
" endfunction
" set conceallevel=1
" because stupid work decided to use 4 spaces on html
" autocmd filetype type args
au FileType make setlocal ts=2 sts=2 tw=2 noet
au Filetype html setlocal ts=2 sts=2 sw=2
au Filetype javascript setlocal ts=2 sts=2 sw=2
au Filetype javascriptreact setlocal ts=2 sts=2 sw=2 expandtab
au Filetype php setlocal ts=4 sts=4 sw=4
au Filetype yaml setlocal ts=2 sts=2 sw=2 expandtab
au Filetype typescript setlocal ts=2 sts=2 sw=2 expandtab
au Filetype json setlocal ts=2 sts=2 sw=2 expandtab
au BufNewFile,BufRead Jenkinsfile setf groovy
" let g:SignatureForceRemoveGlobal = 0
" deal with drag issues when in tmux
" set mouse+=a
if &term =~ '^screen'
" tmux knows the extended mouse mode
set ttymouse=xterm2
endif
"nerdTree
nnoremap <C-f> :NERDTree<CR>
" tcomment:
" let g:polyglot_disabled = ['jsx']
"swap the layouts of horozontal and vertical
"noremap <C-w>h :windo wincmd H<CR>
"noremap <C-w>t :windo wincmd K<CR>
"merge tabs into single page
noremap <C-w>m :Tabmerge<CR>
"ctrlP
" let g:ctrlp_match_func = {'match': 'cpsm#CtrlPMatch'}
let g:ctrlp_max_files=0
noremap <C-B> :CtrlPBuffer<CR>
let g:ctrlp_prompt_mappings = {
\ 'PrtSelectMove("j")': ['<c-t>', '<down>'],
\ 'PrtSelectMove("k")': ['<c-n>', '<up>'],
\ 'CreateNewFile()': ['<c-f>'],
\ 'ToggleType(1)': ['<c-u>', '<c-up>'],
\ 'PrtClear()': ['<c-g>'],
\ 'PrtHistory(-1)': ['<c-b>'],
\ 'ToggleType(-1)': ['<c-down>'],
\ 'PrtExit()': ['<esc>', '<c-c>'],
\ }
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let g:ctrlp_use_caching = 1
"for windowswap plugin:
"should learn keyboard commands though
let g:windowswap_map_keys = 0 "prevent default bindings
nnoremap <silent> <leader>yw :call WindowSwap#MarkWindowSwap()<CR>
nnoremap <silent> <leader>pw :call WindowSwap#DoWindowSwap()<CR>
nnoremap <silent> <leader>ww :call WindowSwap#EasyWindowSwap()<CR>
"enable matchit plugin:
" runtime macros/matchit.vim
"vim-javascript syntax plugin highlighting enable
let g:javascript_enable_domhtmlcss = 1
"map <F5> <Esc>:EnableFastPHPFolds<Cr>
"map <F6> <Esc>:EnablePHPFolds<Cr>
"map <F7> <Esc>:DisablePHPFolds<Cr>
"to prevent annoying behavior of the folding plugin
let g:DisableAutoPHPFolding = 1
function! PhpSyntaxOverride()
"folding stuff
let php_folding=0
setlocal foldmethod=manual
" EnableFastPHPFolds
EnablePHPFolds
normal zR
"syntax stuff
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
" check file change every 4 seconds ('CursorHold') and reload the buffer upon detecting change
set autoread
au CursorHold * checktime
"do better auto complete brace behavior:
let delimitMate_expand_cr = 1
"let delimitMate_jump_expansion = 0
let delimitMate_expand_space = 1
let delimitMate_matchpairs = '(:),{:},[:]'
" look into this:
"https://github.com/chrisbra/vim_dotfiles/blob/master/plugin/CustomFoldText.vim
"syntastic:
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
"vim-go:
let g:go_autodetect_gopath = 1
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
let g:easy_align_ignore_groups = []
"move between splits:
nnoremap <C-H> <C-W><C-H>
nnoremap <C-T> <C-W><C-J>
nnoremap <C-N> <C-W><C-K>
nnoremap <C-S> <C-W><C-L>
"neovim stuff; move between terminal splits
if has('nvim')
tnoremap <Esc> <C-\><C-n>
tnoremap <C-h> <C-\><C-n><C-w>h
tnoremap <C-t> <C-\><C-n><C-w>j
tnoremap <C-n> <C-\><C-n><C-w>k
tnoremap <C-s> <C-\><C-n><C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-t> <C-w>j
nnoremap <C-n> <C-w>k
nnoremap <C-s> <C-w>l
endif
"moving splits around
nnoremap <C-w>S <C-w>L
nnoremap <C-w>T <C-w>J
nnoremap <C-w>N <C-w>K
com! ToJson %s/\(\w*\):/"\1"/
function! ToggleMouse()
" check if mouse is enabled
if &mouse == 'a'
" disable mouse
set mouse=
else
" enable mouse everywhere
set mouse=a
endif
endfunc
com! FormatJSON %!python -m json.tool
" fix weird bug that makes underscores (_) invisible with kitty
set linespace=5
" vim-fugitive gdiff direction
set diffopt+=vertical
" suda.vim save as root
let g:suda_smart_edit = 1
" eslint support
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint'],
\ 'javascriptreact': ['eslint'],
\}
let g:ale_sign_error = '✖'
let g:ale_sign_warning = '⚠'
let g:ale_fix_on_save = 1
" manually trigger with ALEFix
"coc
"coc.vim tab complete
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
" coc.vim autocomplete on tab
inoremap <silent><expr> <Tab> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>"
"reference:
"tabm <number> moves tab to that location.
"example: tabm 0 moves tab to location 0 (first location)
"
"let @a = ':s/row\['\(\w*\)'\]/row->\1/g'
" :s/row\['\(\w*\)'\]/row->\1/g
"move existing window into new tab:
":tabedit %<CR>
"freedom in visual mode
" :set virtualedit=all
" then use Afoo to instert multiple columns