" Settings -------------------------------------------------------------------| " general settings (use :help for these) set confirm set wildmenu set autochdir set laststatus=2 " visuals set statusline=[%{&syntax}]\ %f set statusline+=%r set statusline+=%m set statusline+=\ %{FugitiveStatusline()} "set statusline+=\ %{tagbar#currenttag('←\ %s\ ','','f')} set statusline+=\ %= set statusline+=\ %{FileSize()} set statusline+=\ %4l:%-3c set statusline+=\ %4L set statusline+=\ %3p%% set ruler set showcmd set numberwidth=4 "set relativenumber "set number set colorcolumn=81 set conceallevel=1 set belloff=all " general movement and ergonomics set linebreak set showbreak= set virtualedit=onemore set backspace=indent,eol,start set textwidth=80 set comments=s0:/*! set comments+=mb:* set comments+=ex:*/ set comments+=s1:/* set comments+=mb:* set comments+=ex:*/ set comments+=:/// set comments+=://! set comments+=:// set comments+=b:# set comments+=b:% set formatoptions=tcrqnolj set nojoinspaces let mapleader="\" " snappier responses set ttimeoutlen=0 set lazyredraw " searching options (highlight, smart casing) set showmatch set hlsearch set smartcase set ignorecase set incsearch " tabulation (3 spaces, auto-indent when my muscle memory demands it) set autoindent set noexpandtab set smarttab set shiftwidth=3 set tabstop=3 " limits, what/when/how to save and encodings set undolevels=10000 set tabpagemax=1000 set viminfo='100,/50,<50,s10,h,% set viminfo+=n~/.vim/viminfo set encoding=utf-8 set fileencodings=ucs_bom,utf_8,sjis set fileformats=unix,dos,mac set hidden set updatetime=500 " bufexplorer let g:bufExplorerDisableDefaultKeyMapping=1 " gutentags let g:gutentags_project_root=['.git', 'Makefile'] " TwitVim let twitvim_browser_cmd='palemoon' " vim-markdown let g:vim_markdown_folding_disabled=1 " rainbow let g:rainbow_active=0 " netrw let g:netrw_banner=0 let g:netrw_liststyle=3 let g:netrw_browse_split=4 let g:netrw_altv=1 let g:netrw_winsize=20 " buftabline let g:buftabline_indicators=1 let g:buftabline_numbers=2 " TagBar let g:tagbar_vertical=7 let g:tagbar_compact=1 let g:tagbar_show_linenumbers=1 let g:tagbar_iconchars=['»', '▼'] let g:tagbar_autoshowtag=1 " abolish let g:abolish_no_mappings=1 " we set out own later " zig.vim let g:zig_fmt_autosave=0 " polyglot let g:polyglot_disabled=['c++11'] " gui and terminal specific settings if has('gui_running') set guicursor+=i:hor10-Cursor set guicursor+=a:blinkon0 set guioptions=agit set lines=48 set columns=80 else " use 256-color terminal capabilities set t_Co=256 let base16colorspace=256 set termguicolors endif " GUI-specific settings if has('gui_running') if has('gui_win32') set guifont=PxPlus_IBM_EGA8:h12:cDEFAULT:qDRAFT elseif has('gui_gtk') set guifont=IBM\ Plex\ Mono\ weight=453\ 10 set linespace=-2 elseif has('gui_macvim') set guifont=IBMPlexMono-Text:h14 set linespace=-3 set blurradius=20 set macligatures set macmeta set transparency=10 endif endif " OS-specific settings if has('win32') " windows sucks let $PATH='G:\msys64\usr\bin;'.$PATH set shellslash " netrw let key='G:/msys64/home/marrub/.ssh/id_rsa' let g:netrw_cygwin=0 let g:netrw_ignorenetrc=1 let g:netrw_list_cmd="ssh -i " . key . " USEPORT HOSTNAME ls -Fa " let g:netrw_ssh_cmd="ssh -i " . key let g:netrw_scp_cmd="scp -q -i " . key let g:netrw_sftp_cmd="sftp -i " . key let g:netrw_silent=1 " gutentags let g:gutentags_cache_dir=$VIM.'/vimtags/' " swap files set directory=$VIM/vimtemp// else if has('mac') set rubydll=/usr/local/opt/ruby/lib/libruby.dylib endif " gutentags let g:gutentags_cache_dir=$HOME.'/.vim/tags/' " searching set grepprg=rg\ --vimgrep\ -n " swap files set directory=$HOME/.vim/temp// endif " set up colors and file types colorscheme base16-material-palenight " good color schemes: " badwolf " base16-ashes " base16-atelier-cave " base16-atelier-forest " base16-atelier-heath " base16-atelier-sulphurpool " base16-circus " base16-dracula " base16-material-palenight " base16-monokai " base16-onedark " base16-porple " base16-unikitty-dark " base16-zenburn syntax on filetype on filetype plugin on filetype indent on " Functions ------------------------------------------------------------------| " Automatic headers fu! FillLine() ruby<< tw = VIM::evaluate("&tw").to_i tw = 80 if tw == 0 lin = $curbuf.line rep = tw - lin.length - 3 if rep > 0 $curbuf.line += " " + "-" * rep + "|" end . endfu " File size fu! FileSize() let fs=line2byte(line('$')+1)-1 if fs < 0 return "" else return fs endif endfu " Strip whitespace on buffer write fu! s:StripWhite() ruby<< for ln in 1..$curbuf.length rs = $curbuf[ln].rstrip if $curbuf[ln] != rs $curbuf[ln] = rs end end . endfu " Close empty buffers fu! s:CloseEmptyBuffers() let bufs = filter(range(1, bufnr('$')), 'buflisted(v:val) && empty(bufname(v:val)) && bufwinnr(v:val) < 0 && !getbufvar(v:val, "&modified")') if !empty(bufs) execute 'bdelete' join(bufs, ' ') endif endfu " Commands -------------------------------------------------------------------| " Find com -nargs=+ -complete=file -bar Gr silent! grep! "" | cwindow " Write (sudo) com W execute 'w !sudo tee > /dev/null %' | edit! " Autocommands ---------------------------------------------------------------| " Strip whitespace au FileType c,cpp,cs,java,php,ruby,rust,python,go,zscript,markdown au BufWritePre call s:StripWhite() " Enable rainbow braces au FileType c,cpp,cs,java,php,ruby,rust,python,go,zscript,html,scheme,racket,lisp,json au BufEnter RainbowToggleOn " markdown sucks au FileType markdown set comments+=fb:- comments-=b:- indentexpr= " ASM options au BufNewFile,BufRead *.s,*.inc setlocal shiftwidth=8 filetype=asm_ca65 " close empty buffers automatically au BufEnter * call s:CloseEmptyBuffers() " .rkt → Racket au BufRead,BufNewFile *.rkt set syntax=racket " .edf → conf au BufRead,BufNewFile *.edf set syntax=conf " disable most ftplugins au BufReadPre * let b:did_ftplugin=1 au BufReadPre *.rkt unlet b:did_ftplugin " enable tagbar "au VimEnter * nested :TagbarOpen " rust.vim sets Cargo.toml to use filetype `cfg` even though it shouldn't, to " fix this we simply do the same thing before it has a chance to au BufRead,BufNewFile Cargo.toml if &filetype == "" | set filetype=toml | endif " vertical split on enter "au VimEnter * vsplit " suppress readonly warnings au BufEnter * set noreadonly " Mapping --------------------------------------------------------------------| " Alignment mode nm ga (EasyAlign) xm ga (EasyAlign) nn e :call FillLine() " TagBar nm :TagbarToggle " Copyright header nn C :0put=strftime('// Copyright © %Y ')A " Align text nn c :center nn R :right " Faux asterism nn A oA** *2:center " Substitute word across file nn s :%s/\<\>//g " Fuck off, highlighting nn :nohlsearch\|:echo " Block comments nn r O////// A " Preview tag nn t :ptag " Fold mark nn f zfa{ " Spellcheck toggle nn q :setlocal spell! " Sort nn S vip:sort vn S :sort " Tmux-like bindings nn bw :let g:netrw_chgwin = winnr() nn b" :new:wincmd x:wincmd j nn b% :vnew:wincmd x:wincmd l " Buffer movement nn bn :bnext nn bv :bprevious nn be :BufExplorer nn bd :bprevious\|bdelete # nn bq :bufdo bdelete nn bs :new\|BufExplorer nn br :browse oldfiles nm 1 BufTabLine.Go(1) nm 2 BufTabLine.Go(2) nm 3 BufTabLine.Go(3) nm 4 BufTabLine.Go(4) nm 5 BufTabLine.Go(5) nm 6 BufTabLine.Go(6) nm 7 BufTabLine.Go(7) nm 8 BufTabLine.Go(8) nm 9 BufTabLine.Go(9) " Copy whole file nn x gg"+yG`` " Mirror vn v c:set revins":set norevins " Fix syntax nn :syntax sync fromstart nn :syntax off\|syntax on\|RainbowToggleOn " Ctrl-Arrow movement nn + nn - nn b nn w nn + nn - nn b nn w " Better movement nn j gj vn j gj nn k gk vn k gk nn x vn x nn vn nn vn nn vn nn vn nn vn nn vn nn vn nn vn " abolish nm cr (abolish-coerce-word) " find nn KK :Gr \b\b nn Kk :Gr " quick lambda nn l iλ " auto format nn Q gqap " Rainbow Config -------------------------------------------------------------| let g:rainbow_conf = { \ 'guifgs': ['#ff533d', '#ff973d', '#ffe13d', '#91ff3d', '#3dffd8', '#3daeff', '#6a3dff', '#ee3dff'], \ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'], \ 'operators': '_,_', \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], \ 'separately': { \ '*': {}, \ 'haskell': { \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'], \ }, \ 'tex': { \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'], \ }, \ 'vim': { \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'], \ }, \ 'xml': { \ 'syn_name_prefix': 'xmlRainbow', \ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=## fold'], \ }, \ 'xhtml': { \ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=## fold'], \ }, \ 'html': { \ 'parentheses': ['start=/\v\<((script|style|area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=## fold'], \ }, \ 'perl': { \ 'syn_name_prefix': 'perlBlockFoldRainbow', \ }, \ 'php': { \ 'syn_name_prefix': 'phpBlockRainbow', \ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=## fold', 'start=/(/ end=/)/ containedin=@htmlPreproc contains=@phpClTop', 'start=/\[/ end=/\]/ containedin=@htmlPreproc contains=@phpClTop', 'start=/{/ end=/}/ containedin=@htmlPreproc contains=@phpClTop'], \ }, \ 'stylus': { \ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'], \ }, \ 'css': 0, \ 'sh': 0, \ } \} " EOF