-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvimrc
More file actions
419 lines (341 loc) · 11.2 KB
/
vimrc
File metadata and controls
419 lines (341 loc) · 11.2 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
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
set rtp+=~/.vim/bundle/Vundle.vim
set rtp+=/opt/homebrew/opt/fzf
call vundle#begin("~/.vim/bundle/plugins")
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" TODO:
" Add selet-next-block plugin stuff
" Add all my custom snippets (snipmate has a new interface now)
" Add and configure an autocopletion plugin system
" Investigate using unite.vim to replace [ctrlp, ctrlspace, ack]
Plugin 'MarcWeber/vim-addon-mw-utils' " Used by snipmate
Plugin 'Raimondi/delimitMate'
Plugin 'majutsushi/tagbar'
Plugin 'Yggdroot/indentLine'
Plugin 'airblade/vim-gitgutter'
Plugin 'vim-ctrlspace/vim-ctrlspace'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'easymotion/vim-easymotion'
" Plugin 'mileszs/ack.vim' " Replaced by fzf + ripgrep
Plugin 'tomtom/tcomment_vim'
Plugin 'tpope/vim-fugitive'
" Plugin 'pangloss/vim-javascript' " Conflicts with yats.vim for TS/JS
Plugin 'goldfeld/vim-seek'
Plugin 'tpope/vim-repeat'
Plugin 'scrooloose/nerdtree'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tomtom/tlib_vim' " Used by snipmate
Plugin 'tpope/vim-surround'
Plugin 'dense-analysis/ale'
Plugin 'jparise/vim-graphql'
Plugin 'tmhedberg/matchit'
Plugin 'neoclide/coc.nvim', {'branch': 'release'}
" fzf + ripgrep for fast search
Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plugin 'junegunn/fzf.vim'
" Comprehensive language pack (TypeScript, JSX, etc.)
Plugin 'sheerun/vim-polyglot'
" GitHub integration for vim-fugitive (:GBrowse)
Plugin 'tpope/vim-rhubarb'
" Undo tree visualization
Plugin 'mbbill/undotree'
"Coc Setup Stuff:
"On new install:
"":CocInstall coc-tsserver coc-eslint coc-prettier coc-json coc-snippets coc-git
nnoremap <leader>t :CocList outline<CR>
" CoC navigation
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <leader>rn <Plug>(coc-rename)
nmap <leader>ca <Plug>(coc-codeaction-cursor)
nmap <silent> [d <Plug>(coc-diagnostic-prev)
nmap <silent> ]d <Plug>(coc-diagnostic-next)
" Show documentation with <leader>k (K is used for 5k scrolling)
nnoremap <silent> <leader>k :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" fzf configuration
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.8 } }
nnoremap <leader>f :Rg<CR>
nnoremap <leader>F :Rg <C-r><C-w><CR>
nnoremap <leader>B :Buffers<CR>
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype on " Automatically detect file types. set nocompatible " no vi compatibility.
" Add recently accessed projects menu (project plugin)
set viminfo^=\!
"let terminal resize scale the internal windows
au VimResized * :wincmd =
" Minibuffer Explorer Settings
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" alt+n or alt+p to navigate between entries in QuickFix
map <silent> <m-p> :cp <cr>
map <silent> <m-n> :cn <cr>
syntax enable
set hidden " Needed by ctrl-space plugin. Don't fully understand this line
set cf " Enable error files & error jumping.
set clipboard=unnamed " Yanks go on clipboard instead.
set history=256 " Number of things to remember in history.
set autowrite " Writes on make/shell commands
set autoread " reloads upon file change
set ruler " Ruler on
set nu " Line numbers on
set nowrap " Line wrapping off
set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay)
set colorcolumn=80 "Set column 80 to be grey. Contain code width
" Formatting
set ts=2 " Tabs are 2 spaces
set bs=2 " Backspace over everything in insert mode
set shiftwidth=2 " Tabs under smart indent
set incsearch
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case
set formatoptions=tcqr
set cindent
set autoindent
set smarttab
set expandtab
" Visual
set showmatch " Show matching brackets.
set mat=5 " Bracket blinking.
set list
" Show $ at end of line and trailing space as ~
set lcs=tab:\ \ ,eol:$,trail:~,extends:>,precedes:<
set novisualbell " No blinking .
set noerrorbells " No noise.
set noeb vb t_vb=
set laststatus=2 " Always show status line.
" gvim specific
set mousehide " Hide mouse after chars typed
set mouse=a " Mouse in all modesc
" set antialias
"Personal Customizations
" Insert the directory of the current buffer in command line mode
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
"leader mappings
let mapleader = ","
"Make redo easier
noremap r <c-r>
"Dont lose r's funktionality
noremap <leader>r r
"So I can copy a whole line without the newline like yy has
noremap Y y$
"So I can duplicate and coment in one keystroke
vmap gy ygvgc<ESC>P
nmap gyy yyPgccj
"map cap h and cap l to beg and end of line=more intuitive
noremap H ^
noremap L $
vnoremap L g_
noremap <leader>H H
noremap <leader>L L
"mm to go to matching
map m %
noremap <leader>mm m
"M go to hilight till the rest of this {} block
noremap M $v%
noremap MM ^v%
"keep M's functionality:
noremap <leader>M M
"semicolon as colon
map ; :
map :qqq :q!<CR>
"to keep original semicolon functionality:
noremap ;; ;
"escape is hard to reach so map kj to <ESC>
inoremap kj <ESC>l
" nnoremap kj <ESC>
vnoremap kj <ESC>
"scroll up and down faster with J and K
noremap K 5k
noremap J 5j
"keep functionality of K and J with <leader>J/K
noremap <leader>K K
noremap <leader>J J
"easily escape and save from within insert mode
inoremap ww <ESC>:w<Return>l
"normal text selection in insert mode
if has("gui_macvim")
let macvim_hig_shift_movement = 1
"Add hilight to current line only in MacVim
au WinLeave * set nocursorline
au WinEnter * set cursorline
set cursorline
endif
" Sudo to write
cnoremap w!! w !sudo tee % >/dev/null
"For editing the vimrc more easily:
nnoremap <leader>ev :vs $MYVIMRC<CR>
nnoremap <leader>sv :so $MYVIMRC<CR>
"For editing the complaints file more easily:
nnoremap <leader>ec :vs ~/.vim/complaints.txt<CR>
"For editing the complaints file more easily:
nnoremap :todo :vs ~/Dropbox/notes/todo.txt<CR>
"For accessing the scratchpad file more easily:
" nnoremap <leader>es :e ~/Dropbox/notes/scratchPad.txt<CR>
nnoremap <leader>es :e /Users/samvit/Library/Mobile Documents/iCloud~md~obsidian/Documents/Notes/ScratchPad.md<CR>
"For editing the bashrc file more easily:
nnoremap <leader>eb :vs ~/.bashrc<CR>
"For editing the personal_log more easily:
nnoremap <leader>el :vs ~/.personal_log<CR>
"colors
set t_Co=256
colorscheme vividchalk
" colorscheme molokai
"colorscheme morning
"colorscheme mustang
"other stuff
set nolist
set incsearch
set ignorecase
set smartcase
set scrolloff=3 "So the cursor doesnt get lost on the edge
set wildmode=longest,list
set nobackup
set noswapfile
" Persistent undo - survives closing and reopening files
set undofile
set undodir=~/.vim/undo
nnoremap <leader>u :UndotreeToggle<CR>
filetype plugin indent on
set listchars=tab:>.,trail:.,extends:#,nbsp:.
set gfn=Monaco:h12
"this is to toggle the smart indent which messes up pasting
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2> "F2 toggles paste in insert mode too
set showmode "show the change to the user
set shortmess=a
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1 "this is just what I use
"Syntax hilight ejs files as html+js -- edit killed this after i added the vim-jst plugin
au BufNewFile,BufRead *.ejs set filetype=html
au BufNewFile,BufRead *.cljs set filetype=clojure
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" first disable the s key because its better to use c for everything anyways
map s <Nop>
" Easy window navigation from keyboard too
map sh <C-w>h
map sj <C-w>j
map sk <C-w>k
map sl <C-w>l
"
" Easy window navigation from keyboard too
map sH <C-w>H
map sJ <C-w>J
map sK <C-w>K
map sL <C-w>L
"Easy tab navigation
map <d-Up> :tabr<cr>
map <d-Down> :tabl<cr>
map <d-Left> :tabp<cr>
map <d-Right> :tabn<cr>
"Easy tab navigation from keyboard too
map gh :tabp<cr>
map gl :tabn<cr>
map gH :tabr<cr>
map gL :tabl<cr>
"Better Searching
set hlsearch
noremap <silent> <leader><space> :noh<cr>:call clearmatches()<cr>
" Visual Mode selection (Press * while selecting something)
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
"Allow To hilight 5 words at a time
nnoremap <leader>hh :execute 'match InterestingWord1 /\<<c-r><c-w>\>/'<cr>
nnoremap <leader>h1 :execute 'match InterestingWord1 /\<<c-r><c-w>\>/'<cr>
nnoremap <leader>h2 :execute '2match InterestingWord2 /\<<c-r><c-w>\>/'<cr>
nnoremap <leader>h3 :execute '3match InterestingWord3 /\<<c-r><c-w>\>/'<cr>
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
" Buffer Window Resizing
nnoremap <c-l> 5<c-w>>
nnoremap <c-h> 5<c-w><
nnoremap <c-i> 5<c-w>+
nnoremap <c-j> 5<c-w>-
" Open a Quickfix window for the last search.
nnoremap <silent> <leader>? :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" Search in current buffer lines with fzf
nnoremap <leader>/ :BLines<CR>
"Keep hilight when indenting around
vnoremap > ><CR>gvi
vnoremap < <<CR>gv
noremap NN =ip
"Plugin Configurations
"CtrlP
noremap <space><space> <Esc>:CtrlP .<CR>
let g:ctrlp_working_path_mode = 'c' "index on CWD
let g:ctrlp_switch_buffer = 'e' " Dont jump to the other buffer if the file is already open
set wildignore+=*.pyc,
let g:ctrlp_custom_ignore = 'node_modules\|\.DS_Store\|\.git\|venv\|build\|builds'
"Conque
map <leader>c :ConqueTermSplit bash
map <leader>cv :ConqueTermVSplit bash
"NERDTRee
map <space> :NERDTreeToggle<CR>
let NERDTreeIgnore = ['\.pyc$']
"Tagbar
nmap <leader>t :TagbarToggle<CR>
" "YouCompleteMe
" nnoremap + :YcmCompleter GoTo<CR>
" nnoremap _ :YcmCompleter GoToReferences<CR>
" let g:ycm_autoclose_preview_window_after_completion=1
"
" let g:ycm_key_list_select_completion = ['<Enter>', '<C-j>', '<Down>']
" let g:ycm_key_list_previous_completion = ['<S-Enter>', '<C-k>', '<Up>']
"EasyMotion triggers:
map ,, <leader><leader>
"JSBeautify
"This plugin is mapped to ,ff to format the current javascript file
"Rename
":rename filename
"to rename the current file
"Ack: (replaced by fzf + ripgrep, use <leader>f and <leader>F)
" map :ack :Ack
" map <leader>a :Ack
" <leader>a<motion>, or
"vim-seek
let g:SeekKey = 's'
let g:SeekBackKey = 'S'
if has("gui_running")
set guioptions=egmrt
endif
" Turn off delimateMate for Clojure files (It's annoying with Clojure)
au! FileType clojure let b:loaded_delimitMate=1
"Vim-closedform by aaron
imap <M-;> <Esc>:AppendClosingFormSymbol<CR>a
nmap <M-;> <Esc>:AppendClosingFormSymbol<CR>
imap <M-:> <Esc>:AppendAllClosingFormSymbols<CR>a
nmap <M-:> <Esc>:AppendAllClosingFormSymbols<CR>
"Rainbow Parenthesis
" au VimEnter * RainbowParenthesesToggle
" au Syntax * RainbowParenthesesLoadRound
" au Syntax * RainbowParenthesesLoadSquare
" au Syntax * RainbowParenthesesLoadBraces
"gitgutter
highlight clear SignColumn
set tabstop=2
set shiftwidth=2
"Use this to convert snake case to camel case: %s#\%(\%(\k\+\)\)\@<=_\(\k\)#\u\1#g