-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.nhdaly
509 lines (413 loc) · 15.8 KB
/
vimrc.nhdaly
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
" Because who needs vi?
set nocompatible
let mapleader = ","
""=========== MY PLUGINS =========== {{{
"" --------- VUNDLE ---------------- {{{
" Vundle Setup {{{
" Vundle Plugins -- https://github.com/gmarik/Vundle.vim
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" }}}
" ------- Put Vundle Plugins Here --------------------
if exists("g:running_at_work")
" Skip these, because I already have them in my work vimrc.
else
" YouCompleteMe -- Auto Completions
"Plugin 'valloric/YouCompleteMe'
let g:ycm_extra_conf_globlist = ['~/.ycm_extra_conf.py']
" Set to default python so it still works inside conda.
let g:ycm_path_to_python_interpreter = '/usr/bin/python'
" For code formatting! TODO(nhdaly): Turn this on. Should be cool!
" Add maktaba and codefmt to the runtimepath.
" (The latter must be installed before it can be used.)
Plugin 'google/vim-maktaba'
Plugin 'google/vim-codefmt'
endif
" Settings for the above plugins, to be shared at home & at work.
let g:ycm_always_populate_location_list = 1
" For 'better c++ vim highlighting'
Plugin 'octol/vim-cpp-enhanced-highlight'
let g:cpp_class_scope_highlight = 1
let g:cpp_experimental_template_highlight = 1
hi cppSTLnamespace ctermfg=10
" Lets you swap windows with <leader>ww
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>
Plugin 'wesQ3/vim-windowswap'
" Switch between MRU buffers from the current session.
let g:bufmru_switchkey = "<c-t>" " Never use this.
command ReopenLastTab execute "vsplit " . bufname(g:bufmru_bnrs[1])
Plugin 'vim-scripts/bufmru.vim'
" Auto paste-mode when pasting. ... seems pretty obvious saying it out loud...
Plugin 'ConradIrwin/vim-bracketed-paste'
" Julia syntax highlighting, block-text, etc.
Plugin 'JuliaEditorSupport/julia-vim'
" haskell syntax highlighting
Plugin 'neovimhaskell/haskell-vim'
" Adds command operations that surround text objects.
Plugin 'tpope/vim-surround'
" Adds '.' repeat support to plugin mapped commands (like surround above).
Plugin 'tpope/vim-repeat'
" For vim + git!
Plugin 'tpope/vim-fugitive'
" Let you restore a vim session with ":Obsess"
Plugin 'tpope/vim-obsession'
" *Use same key commands to navigate vim as tmux!*
Plugin 'christoomey/vim-tmux-navigator'
let g:tmux_navigator_no_mappings = 1
" Normal Mode mappings
nnoremap <silent> <C-h>h :TmuxNavigateLeft<cr>
nnoremap <silent> <C-h>j :TmuxNavigateDown<cr>
nnoremap <silent> <C-h>k :TmuxNavigateUp<cr>
nnoremap <silent> <C-h>l :TmuxNavigateRight<cr>
nnoremap <silent> <C-h>; :TmuxNavigatePrevious<cr>
" Insert Mode mappings (note that the 'C-o' re-enters insert-mode after the
" following command.)
inoremap <silent> <C-h>h <C-o>:TmuxNavigateLeft<cr>
inoremap <silent> <C-h>j <C-o>:TmuxNavigateDown<cr>
inoremap <silent> <C-h>k <C-o>:TmuxNavigateUp<cr>
inoremap <silent> <C-h>l <C-o>:TmuxNavigateRight<cr>
inoremap <silent> <C-h>; <C-o>:TmuxNavigatePrevious<cr>
" Visual Mode mappings (note that the 'gv' re-enters visual-mode.
vnoremap <silent> <C-h>h <Esc>:TmuxNavigateLeft<cr>gv
vnoremap <silent> <C-h>j <Esc>:TmuxNavigateDown<cr>gv
vnoremap <silent> <C-h>k <Esc>:TmuxNavigateUp<cr>gv
vnoremap <silent> <C-h>l <Esc>:TmuxNavigateRight<cr>gv
vnoremap <silent> <C-h>; <Esc>:TmuxNavigatePrevious<cr>gv
" Command Mode mappings. Oh boy. To execute the command and not modify the
" current cmdline, you need this function and <C-R>= mappings, which insert the
" value returned from the function (in this case "") at that place in the
" command line.
function! CmdModeTmuxNavigate(cmd)
if a:cmd ==? "h"
silent! execute "TmuxNavigateLeft"
elseif a:cmd ==? "j"
silent! execute "TmuxNavigateDown"
elseif a:cmd ==? "k"
silent! execute "TmuxNavigateUp"
elseif a:cmd ==? "l"
silent! execute "TmuxNavigateRight"
elseif a:cmd ==? ";"
silent! execute "TmuxNavigatePrevious"
endif
return ""
endfunction
cnoremap <silent> <C-h>h <C-R>=CmdModeTmuxNavigate("h")<CR>
cnoremap <silent> <C-h>j <C-R>=CmdModeTmuxNavigate("j")<CR>
cnoremap <silent> <C-h>k <C-R>=CmdModeTmuxNavigate("k")<CR>
cnoremap <silent> <C-h>l <C-R>=CmdModeTmuxNavigate("l")<CR>
cnoremap <silent> <C-h>; <C-R>=CmdModeTmuxNavigate(";")<CR>
" NeoVim Terminal Mode mappings
if has('nvim')
tnoremap <silent> <C-h>h <C-\><C-N>:TmuxNavigateLeft<cr>a
tnoremap <silent> <C-h>j <C-\><C-N>:TmuxNavigateDown<cr>a
tnoremap <silent> <C-h>k <C-\><C-N>:TmuxNavigateUp<cr>a
tnoremap <silent> <C-h>l <C-\><C-N>:TmuxNavigateRight<cr>a
tnoremap <silent> <C-h>; <C-\><C-N>:TmuxNavigatePrevious<cr>a
endif
"" -- Productivity Plugins! ---------
"" Org-Mode: A ToDo list for the rest of us!?
"Plugin 'jceb/vim-orgmode'
"
"" Lets you increase/decrease dates w/ ctrl-a and ctrl-x (like numbers).
"Plugin 'vim-scripts/speeddating.vim'
"
"" -- End Productivity Plugins ------
" ------- End Vundle Plugins -------------------------
" Vundle Setup {{{
" 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
"" --------- END VUNDLE ---------------- }}}
"" --------- VimBall --------------- {{{
" CamelCaseMotion: http://www.vim.org/scripts/script.php?script_id=1905
runtime plugin/camelcasemotion.vim
"" ----- End VimBall --------------- }}}
" ---- Manual Plugins ---- {{{
source ~/.vim/plugin/bclose.vim
" Let bclose close a buffer even if it's in multiple windows
let bclose_multiple = 1
" }}}
""======= END MY PLUGINS =========== }}}
""======== MY ADDITIONS ================= {{{
"Set options for formatting text (with autoformat command [=])
set formatoptions=tcqn "autowrap, maintain comments, format comments, lists
"if version >= 703
" set undofile "Create undo file to store undos even after close/reopen
"endif
" F4 will switch between .cc file and .h
" TODO(nhdaly): Add .cpp file support
map <F4> :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR>
" Makes %%/ expand to file's parent directory.
cabbr <expr> %% expand("%:p:h")
" Don't use Modelines unless you really need them, and then turn it on
" manually per session. See google search for 'vim modeline vulnerability' or
" http://www.techrepublic.com/blog/it-security/turn-off-modeline-support-in-vim/
set modelines=0
" Remove trailing whitespace from a line
"command RemoveSpace s/\s\+$//
" Allow you to save a file that you accidentally opened
" without sudo privelage
cmap w!! %!sudo tee > /dev/null %
" Set (weird) hotkeys for horizontal scrolling.
" map <A-V> <ScrollWheelLeft>
" Show the status line even with only one file open.
set laststatus=2
" set tab stuff
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
set smartindent
set copyindent
set smarttab
set shiftround
" set linebreak "Break lines at word boundaries instead of mid-word
"set nolinebreak "Break lines at word boundaries instead of mid-word
set backspace=indent,eol,start "Allow you to backspace over them
set showmatch "Highlight matching parens
" Hides the current buffer when switching rather than closing.
" Note -- this seems to be enabled even without this line...
set hidden "Allow leaving unsaved buffers to switch windows.
" Allow editing compiled java files, by treating them as .zip files.
au BufRead *.srcjar set filetype=zip
"---- Search settings ------ {{{
"Set vim to use Perl-like regexes instead of Vim-style
"nnoremap / /\v
"vnoremap / /\v
" Don't ignore case for caps
set smartcase "unused unless set ignorecase
set ignorecase
set incsearch "jump to match while typing search
set hlsearch
"shortcut to clear search highlighting
nnoremap <leader><space> :noh<cr>
"Tab to match parentheses
nnoremap <S-tab> %
vnoremap <S-tab> %
" }}}
nnoremap <F10> :set invpaste paste?<CR>
set pastetoggle=<F10>
set showmode
set number "show line numbers. ... duh?
set relativenumber "Set the relative-number in both directions from current line
set splitright "VSplit windows to the right of the current window.
"nnoremap ; : "use ; to mean : so no shift is required
" Set a manual backup directory
"set backup
"set backupdir=~/.vim/backup
"set directory=~/.vim/tmp
set tags=./tags "Where to look for the tags
"set to use search for tags instead of default
"noremap <c-]> g<c-]>
"noremap <c-LeftMouse> <LeftMouse>g<c-]>
" Set emacs-style cmdline editing keys.
" start of line
cnoremap <C-A> <Home>
" delete character under cursor
"cnoremap <C-D> <Del>
" end of line
cnoremap <C-E> <End>
" back/forward one character
"cnoremap <C-B> <Left>
"cnoremap <C-F> <Right>
" recall newer command-line
cnoremap <C-N> <Down>
" recall previous (older) command-line
cnoremap <C-P> <Up>
" back one word
"cnoremap <Esc><C-B> <S-Left>
" forward one word
"cnoremap <Esc><C-F> <S-Right>
" <C-k>: delete to end. From http://stackoverflow.com/a/26310522/751061
cnoremap <C-k> <C-\>e getcmdpos() == 1 ?
\ '' : getcmdline()[:getcmdpos()-2]<CR>
"Fix j and k for wrapped lines:
noremap j gj
noremap k gk
"Fix up/down for wrapped lines:
" 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>
" Makes K split lines (the opposite of J).
nmap K i<cr><Esc>k$
" (And leave cursor on start of the new line)
"nmap K i<cr><C-o>:stopinsert<CR>
" Makes s save
" nmap s :w <enter>
" Unmapping s to save because I press it way too often now -- habitually -- and
" I get screwed up on vim-like programs. (Maps to a Beep instead.)
nmap s \<Esc>
"" Powerline
"python from powerline.vim import setup as powerline_setup
"python powerline_setup()
"python del powerline_setup
"
"let g:powerline_config_overrides
" Turn on folding for vim files with the three-bracket marker.
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" <leader>g does a grep search for the word under the cursor in this dir.
:nnoremap <leader>g :execute "grep! -R " . shellescape(expand("<cWORD>")) . " ."<cr>:copen<cr>
""========= END MY ADDITIONS ============ }}}
""=========== NEOVIM =========== {{{
if has('nvim')
set scrollback=100000
endif
" VISUAL STUDIO
"if exists('g:vscode')
" workaround for calling command picker in visual mode
function! s:runVSCodeCommandWithSelection(cmd)
normal! gv
let visualmode = visualmode()
if visualmode == "V"
let startLine = line("v")
let endLine = line(".")
call VSCodeNotifyRange(a:cmd, startLine, endLine, 1)
else
let startPos = getpos("v")
let endPos = getpos(".")
call VSCodeNotifyRangePos(a:cmd, startPos[1], endPos[1], startPos[2], endPos[2]+1, 1)
endif
endfunction
xnoremap <silent> <C-P> :<C-u>call <SID>runVSCodeCommandWithSelection("workbench.action.showCommands")<CR>
xnoremap <silent> <leader>J :<C-u>call <SID>runVSCodeCommandWithSelection("language-julia.executeJuliaCodeInREPL")<CR>
"function! s:showCommands()
" normal! gv
" let startPos = getpos("v")
" let endPos = getpos(".")
" call VSCodeNotifyRangePos("workbench.action.showCommands", startPos[1], endPos[1], startPos[2], endPos[2], 1)
"endfunction
"xnoremap <silent> <C-P> :<C-u>call <SID>showCommands()<CR>
"endif
""=========== End NEOVIM =========== }}}
""========= Starter Vimrc ============ {{{
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <[email protected]>
" Last change: 2008 Jul 02
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=10000 " keep 100,000 lines of command line history
set ruler " show the cursor position in bottom right all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
" fix mouse-drag to work in tmux/screen
if &term =~ '^screen' || &term =~ 'xterm'
" tmux knows the extended mouse mode
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
endif
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" 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
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" TODO THIS SHOULDN'T NEED TO BE TURNED OFF. I MESSED SOMETHING UP
" For all text files set 'textwidth' to 78 characters.
"autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
""========= End Starter Vimrc ========= }}}
" -------- iTerm Colors -------------- {{{
set t_Co=256
hi Statement ctermfg=3
hi cCustomClass ctermfg=7
hi Function ctermfg=7
hi LineNr ctermfg=3
" Cursor Line number
hi CursorLineNr ctermfg=1
set cursorline
highlight CursorLine ctermfg=none gui=none term=none cterm=none
" Selection
hi Visual term=reverse ctermfg=0
" -------- End iTerm Colors ---------- }}}