From 4b195da0e2ba59186087916d667c54aafae6394d Mon Sep 17 00:00:00 2001 From: Wryn Wagner Date: Thu, 26 Sep 2019 16:00:03 -0600 Subject: [PATCH] Broke out vim rc into nicer pieces :) --- config/i3/config | 4 +- redirect | 1 + vim/abbreviations.vim | 6 +++ vim/edit_rc.vim | 6 +++ vim/file_formatting.vim | 25 +++++++++ vim/general_set.vim | 22 ++++++++ vim/global_sets.vim | 21 ++++++++ vim/rc.vim | 93 +++++----------------------------- vim/window_pane_navigation.vim | 15 ++++++ 9 files changed, 111 insertions(+), 82 deletions(-) create mode 100644 vim/abbreviations.vim create mode 100644 vim/edit_rc.vim create mode 100644 vim/file_formatting.vim create mode 100644 vim/general_set.vim create mode 100644 vim/global_sets.vim create mode 100644 vim/window_pane_navigation.vim diff --git a/config/i3/config b/config/i3/config index 3d65e79..d6d93ba 100644 --- a/config/i3/config +++ b/config/i3/config @@ -136,10 +136,10 @@ mode "resize" { # Pressing right will grow the window’s width. # Pressing up will shrink the window’s height. # Pressing down will grow the window’s height. - bindsym h resize shrink width 10 px or 10 ppt + bindsym h resize grow width 10 px or 10 ppt bindsym j resize grow height 10 px or 10 ppt bindsym k resize shrink height 10 px or 10 ppt - bindsym l resize grow width 10 px or 10 ppt + bindsym l resize shrink width 10 px or 10 ppt # back to normal: Enter or Escape or $mod+r bindsym Return mode "default" diff --git a/redirect b/redirect index 824f64e..1d080eb 100755 --- a/redirect +++ b/redirect @@ -31,6 +31,7 @@ if [ ! -f "$LOCAL_VIM_SETUP" ]; then echo 'let $WRYNVIMRC=expand("$VIM_DIR/rc.vim")' >> $LOCAL_VIM_SETUP echo 'let $WRYNBASH=expand("$RC_DIR/bashrc")' >> $LOCAL_VIM_SETUP echo 'let $MYBASHRC=expand("$HOME/.bashrc")' >> $LOCAL_VIM_SETUP + echo 'let $WEBBROWSER="' $(which google-chrome-stable) '"' >> $LOCAL_VIM_SETUP else echo 'vim environment variables already set up' fi diff --git a/vim/abbreviations.vim b/vim/abbreviations.vim new file mode 100644 index 0000000..d5c2d64 --- /dev/null +++ b/vim/abbreviations.vim @@ -0,0 +1,6 @@ +" -- Abbreviation Dictionary ------------------------- {{{ +iabbrev @@ wagner.wryn@gmail.com +iabbrev ssig -----------------------Wryn Wagnerwagner.wryn@gmail.com(720)557-5443----------------------- + +iabbrev psvm public static void main(String[] args) {} +" }}} diff --git a/vim/edit_rc.vim b/vim/edit_rc.vim new file mode 100644 index 0000000..36b4142 --- /dev/null +++ b/vim/edit_rc.vim @@ -0,0 +1,6 @@ +" -- VIMRC ------------------------------------------- {{{ +nnoremap ev :vsp $WRYNVIMRC +nnoremap sv :source $MYVIMRC +nnoremap eb :vsp $MYBASHRC +nnoremap emb :vsp $WRYNBASH +" }}} diff --git a/vim/file_formatting.vim b/vim/file_formatting.vim new file mode 100644 index 0000000..3f00b03 --- /dev/null +++ b/vim/file_formatting.vim @@ -0,0 +1,25 @@ +syntax on " detect syntax + +" -- File Formatting ------------------------------------- {{{ +augroup filetype_specific_formatting + autocmd! + autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab foldmethod=indent foldlevel=99 + autocmd FileType java setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=indent foldlevel=99 + autocmd FileType cs setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=indent foldlevel=99 + autocmd FileType html setlocal tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab foldmethod=indent foldlevel=99 + autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab foldmethod=indent foldlevel=99 + autocmd FileType vim setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=marker foldlevel=1 + autocmd FileType sh setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=indent foldlevel=99 + autocmd FileType lisp setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab foldmethod=manual foldlevel=99 + autocmd FileType markdown setlocal tabstop=2 noexpandtab foldmethod=indent foldlevel=99 spell + autocmd FileType tex setlocal tabstop=2 noexpandtab foldmethod=indent foldlevel=99 spell +augroup end +" }}} + + +" ec Commands run on a per-extension basis {{{ +augroup execute_file_shortcuts + " tex opens pdf in chrome + autocmd FileType tex nnoremap ec :! $WEBBROWSER %:r.pdf +augroup end +" }}} diff --git a/vim/general_set.vim b/vim/general_set.vim new file mode 100644 index 0000000..3ddfeed --- /dev/null +++ b/vim/general_set.vim @@ -0,0 +1,22 @@ +set linebreak " automatically wraps text +set breakindent " indent for single-line wrap +set breakindentopt=shift:3 " indent amount for single-line wrap + +set formatoptions=lj +" l = prevents the breaking up of words +" j = remove comment leaders when joining lines + +let &t_co=256 " use 256-color + +set number " show line numbers +set autoindent " match indentation with next line +set smartindent " match indentation with syntax + +set spellfile=$VIM_DIR/en.utf-8.add +set spelllang=en + +set showmatch " -- emit 'beep' when no matching symbol, +set matchtime=0 " -- but don't jump to it. + +set timeoutlen=200 " -- short timeout for multi-key functions + diff --git a/vim/global_sets.vim b/vim/global_sets.vim new file mode 100644 index 0000000..e715ae9 --- /dev/null +++ b/vim/global_sets.vim @@ -0,0 +1,21 @@ +set linebreak " automatically wraps text +set breakindent " indent for single-line wrap +set breakindentopt=shift:3 " indent amount for single-line wrap + +set formatoptions=lj +" l = prevents the breaking up of words +" j = remove comment leaders when joining lines + +let &t_co=256 " use 256-color + +set number " show line numbers +set autoindent " match indentation with next line +set smartindent " match indentation with syntax + +set spellfile=$VIM_DIR/en.utf-8.add +set spelllang=en + +set showmatch " -- emit 'beep' when no matching symbol, +set matchtime=0 " -- but don't jump to it. + +set timeoutlen=200 " -- short timeout for multi-key functions diff --git a/vim/rc.vim b/vim/rc.vim index a645606..ceedc75 100644 --- a/vim/rc.vim +++ b/vim/rc.vim @@ -1,86 +1,24 @@ " -- Environment Variables --------------------------------------- {{{ source $HOME/.my_vim_env "sets the following variables: -"$RC_DIR $VIM_DIR $WRYNVIMRC $WRYNBASH $MYBASHRC -" Load Vundle Plugins First -source $VIM_DIR/vundle.vim -" }}} +"$RC_DIR $VIM_DIR $WRYNVIMRC $WRYNBASH $MYBASHRC $WEBBROWSER -" -- General Settings -------------------------------------------- {{{ -set linebreak " automatically wraps text -set breakindent " indent for single-line wrap -set breakindentopt=shift:3 " indent amount for single-line wrap - -set formatoptions=lj -" l = prevents the breaking up of words -" j = remove comment leaders when joining lines - -let &t_co=256 " use 256-color - -set number " show line numbers -syntax on " detect syntax -set autoindent " match indentation with next line -set smartindent " match indentation with syntax - -set spellfile=$VIM_DIR/en.utf-8.add -set spelllang=en - -set showmatch " -- emit 'beep' when no matching symbol, -set matchtime=0 " -- but don't jump to it. - -set timeoutlen=200 " -- short timeout for multi-key functions -" }}} - -" -- File Formatting ------------------------------------- {{{ -augroup filetype_specific_formatting - autocmd! - autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab foldmethod=indent foldlevel=99 - autocmd FileType java setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=indent foldlevel=99 - autocmd FileType cs setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=indent foldlevel=99 - autocmd FileType html setlocal tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab foldmethod=indent foldlevel=99 - autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab foldmethod=indent foldlevel=99 - autocmd FileType vim setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=marker foldlevel=1 - autocmd FileType sh setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab foldmethod=indent foldlevel=99 - autocmd FileType lisp setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab foldmethod=manual foldlevel=99 - autocmd FileType markdown setlocal tabstop=2 noexpandtab foldmethod=indent foldlevel=99 spell -augroup end -" }}} - -" -- Key bindings ---------------------------------------- {{{ let mapleader = "\\" "let localmapleader = ',' -" -- VIMRC ------------------------------------------- {{{ -nnoremap ev :vsp $WRYNVIMRC -nnoremap sv :source $MYVIMRC -nnoremap eb :vsp $MYBASHRC -nnoremap emb :vsp $WRYNBASH -" }}} +" 1) Load Vundle first +source $VIM_DIR/vundle.vim -" -- Abbreviation Dictionary ------------------------- {{{ -iabbrev @@ wagner.wryn@gmail.com -iabbrev ssig -----------------------Wryn Wagnerwagner.wryn@gmail.com(720)557-5443----------------------- - -iabbrev psvm public static void main(String[] args) {} -" }}} - -" -- Pane/Window Navigation -------------------------- {{{ -" (SHIFT + DIRECTION) for tabs -nnoremap gt -nnoremap gT -" (CTRL + DIRECTION) for panes -nnoremap l -nnoremap h -nnoremap j -nnoremap k -" }}} -" (CTRL + n) for files -nnoremap :n -nnoremap :N - -" open (execute) file in chrome -nnoremap ec :!/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome %:p +" 2) Order insensitive plugins +source $VIM_DIR/global_sets.vim +source $VIM_DIR/file_formatting.vim +source $VIM_DIR/edit_rc.vim +source $VIM_DIR/abbreviations.vim +source $VIM_DIR/window_pane_navigation.vim +source $VIM_DIR/my_colors.vim +" 3) Order sensitive plugins +source $VIM_DIR/rd_formatting.vim " Must load after file_formatting " to execute macro on q nnoremap @q @@ -92,7 +30,7 @@ nnoremap Q !!$SHELL " \q for `q:` nnoremap q q: -" \t for rerun tests +" \t for rerun last 'test' command: nnoremap t q:?test " \f for fold @@ -108,8 +46,3 @@ nnoremap _ :m -2 " - (insert mode) set current word to upper-case inoremap viwUea - -" - My Plugins -source $VIM_DIR/rd_formatting.vim -source $VIM_DIR/my_colors.vim -" }}} diff --git a/vim/window_pane_navigation.vim b/vim/window_pane_navigation.vim new file mode 100644 index 0000000..f0770b3 --- /dev/null +++ b/vim/window_pane_navigation.vim @@ -0,0 +1,15 @@ +" -- Pane/Window Navigation -------------------------- {{{ +" (SHIFT + DIRECTION) for tabs +nnoremap gt +nnoremap gT + +" (CTRL + DIRECTION) for panes +nnoremap l +nnoremap h +nnoremap j +nnoremap k + +" (CTRL + n) for files +nnoremap :n +nnoremap :N +" }}}