forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
550 lines (428 loc) · 15 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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" Other vundle plugins
" Keep Plugin commands between vundle#begin/end.
Plugin 'mileszs/ack.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-vividchalk'
"Plugin 'altercation/vim-colors-solarized'
Plugin 'ervandew/supertab'
Plugin 'msanders/snipmate.vim'
Plugin 'tpope/vim-unimpaired'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
Plugin 'sjl/tslime.vim'
Plugin 'davidhalter/jedi-vim'
Plugin 'wgibbs/vim-irblack'
Plugin 'tpope/vim-endwise'
Plugin 'vim-scripts/taglist.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'garbas/vim-snipmate'
Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-markdown'
Plugin 'jtratner/vim-flavored-markdown'
Plugin 'scrooloose/syntastic'
Plugin 'Rip-Rip/clang_complete'
Plugin 'scrooloose/nerdcommenter'
"Plugin 'floobits/floobits-neovim'
"Plugin 'Floobits/floobits-vim' "problems?
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'sophacles/vim-processing'
Plugin 'jceb/vim-orgmode'
"Plugin 'sunset'
Plugin 'kburdett/vim-nuuid'
Plugin 'chrisbra/Recover.vim'
"Plugin 'bnf.vim'
Plugin 'vim-scripts/bnf.vim'
Plugin 'tpope/vim-obsession'
Plugin 'dhruvasagar/vim-prosession'
Plugin 'stephpy/vim-yaml'
Plugin 'jparise/vim-graphql'
Plugin 'pangloss/vim-javascript'
Plugin 'chrisbra/matchit'
"" Clojure things
"Plugin 'vimclojure'
Plugin 'tpope/vim-fireplace'
"Plugin 'guns/vim-clojure-static'
Plugin 'guns/vim-clojure-highlight'
Plugin 'typedclojure/vim-typedclojure'
Plugin 'tpope/vim-leiningen'
"Plugin 'dgrnbrg/vim-redl'
Plugin 'bhurlow/vim-parinfer'
Plugin 'dense-analysis/ale'
""Plugin 'pandysong/ghost-text.vim'
" This seems to be having some crazy fucking issues on stoat... oy vey
"Plugin 'SirVer/ultisnips' " Engine
"Plugin 'honza/vim-snippets' " Snippets
" Plugin 'vim-pandoc/vim-pandoc'
" Examples / reference
" ====================
" plugin on GitHub repo
"Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" All the custom things
" =====================
" Replaced by Vundle
" call pathogen#infect()
let mapleader = ","
let maplocalleader = "\\"
"set backupdir=~/.vim.bkp
" Awesome rad maps...
map <leader>P :Plain<enter>
map <leader>p "+p
map <leader>Y "+yy
map <leader>m :Mail<enter>
map <leader>M :Mail<enter>
map <leader>r :res
map <leader>/ /asdf<enter>
" A couple new suggestions from Erick that made his life better
map <C-\> :w<enter>
imap <C-\> <Esc>:w<enter>
map <C-s> :w<enter>
" Shouldn't need this one, but just in case I haven't yet
map <C-S> :w<enter>
" yank to X clipboard
vmap <leader>y "+y
" Remove tailing white spaces
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" don't stage - git helper for removing things from staging on add -e
"vmap <leader>ds <line1>,<line2>call DontStage()<enter>
function! DontStage() range
execute a:firstline . "," . a:lastline . 's/^-/ /'
execute a:firstline . "," . a:lastline . 'g/^+/d'
endfunction
vmap <leader>ds :call DontStage()<enter>
"" Clojure things!
"" ===============
" Clojure fireplace etc goodies
vmap e :Eval<enter>
vmap E :Eval!<enter>
map E Ve
map <leader>e :%Eval<enter>
map <leader>R :Eval (do (try (require 'mount.core) (mount.core/stop) (catch Throwable t)) (require 'clojure.tools.namespace.repl) (clojure.tools.namespace.repl/refresh) (try (require 'mount.core) (mount.core/start) (catch Throwable t)))<enter>
map <C-t> :Eval (do (require 'clojure.test) (clojure.test/run-tests))<enter>
map <C-A-t> :Eval (do (require 'clojure.test) (clojure.test/run-all-tests))<enter>
" kondo linter
let g:ale_linters = {'clojure': ['clj-kondo']}
" don't want clj fmt running automatically
"let g:clj_fmt_autosave = 0
" Other formats that should compile like as clojure code:
au BufNewFile,BufRead *.edn set filetype=clojure
au BufNewFile,BufRead *.bb set filetype=clojure
autocmd BufEnter *.bb :setlocal filetype=clojure
" Other highlighting things
let g:clojure_align_subforms = 0
let g:clojure_fuzzy_indent_patterns = ['^with', '^def', '^let']
let g:clojure_special_indent_words = 'deftype,defrecord,reify,proxy,extend-type,extend-protocol,letfn,go-loop,go'
" parinfer
" TODO Figure out comments!
augroup parinfer
"autocmd!
"autocmd BufNewFile,BufReadPost *.clj,*.cljs,*.cljc,*.edn call parinfer#start_server()
"autocmd InsertLeave *.clj,*.cljs,*.cljc,*.edn call parinfer#send_buffer()
"autocmd VimLeavePre *.clj,*cljs,*.cljc,*.edn call <sid> stop_server()
" this is why * wasn't working...
autocmd FileType clojure vnoremap <buffer> <Tab> :call parinfer#do_indent()<cr>
autocmd FileType clojure vnoremap <buffer> <S-Tab> :call parinfer#do_undent()<cr>
autocmd FileType clojure vnoremap <buffer> <Tab> :call parinfer#do_indent()<cr>
autocmd FileType clojure vnoremap <buffer> <S-Tab> :call parinfer#do_undent()<cr>
"" stil considering these mappings
"au TextChanged *.clj,*.cljc,*.cljs call parinfer#send_buffer()
""au FileType clojure nnoremap <M-Tab> :call <sid>do_undent()<cr>
""autocmd FileType clojure nnoremap <buffer> ]] /^(<CR>
""autocmd FileType clojure nnoremap <buffer> [[ ?^(<CR>
augroup END
" General editing stuff
"
"
" Vim snippets via ultisnips
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" Some goodies Andrew shared for cursorlines
map <leader>h :set cursorline! cursorcolumn!<CR>
" By default on...
:set nocursorline
" I'm going to use these Alt-binding now for moving through text more easily
" when I'm wrapping, but these (for now, unless I figure something clever out)
" are only going to work in Gvim.
vmap <A-j> gj
vmap <A-k> gk
vmap <A-4> g$
vmap <A-6> g^
vmap <A-0> g^
nmap <A-j> gj
nmap <A-k> gk
nmap <A-4> g$
nmap <A-6> g^
nmap <A-0> g^
" Set sconsstruct files to python filetype, and set up a few special functions for syntax highlighting
au BufNewFile,BufRead SCons* set filetype=python
syn keyword sconsEnv Command, Alias, Variables, SlurmEnvironment, PathVariable
hi link sconsEnv Function
au BufNewFile,BufRead less set filetype=css
" for gvim only I think
set guioptions-=m "Remove menu bar
set guioptions-=T "Remove tool bar
set guifont=Monospace\ 8
syntax on
set t_Co=16
"call togglebg#map("<F4>")
"colorscheme ir_black "last actually...
colorscheme elflord
"colorscheme koehler
"colorscheme delek
"colorscheme desert
"colorscheme solarized
" Trying out auto reloading
set autoread
au CursorHold * checktime
let vimrplugin_screenplugin = 0
let vimrplugin_underscore = 0
" Make supertab ignore usage on fresh lines
"function! CleverTab()
"if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
"return "\<Tab>"
"else
"return "\<C-N>"
"endif
"endfunction
"inoremap <Tab> <C-R>=CleverTab()<CR>
" Attempting to get omni complete to run through super tab contextually
let g:SuperTabDefaultCompletionType = "context"
"let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
" Because it's annoying when shifting for ':' lingers for w or q and you think
" you've saved but haven't....
command! W w
command! Q q
command! Wq wq
command! WQ wq
command! Mail set ft=mail
" Should really set this up as a separate ft
command! Plain set spell linebreak wrap tw=1111111
command! Reload source ~/.vimrc
command! Erc split ~/.vimrc
set noea
" Spell check settings
hi SpellBad cterm=bold ctermbg=black
set textwidth=110
" NERDTree setup
map <leader>T :NERDTreeToggle <CR>
map <leader>t :NERDTreeTabsToggle <CR>
" Was liking having drawer open up automatically, bit it's actually kind of annoying... Might modify later
"autocmd vimenter * if !argc() | NERDTree | endif
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
let NERDTreeIgnore = ['\.pyc$', '\.RData$']
" Stuff for working with tabs + windows
function! MoveToPrevTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() != 1
close!
if l:tab_nr == tabpagenr('$')
tabprev
endif
sp
else
close!
exe "0tabnew"
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
function! MoveToNextTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() < tab_nr
close!
if l:tab_nr == tabpagenr('$')
tabnext
endif
sp
else
close!
tabnew
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
map <C-n> :call MoveToPrevTab()<CR>
"map <C-m> :call MoveToNextTab()<CR>
map <C-B> :call MoveToPrevTab()<CR>
map <C-M> :call MoveToNextTab()<CR>
" Don't know why I have to call this...
unmap <enter>
" 1 Disables pandoc folding - kinda neet though. Might be cool to activate this later
let g:pandoc_no_folding = 1
if has("gui_running")
set lines=70 columns=118
endif
" Sunset settings - for automatically changing background based on sunlight
let g:sunset_latitude = 47.6097
let g:sunset_longitude = -122.3331
let g:sunset_utc_offset = -8
"" to avoid annoying end of line edits to files when saving without changes
:set nofixendofline
"" Generate and insert uuids
"fu! GenerateUUID()
"python << EOF
"import uuid
"import vim
"# output a uuid to the vim variable for insertion below
"vim.command("let generatedUUID = \"%s\"" % str(uuid.uuid4()))
"EOF
"" insert the python generated uuid into the current cursor's position
":execute "normal i" . generatedUUID . ""
"endfunction
""initialize the generateUUID function here and map it to a local command
"map <Leader>U :call GenerateUUID()<CR>
let g:nuuid_no_mappings = 1
map <Leader>U <Plug>Nuuid
"" The below was all snagged from janus. Moving away..
"" ===================================================
""
filetype plugin indent on
set number " Show line numbers
set ruler " Show line and column number
"set encoding=utf-8 " Set default encoding to UTF-8
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
set backspace=indent,eol,start " backspace through everything in insert mode
" Consider doing
" :set list
" :set listchars=""
" :set listchars=tab:\ \
" :set listchars=trail:.
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase "searches are case insensitive
set smartcase " ... unless they contain at least one capital letter
" Disable output and VCS files
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
" Disable archive files
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Ignore 'compiled' python files
set wildignore+=*.pyc
" Ignore bundler and sass cache
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Disable temp and backup files
set wildignore+=*.swp,*~,._*
""
"" File types
" Some file types should wrap their text
function! s:setupWrapping()
set wrap
set linebreak
set textwidth=72
set nolist
endfunction
filetype plugin indent on " Turn on filetype plugins (:help filetype-plugin)
let g:markdown_fenced_languages = ["python", "py=python", "clojure", "clj=clojure", "cljs=clojure", "edn=clojure", "javascript", "js=javascript", "json=javascript", "ruby", "rb=ruby", "sh", "edn-vega-lite=clojure", "edn-vega=clojure", "edn-oz=clojure", "json-vega-lite=javascript", "json-vega=javascript", "json-oz=javascript", "yaml", "yml=yaml"]
if has("autocmd")
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType make setlocal noexpandtab
" Make sure all mardown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt,mds} setf markdown
" Make handlebars look ok
au BufRead,BufNewFile *.{handlebars,hbs} setf html
" Treat JSON files like JavaScript
au BufNewFile,BufRead *.json set ft=javascript
" Treat todo files like markdown
au BufNewFile,BufRead *.todo set ft=markdown
" make Python follow PEP8 for whitespace ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python setlocal softtabstop=4 tabstop=4 shiftwidth=4
" and for js
au FileType javascript setlocal softtabstop=2 tabstop=2 shiftwidth=2
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
" XXX - Custom...
au FileType mail setlocal wrap softtabstop=4 tabstop=4 shiftwidth=4 tw=999999 linebreak spell
endif
if has("statusline") && !&cp
set laststatus=2 " always show the status bar
" Start the status line
set statusline=%f\ %m\ %r
set statusline+=Line:%l/%L[%p%%]
set statusline+=Col:%v
set statusline+=Buf:#%n
set statusline+=[%b][0x%B]
endif
" use :w!! to write to a file using sudo if you forgot to 'sudo vim file'
" (it will prompt for sudo password when writing)
cmap w!! %!sudo tee > /dev/null %
" upper/lower word
nmap <leader>u mQviwU`Q
nmap <leader>l mQviwu`Q
" upper/lower first char of word
nmap <leader>U mQgewvU`Q
nmap <leader>L mQgewvu`Q
" Insert uuids :-)
command! UUID exe 'norm i' . system('uuidgen | tr -d \\n')
nmap <leader>i :UUID<CR>
command! Nowrap set textwidth=0 wrapmargin=0
" Map the arrow keys to be based on display lines, not physical lines
map <Down> gj
map <Up> gk
" Insert the current directory into a command-line path
cmap <C-P> <C-R>=expand("%:p:h") . "/"<CR>
" Bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
nmap <C-k> [e
nmap <C-j> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
vmap <C-k> [egv
vmap <C-j> ]egv
" format the entire file - XXX Not sure what this does
nmap <leader>fef ggVG=
" blah