-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvimrc
379 lines (310 loc) · 10.1 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
"-----------------------------------------------------------------------------
" Vim Configuration (Dotfiles)
"
" Brian Cain
"-----------------------------------------------------------------------------
set nocompatible
let &t_Co=256
"-----------------------------------------------------------------------------
"
" Syntax Highlighting
"
"-----------------------------------------------------------------------------
" Markdown Syntax
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.mdx set filetype=markdown
" Powershell files
autocmd BufNewFile,BufReadPost *.ps1 set filetype=ps1
"-----------------------------------------------------------------------------
" ColorColumn for overflow
"-----------------------------------------------------------------------------
set colorcolumn=80
highlight ColorColumn ctermbg=0 guibg=lightgrey
"-----------------------------------------------------------------------------
" Vundle Config
"-----------------------------------------------------------------------------
" Setting up Vundle
" Found here: http://www.erikzaadi.com/2012/03/19/auto-installing-vundle-from-your-vimrc/
let has_vundle=1
let vundle_readme=expand('~/.dotfiles/vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle..."
echo ""
silent !mkdir -p ~/.dotfiles/vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.dotfiles/vim/bundle/vundle
let has_vundle=0
endif
" Vundle setup config
set rtp+=~/.dotfiles/vim/bundle/vundle/
call vundle#rc()
" Required Bundle
Bundle 'gmarik/vundle'
" Syntax Highlighters
Plugin 'jvirtanen/vim-hcl'
Plugin 'joukevandermaas/vim-ember-hbs'
" Copilot
Plugin 'github/copilot.vim'
" Additional Bundles go here"
Bundle 'L9'
Bundle 'Gundo'
Bundle 'kien/ctrlp.vim'
Bundle 'flazz/vim-colorschemes'
Bundle 'scrooloose/nerdtree'
Bundle 'godlygeek/tabular'
" Bundle 'PProvost/vim-ps1'
Bundle 'fatih/vim-go'
Bundle 'morhetz/gruvbox'
" Four needed for snipmate
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
" Bundle "garbas/vim-snipmate"
" Bundle "honza/vim-snippets"
" Airline
Bundle 'bling/vim-airline'
Bundle 'tpope/vim-fugitive'
" Installing plugins the first time
" If exists, skip
if has_vundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
"-----------------------------------------------------------------------------
"
" Plugin Configuration
"
"-----------------------------------------------------------------------------
" Shortcuts for CtrlP
let g:ctrlp_map = '<c-p>'
" The Silver Searcher
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
syntax enable
filetype plugin indent on
" Gundo mapping
nnoremap <silent> <C-U> :GundoToggle<CR>
let g:snipMate = { 'snippet_version': 1 }
"-----------------------------------------------------------------------------
"
" Color
"
"-----------------------------------------------------------------------------
colorscheme gruvbox
set bg=dark
"-----------------------------------------------------------------------------
"
" Airline configuration
"
"-----------------------------------------------------------------------------
let g:airline#extensions#tabline#enabled = 1
"-----------------------------------------------------------------------------
" Encoding and general usability
"-----------------------------------------------------------------------------
nnoremap <Space> :
set splitbelow
set splitright
set modeline
set ls=2
set cursorline
set showmatch
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/#important-vimrc-lines
set encoding=utf-8
set scrolloff=3
set showmode
set showcmd
set wildmenu
set wildmode=list:longest
set visualbell
set ttyfast
set ruler
set backspace=indent,eol,start
" Line numbering
set number
" Vim window stuff
set linebreak
set guifont=Inconsolata:h15
" Show tabs and trailing whitespace visually
if (&termencoding == "utf-8") || has("gui_running")
if v:version >= 700
set list listchars=tab:»·,trail:·,extends:…,nbsp:‗
else
set list listchars=tab:»·,trail:·,extends:…
endif
else
if v:version >= 700
set list listchars=tab:>-,trail:.,extends:>,nbsp:_
else
set list listchars=tab:>-,trail:.,extends:>
endif
endif
"-----------------------------------------------------------------------------
" Macros
"-----------------------------------------------------------------------------
"
" DEBUGGING RUBY
"
" Inserts a `pry` break on a newline
map ,p orequire 'pry'<ENTER>binding.pry<ESC>
map ,b obyebug<ESC>
"
" Waypoint Changelog
"
map ,w o```release-note:FIXME<ENTER>type:TODO WRITE ME<ENTER>```<ESC>
"-----------------------------------------------------------------------------
" Search, highlight, spelling, etc.
"-----------------------------------------------------------------------------
" Improved searching
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
" Enable syntax highlighting, if one exists
if has("syntax")
syntax on
endif
" Paragraph formatting stuff:
set formatprg=par
" Store temporary files in a central location
set backupdir=~/.vim/vim-tmp,~/.tmp,~/tmp,~/var/tmp,/tmp
set directory=~/.vim/vim-tmp,~/.tmp,~/tmp,~/var/tmp,/tmp
" Omnifunction
set omnifunc=syntaxcomplete#Complete
" If a file has been changed outside of Vim, reload it inside of Vim
set autoread
"-----------------------------------------------------------------------------
" Spacing
"-----------------------------------------------------------------------------
set autoindent
set smartindent
set tabstop=2 shiftwidth=2 expandtab
"-----------------------------------------------------------------------------
" Buffers
"-----------------------------------------------------------------------------
" Delete all buffers with \da
nmap <silent> <leader>da :exec "1," . bufnr('$') . "bd"<cr>
" Let me switch buffers with unsaved changes
set hidden
"-----------------------------------------------------------------------------
" Folds and folding
"-----------------------------------------------------------------------------
set foldcolumn=0
set foldmethod=marker "alternatives: indent, syntax, marker
" Change what folded lines show (currently disabled)
function! MyFoldText()
let nl = v:foldend - v:foldstart + 1
let comment = substitute(getline(v:foldstart),"^ *","",1)
let linetext = substitute(getline(v:foldstart+1),"^ *","",1)
let txt = '+ ' . linetext . ' : "' . comment . '" : length ' . nl
return txt
endfunction
" set foldtext=MyFoldText()
" map <leader>mv :mkview<CR>
" map <leader>lv :loadview<CR>
"-----------------------------------------------------------------------------
" Keymap stuff
"-----------------------------------------------------------------------------
" noremap <Up> gk
" noremap <Down> gj
" Toggle text wrapping with \w {{{
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
if &wrap
echo "Wrap OFF"
setlocal nowrap
set virtualedit=all
silent! nunmap <buffer> <Up>
silent! nunmap <buffer> <Down>
silent! nunmap <buffer> <Home>
silent! nunmap <buffer> <End>
silent! iunmap <buffer> <Up>
silent! iunmap <buffer> <Down>
silent! iunmap <buffer> <Home>
silent! iunmap <buffer> <End>
else
echo "Wrap ON"
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj
noremap <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End>
inoremap <buffer> <silent> <Up> <C-o>gk
inoremap <buffer> <silent> <Down> <C-o>gj
inoremap <buffer> <silent> <Home> <C-o>g<Home>
inoremap <buffer> <silent> <End> <C-o>g<End>
endif
endfunction
" }}}
noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
noremap <buffer> <silent> 0 g0
noremap <buffer> <silent> $ g$
set mouse=a
" Keymappings for :e
map <leader>ew :e <C-R>=expand("%:p:h")."/"<CR>
map <leader>es :sp <C-R>=expand("%:p:h")."/"<CR>
map <leader>ev :vsp <C-R>=expand("%:p:h")."/"<CR>
map <leader>et :tabe <C-R>=expand("%:p:h")."/"<CR>
" Map for omnicomplete
inoremap <F8> <C-X><C-O>
" Access .vimrc with \vi
nmap <silent> <leader>vi :e $MYVIMRC<CR>
nmap <silent> <leader>vh :e ~/Documents/References/vim.txt<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Relative Number toggle (\rn) {{{
nmap <silent> <leader>rn :call RelativeNumberToggle()<CR>
function! RelativeNumberToggle()
if &number
echo "relativenumber ON"
setlocal relativenumber
else
if &relativenumber
echo "relativenumber OFF"
setlocal norelativenumber
setlocal number
endif
endif
endfunction
" }}}
"-----------------------------------------------------------------------------
" NERD Tree
"-----------------------------------------------------------------------------
" Invoke NERD Tree with \nt
nmap <leader>nt :NERDTree<CR>
" Toggle the NERD Tree on an off with F7
nmap <F7> :NERDTreeToggle<CR>
" Close the NERD Tree with Shift-F7
nmap <S-F7> :NERDTreeClose<CR>
let NERDTreeShowHidden=1
"-----------------------------------------------------------------------------
" Latex-Suite
"-----------------------------------------------------------------------------
"let g:Tex_ViewRule_pdf = '/Applications/Skim.app'
" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on
"
" " IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" " can be called correctly.
set shellslash
"
" " IMPORTANT: grep will sometimes skip displaying the file name if you
" " search in a singe file. This will confuse Latex-Suite. Set your grep
" " program to always generate a file-name.
set grepprg=grep\ -nH\ $*
"
" " OPTIONAL: This enables automatic indentation as you type.
filetype indent on
"
" " OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults
" to
" " 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" " The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'