dotfiles/vim/.vimrc

430 lines
13 KiB
VimL
Raw Normal View History

2020-01-23 13:29:11 -05:00
" vim-plug {{{
" Automatic installation
2020-01-15 11:18:49 -05:00
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugins')
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin --all' }
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'w0rp/ale'
Plug 'airblade/vim-gitgutter'
Plug 'itchyny/lightline.vim'
Plug 'tpope/vim-repeat'
Plug 'haya14busa/incsearch.vim'
Plug 'gorodinskiy/vim-coloresque'
Plug 'sheerun/vim-polyglot'
Plug 'nvie/vim-flake8'
Plug 'KKPMW/sacredforest-vim'
Plug 'wolf-dog/lightline-sceaduhelm.vim'
2020-01-23 13:13:02 -05:00
" Plug 'unblevable/quick-scope'
2020-01-15 11:18:49 -05:00
Plug 'tpope/vim-fugitive'
2020-02-24 20:27:04 -05:00
" Plug 'l04m33/vlime', {'rtp': 'vim/'}
" Plug 'kovisoft/paredit'
2020-01-23 13:13:02 -05:00
Plug 'sainnhe/vim-color-forest-night'
Plug 'justinmk/vim-sneak'
Plug 'axvr/zepl.vim'
2020-07-15 13:48:08 -04:00
" Plug 'kovisoft/slimv'
Plug 'tpope/vim-vinegar'
Plug 'preservim/nerdtree'
Plug 'vimwiki/vimwiki'
Plug 'simnalamburt/vim-mundo'
Plug 'tpope/vim-dadbod'
Plug 'junegunn/gv.vim'
Plug 'rbong/vim-flog'
Plug 'tpope/vim-unimpaired'
2020-07-15 13:48:08 -04:00
" Clojure
Plug 'guns/vim-clojure-static' " syntax
Plug 'tpope/vim-fireplace'
Plug 'guns/vim-sexp'
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'dylanaraps/wal.vim'
Plug 'alvan/vim-closetag'
Plug 'mattn/emmet-vim'
2020-07-15 13:48:08 -04:00
" Plug 'tpope/vim-salve'
Plug 'chrisbra/colorizer'
2020-07-15 13:48:08 -04:00
" cljfold
" " Todo:
" "
2020-01-15 11:18:49 -05:00
call plug#end()
"}}}
2020-01-23 13:29:11 -05:00
" appearance {{{
2021-03-14 21:20:11 +00:00
colorscheme zenburn
" colorscheme wal
2020-01-23 13:41:26 -05:00
syntax on " Enable syntax
2020-02-07 08:49:43 -05:00
set encoding=utf-8 " Keep utf-8 encoding
2020-01-23 13:41:26 -05:00
set scrolloff=2 " Keep at least 3 lines above and below cursor
set showmode " Something something buffers
set showcmd " Show command in bottom bar
set wildmenu " Visual autocomplete for command menu
2020-01-23 13:29:11 -05:00
set wildmode=list:longest " Show all completions on tab
2020-02-24 20:27:04 -05:00
set laststatus=2 " Last window will always have statusline
2020-01-23 13:41:26 -05:00
set showmatch " Highlight matching [{()}]
set cursorline " Highlight current line
2020-01-23 13:29:11 -05:00
" remove underline on current line number
2020-02-24 20:27:04 -05:00
hi CursorLineNr cterm=bold
2020-01-15 11:18:49 -05:00
2020-01-23 13:29:11 -05:00
" Lightline
let g:lightline = { 'colorscheme': 'sceaduhelm' }
2020-01-15 11:18:49 -05:00
set fillchars+=vert:│
2020-01-23 13:41:26 -05:00
command! LightlineReload call LightlineReload()
function! LightlineReload()
call lightline#init()
call lightline#colorscheme()
call lightline#update()
endfunction
2020-01-15 11:18:49 -05:00
" }}}
2020-01-23 13:29:11 -05:00
" Movement {{{
2020-01-15 11:18:49 -05:00
" TODO: map alt-j and k to move text lines vertically, maintaining indent
" }}}
2020-01-23 13:29:11 -05:00
" Folding {{{
2020-02-07 08:49:43 -05:00
set foldenable " Enable folding
set foldmethod=marker " Fold sections by marker
set foldlevel=0 " Fold by default
set modelines=1 " Check final line of file for modeline
2020-01-23 13:41:26 -05:00
" }}}
2020-01-15 11:18:49 -05:00
2020-01-23 13:29:11 -05:00
" behavior {{{
2020-01-23 13:41:26 -05:00
set nocompatible " Turn off vi compatability nonsense
set hidden " Hide buffer when opening new file
set visualbell " Use visual bell instead of beeping
set ttyfast " Improves smoothness and drawing
2020-01-23 13:29:11 -05:00
set backspace=indent,eol,start " Always allow backspacing
2020-01-23 13:41:26 -05:00
set undofile " Make .un file for persistent undo
set relativenumber " Make numbers relative to current line
set lazyredraw " Redraw only when necessary
set updatetime=100 " Make updates happen faster (gitgutter)
set splitright " Make split to right by default
set splitbelow
2020-02-24 20:27:04 -05:00
set winheight=30 " Soft minimum window height (active)
"set winminheight=10 " Hard minimum window height (inactive)
set winwidth=85 " Window width for current window
2020-02-24 20:27:04 -05:00
set winminwidth=30 " Hard minimum for window width
set t_vb= " No visual bell ever
let g:sneak#use_ic_scs=1
set virtualedit=block
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" searching {{{
2020-01-23 13:41:26 -05:00
set gdefault " Remove default g flag on search
2020-01-23 13:29:11 -05:00
set ignorecase " Ignore case for searches
2020-01-23 13:41:26 -05:00
set smartcase " Case-specific only when uppercase
set hlsearch " Don't continue to highlight searched phrases.
set incsearch " But do search as characters are entered
2020-01-23 13:29:11 -05:00
" Remap tab to jump by brackets
" Nnoremap <tab> %
" Vnoremap <tab> %
2020-01-23 13:41:26 -05:00
" Remap tab to jump by window
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" tab settings {{{
2020-02-07 08:49:43 -05:00
set tabstop=4 " Number of visual spaces per tab
set softtabstop=4 " Should always = tabstop
set shiftwidth=4 " Indent/outdent by 4 columns
2020-01-23 13:41:26 -05:00
set expandtab " Tabs are spaces
set shiftround " Always indent/outdent to the nearest tabstop
2020-01-23 13:29:11 -05:00
" Make search terms more visible
2020-01-15 11:18:49 -05:00
highlight Visual ctermbg=DarkGreen ctermfg=Black
2020-01-23 13:41:26 -05:00
set autoindent " Auto indentation
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" ruler settings {{{
set rulerformat=%l,%-2v\|%4L\ Lines " Display line, column, and total lines
2020-01-23 13:41:26 -05:00
set ruler " Turn on ruler
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" long line handling {{{
" set textwidth=79
" set fo=t
2020-01-15 11:18:49 -05:00
" set colorcolumn=85
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" leaders {{{
2020-01-15 11:18:49 -05:00
:let mapleader = ","
2020-01-23 13:29:11 -05:00
" Clear search highlighting with leader-space
2020-01-15 11:18:49 -05:00
nnoremap <leader><space> :noh<cr>
2020-07-15 13:48:08 -04:00
2020-01-23 13:29:11 -05:00
" Underline with line of the same length
2020-01-15 11:18:49 -05:00
nnoremap <leader>- yypv$r-
2020-01-23 13:29:11 -05:00
" Insert date on current line
2020-01-15 11:18:49 -05:00
nnoremap <leader>d k :r !date <cr>
2020-01-23 13:13:02 -05:00
nnoremap <leader>k :vert new ~/.vim/bindings.md <cr>
2020-03-10 07:07:51 -04:00
tnoremap <leader><esc> <C-\><C-n>
2020-01-23 13:41:26 -05:00
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" invisible characters {{{
2020-01-15 11:18:49 -05:00
set list
set listchars=tab:▸\ ,eol
2020-01-23 13:41:26 -05:00
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" hjkl {{{
" Disable arrow keys in normal and visual mode
2020-01-15 11:18:49 -05:00
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
2020-01-23 13:29:11 -05:00
" Disable h and l
2020-01-15 11:18:49 -05:00
" nnoremap h <nop>
" nnoremap l <nop>
2020-01-23 13:29:11 -05:00
" Make j and k move by screen line, not file line
2020-01-15 11:18:49 -05:00
nnoremap j gj
nnoremap k gk
2020-01-23 13:41:26 -05:00
2020-01-15 11:18:49 -05:00
"}}}
2020-02-24 20:27:04 -05:00
" slimv{{{
2020-07-15 13:48:08 -04:00
" let g:slimv_repl_split=2
" let g:slimv_repl_split_size=10
2020-02-24 20:27:04 -05:00
"}}}
2020-01-15 11:18:49 -05:00
" {{{ web dev
autocmd FileType html set softtabstop=2
autocmd FileType html set ts=2
autocmd FileType html set shiftwidth=2
autocmd FileType css set softtabstop=2
autocmd FileType css set ts=2
autocmd FileType html set shiftwidth=2
" Emmet tab size
let g:user_emmet_settings = {
\ 'indentation' : ' '
\}
" }}}
2020-07-15 13:48:08 -04:00
" clojure {{{
" TODO: make only work in clojure files
nnoremap <leader>e :Eval<CR> " eval form
nnoremap <leader>E :%Eval<CR> " eval file
" }}}
2020-01-23 13:29:11 -05:00
" split pane navigation {{{
" Map vertical split to \ w, switch to it, open explorer, prompt for filename
" TODO: make new window prompt use fzf
" nnoremap <leader>w <C-w>v<C-w>l:e <C-S-d><BS><BS>open
2020-01-23 13:29:11 -05:00
" Switch panes wit ctrl + h/j/k/l
2020-01-15 11:18:49 -05:00
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
2020-01-23 13:13:02 -05:00
nnoremap <C-c> :close <cr>
nnoremap <C-n> :bn <cr>
" Term mode
tnoremap <C-h> <C-w>h
tnoremap <C-j> <C-w>j
tnoremap <C-k> <C-w>k
tnoremap <C-l> <C-w>l
tnoremap <C-c> :close <cr>
tnoremap <C-n> :bn <cr>
tnoremap <Esc> <C-\><C-n>
2020-01-23 13:29:11 -05:00
" TODO: remap pane resize to something else (leader?)
" quick-scope
2020-01-15 11:18:49 -05:00
" Trigger a highlight in the appropriate direction when pressing these keys:
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
augroup qs_colors
autocmd!
autocmd ColorScheme * highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
autocmd ColorScheme * highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
augroup END
nnoremap <c-s> gt
2020-01-23 13:41:26 -05:00
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" file specific {{{
" In markdown files, when writing add two spaces to each line to fix spacing
" In compiled version
2020-01-23 13:13:02 -05:00
" au BufWritePost *.md silent! %s/[^ ]\zs$/\1 /
2020-01-23 13:29:11 -05:00
" TODO: find a better solution
" Bold something in a markdown file
2020-01-23 13:13:02 -05:00
" :au FileType markdown nmap <leader>b i**<esc>ea**<esc>b
2020-01-23 13:29:11 -05:00
" Python
" au BufNewFile,BufRead *.py
2020-01-15 11:18:49 -05:00
"\ set tabstop=4
"\ set softtabstop=4
"\ set shiftwidth=4
"\ set textwidth=79
"\ set expandtab
"\ set autoindent
"\ set fileformat=unix
2020-01-23 13:29:11 -05:00
"" Webdev
" au BufNewFile,BufRead *.js, *.html, *.css
2020-01-15 11:18:49 -05:00
"\ set tabstop=2
"\ set softtabstop=2
"\ set shiftwidth=2
2020-01-23 13:41:26 -05:00
2020-01-15 11:18:49 -05:00
"}}}
2020-01-23 13:29:11 -05:00
" plugin modification {{{
" FZF
2020-01-16 17:29:49 -05:00
map <C-p> :FZF<cr>
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~30%' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
2020-01-23 13:41:26 -05:00
\ { 'fg': [ 'fg', 'Normal'],
\ 'bg': [ 'bg', 'Normal'],
\ 'hl': [ 'fg', 'Comment'],
\ 'fg+': [ 'fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': [ 'bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': [ 'fg', 'Statement'],
\ 'info': [ 'fg', 'PreProc'],
\ 'border': [ 'fg', 'Ignore'],
\ 'prompt': [ 'fg', 'Conditional'],
\ 'pointer': [ 'fg', 'Exception'],
\ 'marker': [ 'fg', 'Keyword'],
\ 'spinner': [ 'fg', 'Label'],
\ 'header': [ 'fg', 'Comment'] }
2020-01-16 17:29:49 -05:00
" EasyAlign
"" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
"}}}
2020-01-15 14:14:30 -05:00
" git commands {{{
2020-01-23 13:13:02 -05:00
nmap ghv <Plug>(GitGutterPreviewHunk)
nmap ghn <Plug>(GitGutterNextHunk)
nmap ghp <Plug>(GitGutterPrevHunk)
nmap ghf <Plug>(GitGutterFold)
2020-07-15 13:48:08 -04:00
nmap ghs <Plug>(GitGutterStageHunk)
2020-06-25 15:40:56 -04:00
" Controls fugitive diff split direction
set diffopt=vertical
command! Gundo !git reset --soft HEAD~1
2020-01-15 11:18:49 -05:00
"}}}
" fold search {{{
" command to fold everything except what you searched for
command! -nargs=* Fs
\ if <q-args> != '' |
\ exe "normal /".<q-args>."\<CR>" |
\ endif |
\ if @/ != '' |
\ setlocal
\ foldexpr=FoldRegex(v:lnum,@/,2)
\ foldmethod=expr
\ foldlevel=0 |
\ endif
2020-07-15 13:48:08 -04:00
function! FoldRegex(lnum,pat,context)
" get start/end positions for context lines
let startline=a:lnum-a:context
while startline < 1
let startline+=1
endwhile
let endline=a:lnum+a:context
while endline > line('$')
let endline-=1
endwhile
2020-07-15 13:48:08 -04:00
let returnval = 2
2020-07-15 13:48:08 -04:00
let pos=getpos('.')
2020-07-15 13:48:08 -04:00
" search from current line to get matches ON the line
call cursor(a:lnum, 1)
let matchline=search(a:pat,'cW',endline)
if matchline==a:lnum
let returnval = 0
elseif matchline > 0
" if current line didn't match, there could have been a match within
" trailing context lines
let returnval = 1
else
" if no match at current line, search leading context lines for a match
call cursor(startline, 1)
let matchline=search(a:pat,'cW',a:lnum)
if matchline > 0
let returnval = 1
endif
endif
2020-07-15 13:48:08 -04:00
call setpos('.',pos)
2020-07-15 13:48:08 -04:00
return returnval
endfun
2020-01-15 14:14:30 -05:00
" }}}
" copy matches {{{
function! CopyMatches(reg)
let hits = []
%s//\=len(add(hits, submatch(0))) ? submatch(0) : ''/gne
let reg = empty(a:reg) ? '+' : a:reg
execute 'let @'.reg.' = join(hits, "\n") . "\n"'
endfunction
command! -register CopyMatches call CopyMatches(<q-reg>)
" }}}
" vimrc {{{
" source $MYVIMRC reloads the saved $MYVIMRC
:nmap <Leader>s :source $MYVIMRC
2020-02-07 08:49:43 -05:00
" opens $MYVIMRC for editing, or use :tabedit $MYVIMRC
:nmap <Leader>v :e $MYVIMRC
2020-02-07 08:49:43 -05:00
"}}}
2020-02-17 22:07:39 -05:00
" zepl {{{
augroup zepl
autocmd!
autocmd FileType python let b:repl_config = { 'cmd': 'python3' }
autocmd FileType javascript let b:repl_config = { 'cmd': 'python3' }
autocmd FileType clojure let b:repl_config = { 'cmd': 'clj' }
autocmd FileType scheme let b:repl_config = { 'cmd': 'rlwrap csi' }
autocmd FileType lisp let b:repl_config = { 'cmd': 'sbcl' }
autocmd FileType julia let b:repl_config = { 'cmd': 'julia' }
" autocmd FileType cs let b:repl_config = { 'cmd': '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"' }
autocmd FileType cs let b:repl_config = { 'cmd': 'cmd' }
augroup END
2020-02-17 22:07:39 -05:00
"}}}
2020-01-15 14:14:30 -05:00
2020-07-10 12:35:42 -04:00
" TODO: rebind c-n
" TODO: change ,k to ,n and add notes to version control
2020-01-23 13:29:11 -05:00
" folding options, this must be last in file
2020-01-15 11:18:49 -05:00
" vim:foldmethod=marker:foldlevel=0