scripts/vim/vimrc

542 lines
12 KiB
VimL
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

" 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 noshowmode
set numberwidth=4
"set relativenumber
"set number
set colorcolumn=81
set conceallevel=1
set belloff=all
set list
set listchars=tab:»—,eol,space,trail:∴,extends:>,precedes:<
" 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="\<Tab>"
" snappier responses
set ttimeoutlen=0
set lazyredraw
" searching options (highlight, smart casing)
set showmatch
set hlsearch
set smartcase
set ignorecase
set incsearch
" tabulation (3 space hard tabs, auto-indent when my muscle memory demands it)
set autoindent
set smarttab
set noexpandtab
set copyindent
set preserveindent
set softtabstop=0
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_show=2
let g:buftabline_numbers=2
let g:buftabline_indicators=1
let g:buftabline_separators=0
let g:buftabline_plug_max=19
" 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']
" airline
let g:airline_powerline_fonts=1
let g:airline_mode_map = {
\ '__' : '-',
\ 'c' : '/',
\ 'i' : 'I',
\ 'ic' : 'i',
\ 'ix' : 'ï',
\ 'n' : '~',
\ 'multi': 'M',
\ 'ni' : 'N',
\ 'no' : 'n',
\ 'R' : 'R',
\ 'Rv' : 'r',
\ 's' : 's',
\ 'S' : 'S',
\ '' : 'ß',
\ 't' : 't',
\ 'v' : 'v',
\ 'V' : 'V',
\ '' : 'ʌ',
\}
let g:airline#extensions#default#section_truncate_width={}
fu! AirlineInit()
let spc = g:airline_symbols.space
call airline#parts#define_function('mfsize', 'FileSize')
let g:airline_section_a=airline#section#create_left(['mode', 'readonly'])
let g:airline_section_b=airline#section#create(['filetype', 'hunks', 'branch', 'tagbar'])
let g:airline_section_c=airline#section#create(['file'])
let g:airline_section_x=airline#section#create_right([])
let g:airline_section_y=airline#section#create_right(['mfsize'])
let g:airline_section_z=airline#section#create_right(['%4l:%-3c'.spc, '%4L'.spc, '%3p%%'])
let g:airline_section_error=''
let g:airline_section_warning=''
endfu
au User AirlineAfterInit call AirlineInit()
" gui and terminal specific settings
if has('gui_running')
set guicursor+=i:hor10-Cursor
set guicursor+=a:blinkon0
set guioptions=agit
set guitablabel=%N.%t
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 quantum
" good color schemes:
" aurora
" badwolf
" candid
" 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
" plastic
" quantum
syntax on
filetype on
filetype plugin on
filetype indent on
" Functions ------------------------------------------------------------------|
" Automatic headers
fu! <SID>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! "<Args>" | 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 <buffer> 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 <buffer> 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 <Plug>(EasyAlign)
xm ga <Plug>(EasyAlign)
nn <Leader>e :call <SID>FillLine()<CR>
" TagBar
nm <F5> :TagbarToggle<CR>
" Copyright header
nn <Leader>C :0put=strftime('// Copyright © %Y ')<CR>A
" Align text
nn <Leader>c :center<CR>
nn <Leader>R :right<CR>
" Faux asterism
nn <Leader>A o<Esc>A*<CR>* *<Esc><Up>2:center<CR>
" Substitute word across file
nn <Leader>s :%s/\<<C-R><C-W>\>//g<Left><Left>
" Fuck off, highlighting
nn <silent> <Leader><Space> :nohlsearch\|:echo<CR>
" Block comments
nn <Leader>r O//<CR>//<CR>//<Up><End> <Esc>A
" Preview tag
nn <Leader>t :ptag <C-R><C-W><CR>
" Fold mark
nn <Leader>f zfa{
" Spellcheck toggle
nn <Leader>q :setlocal spell!<CR>
" Sort
nn <Leader>S vip:sort<CR>
vn <Leader>S :sort<CR>
" Tmux-like bindings
nn <silent> <Leader>bw :let g:netrw_chgwin = winnr()<CR>
nn <silent> <Leader>b" :new<CR>:wincmd x<CR>:wincmd j<CR>
nn <silent> <Leader>b% :vnew<CR>:wincmd x<CR>:wincmd l<CR>
" Buffer movement
nn <silent> <Leader>bn :bnext<CR>
nn <silent> <Leader>bv :bprevious<CR>
nn <silent> <Leader>be :BufExplorer<CR>
nn <silent> <Leader>bd :bprevious\|bdelete #<CR>
nn <silent> <Leader>bq :bufdo bdelete<CR>
nn <silent> <Leader>bs :new\|BufExplorer<CR>
nn <silent> <Leader>br :browse oldfiles<CR>
nm <Leader>1 <Plug>BufTabLine.Go(1)
nm <Leader>2 <Plug>BufTabLine.Go(2)
nm <Leader>3 <Plug>BufTabLine.Go(3)
nm <Leader>4 <Plug>BufTabLine.Go(4)
nm <Leader>5 <Plug>BufTabLine.Go(5)
nm <Leader>6 <Plug>BufTabLine.Go(6)
nm <Leader>7 <Plug>BufTabLine.Go(7)
nm <Leader>8 <Plug>BufTabLine.Go(8)
nm <Leader>9 <Plug>BufTabLine.Go(9)
" Copy whole file
nn <silent> <Leader>x gg"+yG``
" Mirror
vn <Leader>v c<C-O>:set revins<CR><C-R>"<Esc>:set norevins<CR>
" Fix syntax
nn <silent> <F11> :syntax sync fromstart<CR>
nn <silent> <F12> :syntax off\|syntax on\|RainbowToggleOn<CR>
" Ctrl-Arrow movement
nn <silent> <C-K> <C-W>+
nn <silent> <C-J> <C-W>-
nn <silent> <C-H> b
nn <silent> <C-L> w
nn <silent> <C-Up> <C-W>+
nn <silent> <C-Down> <C-W>-
nn <silent> <C-Left> b
nn <silent> <C-Right> w
" Better movement
nn j gj
vn j gj
nn k gk
vn k gk
nn <Del> x
vn <Del> x
nn <Up> <NOp>
vn <Up> <NOp>
nn <Down> <NOp>
vn <Down> <NOp>
nn <Left> <NOp>
vn <Left> <NOp>
nn <Right> <NOp>
vn <Right> <NOp>
nn <End> <NOp>
vn <End> <NOp>
nn <Home> <NOp>
vn <Home> <NOp>
nn <PageDown> <NOp>
vn <PageDown> <NOp>
nn <PageUp> <NOp>
vn <PageUp> <NOp>
" abolish
nm cr <Plug>(abolish-coerce-word)
" find
nn KK :Gr \b<C-r><C-w>\b<CR>
nn Kk :Gr<Space>
" quick lambda
nn <Leader>l<Esc>
" 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=#</\z1># fold'],
\ },
\ 'xhtml': {
\ 'parentheses': ['start=/\v\<\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'))?)*\>/ end=#</\z1># 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=#</\z1># 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=#</\z1># 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