2015-03-09 10:02:16 -07:00
|
|
|
" make vim unusable for anyone else
|
2015-03-10 14:42:26 -07:00
|
|
|
" from the get-go, we assume version >= 703
|
2015-03-09 10:02:16 -07:00
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
set nocompatible " screw vi
|
2013-07-03 15:03:54 -07:00
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
" hacks {{{1
|
2013-07-04 01:39:44 -07:00
|
|
|
if has('multi_byte')
|
|
|
|
scriptencoding utf-8 " allow it in this script
|
|
|
|
set termencoding=utf-8 " and this terminal supports it
|
|
|
|
set encoding=utf-8 " and the default file is in it
|
2013-07-03 15:03:54 -07:00
|
|
|
endif
|
|
|
|
|
2015-03-08 15:59:44 -07:00
|
|
|
if has("win32")
|
|
|
|
" assume directory structure:
|
|
|
|
" something/anything/.vimrc " this was passed to vim by the -u switch
|
|
|
|
" something/vim/
|
|
|
|
" something/vim/after
|
|
|
|
let $MYVIMRC=expand('<sfile>')
|
2015-03-10 15:21:29 -07:00
|
|
|
let g:rcvim=expand('<sfile>:p:h:h').'/vim'
|
2015-03-08 15:59:44 -07:00
|
|
|
else
|
2015-03-13 12:31:16 -07:00
|
|
|
let g:rcvim=$HOME.'/.vim'
|
2015-03-08 15:59:44 -07:00
|
|
|
endif
|
|
|
|
|
2015-03-10 15:21:29 -07:00
|
|
|
let &backupdir=g:rcvim.'/backup' " stash tilde files elsewhere
|
2015-03-09 10:02:16 -07:00
|
|
|
" the double slash at the end dumps the path of the file for uniqueness
|
2015-03-10 15:21:29 -07:00
|
|
|
let &directory=g:rcvim.'/swp//' " stash swap files too
|
|
|
|
let &undodir=g:rcvim.'/undo/' " undo files are cool
|
2015-03-09 10:02:16 -07:00
|
|
|
try | call mkdir(&backupdir, "p") | catch /E739/ | endtry
|
|
|
|
try | call mkdir(&directory, "p") | catch /E739/ | endtry
|
2015-03-10 15:21:29 -07:00
|
|
|
try | call mkdir(&undodir, "p") | catch /E739/ | endtry
|
2015-03-08 15:59:44 -07:00
|
|
|
|
2019-06-05 16:08:55 -07:00
|
|
|
" force colors on anything that looks reasonable
|
|
|
|
if (&term =~ "^xterm") || (&term == "screen")
|
2013-07-04 01:39:44 -07:00
|
|
|
let &t_Co=256
|
2019-06-05 13:07:43 -07:00
|
|
|
"let &t_AF="\e[38;5;%dm"
|
|
|
|
"let &t_AB="\e[48;5;%dm"
|
2013-07-04 01:39:44 -07:00
|
|
|
endif
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
" main config {{{1
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
if has('syntax')
|
|
|
|
syntax enable " required for folding as well
|
|
|
|
set hlsearch " highlight search results
|
|
|
|
endif
|
2015-03-24 19:54:57 -07:00
|
|
|
let g:python_highlight_builtin_funcs=1
|
2013-07-03 15:03:54 -07:00
|
|
|
|
|
|
|
if has('gui_running')
|
2015-03-08 15:59:44 -07:00
|
|
|
set guioptions-=M " skip loading $VIMRUNTIME/menu.vim
|
|
|
|
set guioptions-=m " hide menu which isn't loaded anyway
|
2013-07-04 01:39:44 -07:00
|
|
|
set guioptions-=T " hide toolbar
|
2015-03-08 15:59:44 -07:00
|
|
|
set guioptions-=r " hide scrollbar
|
2015-11-24 19:01:34 -08:00
|
|
|
if has("gui_gtk2")
|
|
|
|
set guifont=Consolas\ 11
|
|
|
|
else
|
|
|
|
set guifont=Consolas:h9
|
|
|
|
end
|
2013-07-04 01:39:44 -07:00
|
|
|
set columns=84
|
|
|
|
set lines=36
|
|
|
|
cd $HOME " might not be ideal...
|
2015-03-08 15:59:44 -07:00
|
|
|
endif
|
2013-07-04 01:39:44 -07:00
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
if has('title') | set title | endif " terminal title
|
2017-08-04 20:42:31 -07:00
|
|
|
set history=8192 " command lines to remember
|
2015-03-09 12:27:15 -07:00
|
|
|
set number " lines
|
2013-07-04 01:39:44 -07:00
|
|
|
set ruler " write out the cursor position
|
2016-01-17 16:04:18 -08:00
|
|
|
set showcmd " show number of lines/etc. selected
|
2013-07-04 01:39:44 -07:00
|
|
|
set lazyredraw " when executing macros, untyped things
|
2015-03-09 12:27:15 -07:00
|
|
|
set shortmess=atI " be less verbose and shut up vim
|
|
|
|
set suffixes=.bak,~,.swp,.o,.log,.out " lower tab-completion priority
|
2013-07-04 01:39:44 -07:00
|
|
|
set noerrorbells visualbell t_vb= " disable bells
|
|
|
|
set scrolloff=3 " row context during scrolling
|
|
|
|
set sidescrolloff=2 " col context during scrolling
|
|
|
|
set incsearch " show first search result as we type
|
|
|
|
set ignorecase " insensitive searching
|
|
|
|
set smartcase " except when uppercase is used
|
|
|
|
set infercase " use existing case when ins-completing
|
2015-03-10 15:21:29 -07:00
|
|
|
set tabstop=8 shiftwidth=8 smarttab " 8 space tabs
|
2015-04-24 13:04:56 -07:00
|
|
|
set virtualedit=block " allow cursor anywhere in visual block
|
2016-01-23 23:00:53 -08:00
|
|
|
set foldmethod=marker " (performance issues with other methods)
|
2015-03-13 12:31:16 -07:00
|
|
|
set foldlevelstart=99 " start with everything unfolded...?
|
2015-03-09 12:27:15 -07:00
|
|
|
let c_syntax_for_h=1 " use C highlighting for .h files
|
|
|
|
set nowrap " word wrapping is pretty weak in vim
|
2019-06-07 01:47:44 -07:00
|
|
|
set nojoinspaces " don't use double-spaces for J and gq
|
2015-03-09 12:27:15 -07:00
|
|
|
set ffs=unix,dos " ffs indeed
|
2015-03-10 15:21:29 -07:00
|
|
|
set nobomb " bombs are bad ok
|
|
|
|
set undofile " remember undos across files/sessions
|
2015-03-09 12:27:15 -07:00
|
|
|
set diffopt+=iwhite " ignore whitespace in diff command
|
2016-01-08 09:12:49 -08:00
|
|
|
set ttimeoutlen=50 " make changing modes a bit snappier
|
2016-07-06 22:33:39 -07:00
|
|
|
set hidden " allow swapping out of unsaved buffers
|
2020-11-05 08:11:07 -08:00
|
|
|
set complete=.,w,b,u,t " don't scan every file with autocomplete
|
2015-03-10 15:21:29 -07:00
|
|
|
if has('mksession')
|
|
|
|
set sessionoptions=blank,buffers,curdir,options,folds,tabpages,winsize,resize,winpos
|
|
|
|
end
|
2013-07-03 15:03:54 -07:00
|
|
|
|
2016-01-23 23:00:53 -08:00
|
|
|
if has('wildignore')
|
|
|
|
" a bunch of stuff that may or may not do any good
|
|
|
|
set wildignore=""
|
2017-10-13 05:26:22 -07:00
|
|
|
set wildignore+=.git,.svn,.hg,pkg,tmp
|
2016-01-23 23:00:53 -08:00
|
|
|
set wildignore+=*.bak,*.tmp,*.log,*.cache,
|
|
|
|
set wildignore+=Desktop.ini,Thumbs.db,*.lnk,.DS_Store
|
|
|
|
set wildignore+=*.zip,*.tar,*.tar.*,
|
|
|
|
set wildignore+=*.suo,*.sln,*.pch,*.pdb,*.pgc,*.pgd
|
|
|
|
set wildignore+=*.o,*.obj,*.elf,*.lib,*.a,*.dll,*.so,*.so.*,*.exe,*.out
|
2017-10-13 05:26:22 -07:00
|
|
|
set wildignore+=*.png,*.jpg,*.jpeg,*.gif,*.pdf
|
2017-10-31 01:08:21 -07:00
|
|
|
set wildignore+=__pycache__,*.pyc,*.pyo,*.pyd,*.npy,*.npz,*.pkl
|
2016-01-23 23:00:53 -08:00
|
|
|
set wildignore+=*.gem,.bundle
|
2019-06-05 21:49:39 -07:00
|
|
|
set wildignore+=CMakeCache.txt,CMakeFiles,install_manifest.txt
|
2017-01-29 22:21:24 -08:00
|
|
|
set wildignore+=*.h5,*.npz
|
2016-01-23 23:00:53 -08:00
|
|
|
endif
|
|
|
|
|
2021-08-01 11:29:56 -07:00
|
|
|
let $PATH .= ':'.$HOME.'/sh' " allow direct invocation of shell funcs
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
" autocmd {{{1
|
2013-07-04 01:39:44 -07:00
|
|
|
|
2015-11-19 09:22:23 -08:00
|
|
|
fu! TabEight()
|
|
|
|
setlocal tabstop=8 shiftwidth=8 noexpandtab softtabstop=0
|
|
|
|
endf
|
|
|
|
|
2013-07-04 02:07:41 -07:00
|
|
|
fu! TabFour()
|
2015-03-09 10:02:16 -07:00
|
|
|
setlocal tabstop=8 shiftwidth=4 expandtab softtabstop=4
|
2013-07-04 02:07:41 -07:00
|
|
|
endf
|
2013-07-04 01:39:44 -07:00
|
|
|
|
2014-03-13 10:15:09 -07:00
|
|
|
fu! TabTwo()
|
|
|
|
setlocal tabstop=2 shiftwidth=2 expandtab
|
|
|
|
endf
|
|
|
|
|
2019-06-30 16:42:13 -07:00
|
|
|
fu! TabBad()
|
|
|
|
setlocal tabstop=4 shiftwidth=4 noexpandtab softtabstop=4
|
|
|
|
endf
|
|
|
|
|
2015-11-19 09:22:23 -08:00
|
|
|
" set TabFour as default
|
|
|
|
set tabstop=8 shiftwidth=4 expandtab softtabstop=4
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
if has('autocmd')
|
2015-11-19 09:22:23 -08:00
|
|
|
augroup tabs
|
2013-07-04 01:39:44 -07:00
|
|
|
au!
|
2014-03-13 10:15:09 -07:00
|
|
|
au BufRead,BufNewFile PKGBUILD call TabTwo()
|
2014-06-02 06:54:57 -07:00
|
|
|
au FileType ruby call TabTwo()
|
2017-03-13 05:17:24 -07:00
|
|
|
au FileType nim call TabTwo()
|
2015-11-19 09:22:23 -08:00
|
|
|
au BufRead,BufNewFile *.bt,*.1sc call TabFour()
|
2019-05-26 11:54:52 -07:00
|
|
|
au BufRead,BufNewFile *.ys call TabTwo()
|
2017-05-25 19:24:48 -07:00
|
|
|
au FileType javascript,processing call TabTwo()
|
2014-03-13 10:15:09 -07:00
|
|
|
augroup END
|
|
|
|
|
2015-04-03 01:30:50 -07:00
|
|
|
augroup whatever
|
|
|
|
au!
|
|
|
|
au BufRead,BufNewFile *.lib setlocal ft=spice
|
2015-11-19 09:22:23 -08:00
|
|
|
au BufRead,BufNewFile *.bt setlocal ft=c
|
|
|
|
au BufRead,BufNewFile *.1sc setlocal ft=c
|
2016-01-07 19:42:51 -08:00
|
|
|
au BufRead,BufNewFile *.asm setlocal ft=lips
|
2017-03-13 05:17:24 -07:00
|
|
|
au BufRead,BufNewFile *.nim setlocal ft=nim
|
2017-05-25 19:24:48 -07:00
|
|
|
au BufRead,BufNewFile *.pde setlocal ft=processing
|
2015-04-03 01:30:50 -07:00
|
|
|
augroup END
|
|
|
|
|
2021-08-02 13:43:52 -07:00
|
|
|
augroup insanity
|
|
|
|
autocmd FileType netrw setl bufhidden=wipe
|
|
|
|
augroup END
|
|
|
|
|
2016-02-07 06:53:14 -08:00
|
|
|
augroup nocomment
|
|
|
|
au!
|
2019-06-06 01:19:35 -07:00
|
|
|
au FileType * setlocal fo-=c fo-=r fo-=o
|
2015-03-10 15:21:29 -07:00
|
|
|
augroup END
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
augroup nobells " good lord vim you are archaic
|
|
|
|
au!
|
2015-03-08 15:59:44 -07:00
|
|
|
au GUIEnter * set vb t_vb=
|
|
|
|
augroup END
|
|
|
|
|
2013-07-04 02:07:41 -07:00
|
|
|
fu! ResCur() " attempt to preserve cursor position
|
|
|
|
if line("'\"") > 1 && line("'\"") <= line("$")
|
|
|
|
normal! g`"
|
|
|
|
return 1
|
|
|
|
endif
|
|
|
|
endf
|
|
|
|
augroup resCur
|
|
|
|
au!
|
2013-07-08 17:45:51 -07:00
|
|
|
au BufWinEnter * call ResCur()
|
2013-07-04 02:07:41 -07:00
|
|
|
augroup END
|
2013-07-04 01:39:44 -07:00
|
|
|
endif
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
" keys/binds {{{1
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
set backspace=eol,start,indent " make backspace useful
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
" tab completion in command-line
|
|
|
|
if has('wildmenu') | set wildmenu | endif
|
2015-03-05 10:10:22 -08:00
|
|
|
|
2019-07-29 02:53:45 -07:00
|
|
|
if &term =~ '^tmux'
|
|
|
|
" https://unix.stackexchange.com/a/34723
|
|
|
|
" tmux will send xterm-style keys when xterm-keys is on
|
2021-06-19 20:25:41 -07:00
|
|
|
exec "set <xUp>=\e[1;*A"
|
|
|
|
exec "set <xDown>=\e[1;*B"
|
|
|
|
exec "set <xRight>=\e[1;*C"
|
|
|
|
exec "set <xLeft>=\e[1;*D"
|
2019-07-29 02:53:45 -07:00
|
|
|
endif
|
|
|
|
|
2021-07-21 15:30:05 -07:00
|
|
|
" mintty pls
|
|
|
|
"exec "set <s-Tab>=\e[Z"
|
|
|
|
"map <Esc>[Z <s-tab>
|
|
|
|
"ounmap <Esc>[Z
|
|
|
|
|
2013-07-04 01:39:44 -07:00
|
|
|
" easy indent/unindent
|
|
|
|
nn <tab> >>
|
|
|
|
nn <s-tab> <<
|
|
|
|
" indentation without ending selection
|
|
|
|
vn <silent> <tab> >gv
|
|
|
|
vn <silent> <s-tab> <gv
|
2013-07-03 15:03:54 -07:00
|
|
|
|
2016-01-08 09:12:49 -08:00
|
|
|
fu! Inn(q)
|
2015-03-09 12:27:15 -07:00
|
|
|
" bind both normal and insert modes
|
2015-03-09 10:02:16 -07:00
|
|
|
let args=split(a:q, '^\s*\(<[^>]\+>\s\+\)\+\zs')
|
|
|
|
exec 'nn '.args[0].' '.args[1]
|
|
|
|
exec 'ino '.args[0].' <c-o>'.args[1]
|
|
|
|
endf
|
|
|
|
com! -nargs=+ Inn call Inn(<q-args>)
|
|
|
|
|
|
|
|
Inn <F5> :w<cr>
|
2021-08-02 13:43:52 -07:00
|
|
|
Inn <F6> :Next<cr>
|
|
|
|
Inn <F7> :next<cr>
|
2015-03-09 10:02:16 -07:00
|
|
|
Inn <F8> :e<cr>
|
2021-08-02 13:43:52 -07:00
|
|
|
Inn <F9> @@
|
2015-03-09 10:02:16 -07:00
|
|
|
Inn <F10> :bd<cr>
|
|
|
|
Inn <c-F5> :w!<cr>
|
|
|
|
Inn <c-F8> :e!<cr>
|
|
|
|
Inn <c-F10> :bd!<cr>
|
|
|
|
Inn <s-F5> :wall<cr>
|
2015-03-05 10:10:22 -08:00
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
" np++ habits
|
2015-03-09 10:02:16 -07:00
|
|
|
Inn <c-up> <c-y>
|
|
|
|
Inn <c-down> <c-e>
|
|
|
|
Inn <silent> <c-s-up> :m-2<cr>
|
|
|
|
Inn <silent> <c-s-down> :m+1<cr>
|
2015-03-10 14:42:26 -07:00
|
|
|
Inn <silent> <c-s-PageUp> :tabm -1<cr>
|
|
|
|
Inn <silent> <c-s-PageDown> :tabm +1<cr>
|
2015-03-09 10:02:16 -07:00
|
|
|
|
2019-06-05 19:09:14 -07:00
|
|
|
" jump to top and bottom
|
|
|
|
Inn <c-Home> gg
|
|
|
|
Inn <c-End> G
|
|
|
|
nn <Esc>[1;5H gg
|
|
|
|
nn <Esc>[1;5F G
|
|
|
|
ino <Esc>[1;5H <c-o>gg
|
|
|
|
ino <Esc>[1;5F <c-o>G
|
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
" hide search highlighting
|
|
|
|
Inn <silent> <c-]> :nohls<enter>
|
2013-07-04 01:39:44 -07:00
|
|
|
|
|
|
|
" rebind annoying things
|
2015-03-05 10:10:22 -08:00
|
|
|
" reflow text
|
2013-07-04 01:39:44 -07:00
|
|
|
nn Q gq
|
2015-03-24 19:54:57 -07:00
|
|
|
vn Q gq
|
2015-03-05 10:10:22 -08:00
|
|
|
" split lines (opposite of J)
|
|
|
|
nn K i<cr><esc>k$
|
2015-03-05 11:57:16 -08:00
|
|
|
vn K <nop>
|
2015-03-05 12:40:32 -08:00
|
|
|
" follow tag
|
|
|
|
nn <bar> <c-]>
|
2015-03-06 07:14:33 -08:00
|
|
|
" delete line
|
2015-03-24 19:54:57 -07:00
|
|
|
"nn D dd
|
2015-03-06 07:14:33 -08:00
|
|
|
|
2016-09-02 19:59:27 -07:00
|
|
|
" execute vim code in visual selection
|
2018-03-21 04:04:43 -07:00
|
|
|
vmap <space> "xy:@x<cr>
|
2016-09-02 19:59:27 -07:00
|
|
|
|
2015-03-09 10:02:16 -07:00
|
|
|
" this frees up x and X for use if you like
|
2019-06-08 09:52:31 -07:00
|
|
|
exec "set <s-Del>=\<Esc>[3;2~"
|
2015-03-09 12:27:15 -07:00
|
|
|
Inn <s-Del> X
|
2015-03-06 07:14:33 -08:00
|
|
|
|
|
|
|
" unfollow your leaders
|
2015-03-13 12:31:16 -07:00
|
|
|
let leader="\\"
|
2015-03-24 19:54:57 -07:00
|
|
|
" no-op
|
|
|
|
nn <Leader><Leader> :<cr>
|
2015-03-09 12:27:15 -07:00
|
|
|
"ino <c-\> <C-o><Leader> " this doesn't workkkkkkkkk
|
2015-04-04 00:14:55 -07:00
|
|
|
nm <Leader>i i?<Esc>r
|
|
|
|
nm <Leader>a a?<Esc>r
|
2015-03-06 07:14:33 -08:00
|
|
|
nn <Leader>p "0p
|
|
|
|
nn <Leader>P "0P
|
2016-01-23 23:00:53 -08:00
|
|
|
nn <Leader>e :e **/*
|
|
|
|
nn <Leader>b :ls<cr>:b<space>
|
2015-03-10 14:42:26 -07:00
|
|
|
nn <silent> <Leader>d :cd %:p:h<cr>:pwd<cr>
|
2015-03-07 07:57:26 -08:00
|
|
|
nn <Leader>. @:
|
2015-03-10 14:42:26 -07:00
|
|
|
"nn <Leader>? :exec getline(".")
|
|
|
|
nn <Leader>, :Tab /,\zs<cr>
|
2015-03-09 12:27:15 -07:00
|
|
|
"nn <Leader>x :system('chmod +x %') | e
|
2015-03-24 19:54:57 -07:00
|
|
|
|
2018-03-21 04:04:43 -07:00
|
|
|
" via bit101
|
2019-06-06 01:19:35 -07:00
|
|
|
nn <Leader>f :E<cr>
|
|
|
|
nn <Leader>F :E .<cr>
|
2016-01-23 23:00:53 -08:00
|
|
|
|
2019-06-05 19:09:25 -07:00
|
|
|
" alias :W to :w, via https://stackoverflow.com/a/3879737
|
|
|
|
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
|
|
|
|
|
2015-03-09 12:27:15 -07:00
|
|
|
" misc {{{1
|
2013-07-04 01:39:44 -07:00
|
|
|
|
2015-03-10 14:42:26 -07:00
|
|
|
set list listchars=tab:»·,trail:·,extends:…,nbsp:‗
|
|
|
|
" including this in case i'm on a _really_ bad terminal:
|
|
|
|
"set list listchars=tab:>-,trail:.,extends:>,nbsp:_
|
2015-03-05 10:10:22 -08:00
|
|
|
|
2021-06-19 20:25:41 -07:00
|
|
|
try | exec pathogen#infect() | catch /E117/ | endtry
|
2015-03-30 21:42:01 -07:00
|
|
|
|
2018-04-12 13:12:19 -07:00
|
|
|
let g:netrw_banner=0
|
2018-03-21 04:04:43 -07:00
|
|
|
|
2015-03-30 21:42:01 -07:00
|
|
|
set background=dark
|
|
|
|
try
|
2016-01-24 16:02:24 -08:00
|
|
|
colorscheme property16
|
2015-03-30 21:42:01 -07:00
|
|
|
catch /E185/
|
|
|
|
colorscheme desert
|
|
|
|
endtry
|
2016-01-08 09:12:49 -08:00
|
|
|
|
2021-08-02 13:43:52 -07:00
|
|
|
let g:netrw_fastbrowse = 0 " so THAT'S what's been causing me agony
|
|
|
|
|
2017-01-23 11:56:26 -08:00
|
|
|
" ctrlp {{{1
|
2016-09-19 12:52:05 -07:00
|
|
|
|
2019-06-06 01:19:35 -07:00
|
|
|
map <silent> <c-n> :CtrlPBuffer<cr>
|
2018-04-12 13:12:19 -07:00
|
|
|
let g:ctrlp_match_window='bottom,order:btt,min:1,max:24,results:24'
|
2016-09-19 12:52:05 -07:00
|
|
|
|
2016-05-26 23:42:14 -07:00
|
|
|
" machine-specific configs {{{1
|
|
|
|
|
2018-04-12 13:12:19 -07:00
|
|
|
let s:hostname=hostname()
|
2016-06-27 04:33:41 -07:00
|
|
|
if s:hostname == "phantom-pi" || s:hostname == "wraith"
|
2016-05-26 23:42:14 -07:00
|
|
|
colo Tomorrow-Night
|
|
|
|
endif
|