From c05aad646e1c5f6b3c4eaa58e04b58f576779cb5 Mon Sep 17 00:00:00 2001 From: ikeane Date: Thu, 25 Jun 2020 15:06:02 -0400 Subject: [PATCH] A couple months of changes to my windows vimrc :( --- vim/_vimrc | 418 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 418 insertions(+) create mode 100644 vim/_vimrc diff --git a/vim/_vimrc b/vim/_vimrc new file mode 100644 index 0000000..b2d02b1 --- /dev/null +++ b/vim/_vimrc @@ -0,0 +1,418 @@ + +" vim-plug {{{ + " Automatic installation +" 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 'junegunn/fzf.vim' + 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' + " Plug 'unblevable/quick-scope' + Plug 'tpope/vim-fugitive' + " Plug 'l04m33/vlime', {'rtp': 'vim/'} + " Plug 'kovisoft/paredit' + Plug 'sainnhe/vim-color-forest-night' + Plug 'justinmk/vim-sneak' + Plug 'axvr/zepl.vim' + 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' + + " Todo: + " GV + " Gundo (or undotree?) + " Emmett + " Fugitive + " Vimwiki + " Plug 'ryanss/vim-hackernews' + " Plug 'mbbill/undotree' or Plug 'sjl/gundo.vim' + " Plug 'tpope/vim-projectionist' + " Plug 'mileszs/ack.vim' + " Plug 'vim-pandoc/vim-pandoc' + " Plug 'alfredodeza/pytest.vim' + " Plug 'docker/docker' + " Plug vim-scripts/indentpython.vim + " + call plug#end() + +"}}} + +" appearance {{{ + colorscheme zenburn + syntax on " Enable syntax + filetype plugin on + set encoding=utf-8 " Keep utf-8 encoding + 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 + set wildmode=list:longest " Show all completions on tab + set laststatus=2 " Last window will always have statusline + set showmatch " Highlight matching [{()}] + set cursorline " Highlight current line + + " remove underline on current line number + hi CursorLineNr cterm=bold + + " Lightline + let g:lightline = { 'colorscheme': 'sceaduhelm' } + set fillchars+=vert:│ + + command! LightlineReload call LightlineReload() + + function! LightlineReload() + call lightline#init() + call lightline#colorscheme() + call lightline#update() + endfunction +" }}} + +" Movement {{{ + " TODO: map alt-j and k to move text lines vertically, maintaining indent +" }}} + +" Folding {{{ + 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 + +" }}} + +" behavior {{{ + 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 + set backspace=indent,eol,start " Always allow backspacing + 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 + set winheight=30 " Soft minimum window height (active) + "set winminheight=10 " Hard minimum window height (inactive) + set winwidth=85 " Window width for current window + 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 +"}}} + +" searching {{{ + set gdefault " Remove default g flag on search + set ignorecase " Ignore case for searches + 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 + " Remap tab to jump by brackets + " Nnoremap % + " Vnoremap % + " Remap tab to jump by window + +"}}} + +" tab settings {{{ + set tabstop=4 " Number of visual spaces per tab + set softtabstop=4 " Should always = tabstop + set shiftwidth=4 " Indent/outdent by 4 columns + set expandtab " Tabs are spaces + set shiftround " Always indent/outdent to the nearest tabstop + " Make search terms more visible + highlight Visual ctermbg=DarkGreen ctermfg=Black + set autoindent " Auto indentation + +"}}} + +" ruler settings {{{ + set rulerformat=%l,%-2v\|%4L\ Lines " Display line, column, and total lines + set ruler " Turn on ruler + +"}}} + +" long line handling {{{ + " set textwidth=79 + " set fo=t +" set colorcolumn=85 + +"}}} + +" leaders {{{ + :let mapleader = "," + + " Clear search highlighting with leader-space + nnoremap :noh + + " Underline with line of the same length + nnoremap - yypv$r- + + " Insert date on current line + nnoremap d k :r !date + + nnoremap k :vert new ~/.vim/bindings.md + +"}}} + +" invisible characters {{{ + set list + set listchars=tab:▸\ ,eol:¬ + +"}}} + +" hjkl {{{ + " Disable arrow keys in normal and visual mode + nnoremap + nnoremap + nnoremap + nnoremap + inoremap + inoremap + inoremap + inoremap + " Disable h and l + " nnoremap h + " nnoremap l + " Make j and k move by screen line, not file line + nnoremap j gj + nnoremap k gk + +"}}} + +" slimv{{{ + let g:slimv_repl_split=2 + let g:slimv_repl_split_size=10 +" +"}}} + +" split pane navigation {{{ + " Map vertical split to \ w, switch to it, open explorer, prompt for filename + " TODO: make new window prompt use fzf + " nnoremap w vl:e open + " Switch panes wit ctrl + h/j/k/l + nnoremap h + nnoremap j + nnoremap k + nnoremap l + nnoremap :close + nnoremap :bn + " Term mode + tnoremap h + tnoremap j + tnoremap k + tnoremap l + tnoremap :close + tnoremap :bn + tnoremap + + " TODO: remap pane resize to something else (leader?) + " quick-scope + " 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 gt + +"}}} + +" file specific {{{ + " In markdown files, when writing add two spaces to each line to fix spacing + " In compiled version + " au BufWritePost *.md silent! %s/[^ ]\zs$/\1 / + " TODO: find a better solution + " Bold something in a markdown file + " :au FileType markdown nmap b i**ea**b + " Python + " au BufNewFile,BufRead *.py + "\ set tabstop=4 + "\ set softtabstop=4 + "\ set shiftwidth=4 + "\ set textwidth=79 + "\ set expandtab + "\ set autoindent + "\ set fileformat=unix + "" Webdev + " au BufNewFile,BufRead *.js, *.html, *.css + "\ set tabstop=2 + "\ set softtabstop=2 + "\ set shiftwidth=2 + +"}}} + +" plugin modification {{{ + " FZF + map :FZF + " 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 = + \ { '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'] } + + " EasyAlign + "" Start interactive EasyAlign in visual mode (e.g. vipga) + xmap ga (EasyAlign) + " Start interactive EasyAlign for a motion/text object (e.g. gaip) + nmap ga (EasyAlign) + +"}}} + +" git commands {{{ +" TODO: map fugitive commands +" TODO: check out gv etc +" TODO: bind hunk committing + " Gitgutter hunk view + nmap ghv (GitGutterPreviewHunk) + nmap ghn (GitGutterNextHunk) + nmap ghp (GitGutterPrevHunk) + nmap ghf (GitGutterFold) + +"}}} + +" fold search {{{ + +" command to fold everything except what you searched for + command! -nargs=* Fs + \ if != '' | + \ exe "normal /".."\" | + \ endif | + \ if @/ != '' | + \ setlocal + \ foldexpr=FoldRegex(v:lnum,@/,2) + \ foldmethod=expr + \ foldlevel=0 | + \ endif + + 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 + + let returnval = 2 + + let pos=getpos('.') + + " 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 + + call setpos('.',pos) + + return returnval + endfun + +" }}} + +" 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() + +" }}} + +" vimrc {{{ + " source $MYVIMRC reloads the saved $MYVIMRC + :nmap s :source $MYVIMRC + + " opens $MYVIMRC for editing, or use :tabedit $MYVIMRC + :nmap v :e $MYVIMRC +"}}} + +" gvim {{{ + set guioptions=Ace + set guifont=Consolas:h11 + " set guifont=Bitstream\ Vera\ Sans\ Mono + set guioptions-=e + set pythondll=python27.dll +"}}} + +" 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 +"}}} + + +" folding options, this must be last in file +" vim:foldmethod=marker:foldlevel=0 + +