Clean up vimrc

This commit is contained in:
Michael Campagnaro 2019-12-31 00:37:09 -05:00
parent 6de3bff84e
commit 00aca34e56
5 changed files with 178 additions and 246 deletions

View File

@ -9,3 +9,4 @@ Abolish kewyord keyword
Abolish indentit{y,ies} identit{y,ies} Abolish indentit{y,ies} identit{y,ies}
Abolish indetit{y,ies} identit{y,ies} Abolish indetit{y,ies} identit{y,ies}
Abolish constnat constant Abolish constnat constant
Abolish darw draw

View File

@ -1,6 +0,0 @@
if !exists(':GitGutter')
finish
endif
" Disable realtime updates.
autocmd! gitgutter CursorHold,CursorHoldI

View File

@ -21,6 +21,7 @@ let s:green = "409b1c"
let s:aqua = "00897b" let s:aqua = "00897b"
let s:blue = "3b5bb5" let s:blue = "3b5bb5"
let s:purple = "673ab7" let s:purple = "673ab7"
let s:black = "000000"
let s:window = "cfd8dc" let s:window = "cfd8dc"
let s:error_msg_background = s:background let s:error_msg_background = s:background
@ -290,7 +291,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("Type", s:blue, "", "none") call <SID>X("Type", s:blue, "", "none")
call <SID>X("Define", s:purple, "", "none") call <SID>X("Define", s:purple, "", "none")
call <SID>X("Include", s:blue, "", "") call <SID>X("Include", s:blue, "", "")
call <SID>X("Number", s:orange, "", "") call <SID>X("Number", s:black, "", "")
"call <SID>X("Ignore", "666666", "", "") "call <SID>X("Ignore", "666666", "", "")
" Custom TODO/NOTE colors " Custom TODO/NOTE colors
@ -345,7 +346,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("pythonDocstring", s:comment, "", "") call <SID>X("pythonDocstring", s:comment, "", "")
call <SID>X("pythonBuiltinObj", s:red, "", "") call <SID>X("pythonBuiltinObj", s:red, "", "")
call <SID>X("pythonBuiltinType", s:orange, "", "") call <SID>X("pythonBuiltinType", s:orange, "", "")
call <SID>X("pythonNumber", s:orange, "", "") call <SID>X("pythonNumber", s:black, "", "")
" Go Highlighting " Go Highlighting
@ -366,7 +367,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256
call <SID>X("javaScriptFunction", s:purple, "", "") call <SID>X("javaScriptFunction", s:purple, "", "")
call <SID>X("javaScriptConditional", s:purple, "", "") call <SID>X("javaScriptConditional", s:purple, "", "")
call <SID>X("javaScriptRepeat", s:purple, "", "") call <SID>X("javaScriptRepeat", s:purple, "", "")
call <SID>X("javaScriptNumber", s:orange, "", "") call <SID>X("javaScriptNumber", s:black, "", "")
call <SID>X("javaScriptMember", s:orange, "", "") call <SID>X("javaScriptMember", s:orange, "", "")
" HTML Highlighting " HTML Highlighting

View File

@ -1,5 +1,5 @@
---------------------------------------------- ----------------------------------------------
Michael Campagnaro's plan for <month> <day>, 2018 Michael Campagnaro's plan for <month> <day>, 2019
---------------------------------------------- ----------------------------------------------
DO DO

408
vimrc
View File

@ -1,7 +1,28 @@
" @fixme i'm now experiencing end of file history more often after the big
" changes to this file. Coincidence?
"
" Check out https://stackoverflow.com/a/34253629 to change the cursor to a
" @incomplete check for mappings in terminus to verify they don't override anything I used.
" block or whatever depending on the mode.
" @incomplete Move all leader definitions to the bottom, so that it's easier to see them. " @incomplete Move all leader definitions to the bottom, so that it's easier to see them.
" @incomplete Add setup steps (plugins, cache setup, search tool, etc). " @incomplete Add setup steps (plugins, cache setup, search tool, etc).
"Remove Menubar and Toolbar from gvim "###################################################################################################
"
" The config is chopped up into sections. These are the headings, which you
" can use to quickly jump to a particular section:
" #0. GLOBALS
" #1. PLUGINS
" #2. BASE CONFIG
" #3. PLUGIN CONFIGS
" #4. VISUALS
" #5. HELPER FUNCTIONS
" #6. PERSONAL
"
"###################################################################################################
" Remove Menubar and Toolbar from gvim
"set guioptions -=m "set guioptions -=m
"set guioptions -=T "set guioptions -=T
@ -16,10 +37,10 @@ let s:uname = system("echo -n \"$(uname)\"")
let s:vim_dir = $HOME . "/.vim" let s:vim_dir = $HOME . "/.vim"
function! IsWindows() function! IsWindows()
if s:uname =~ "mingw" if s:uname =~ "mingw"
return 1 return 1
endif endif
return 0 return 0
endfunction endfunction
let mapleader="," let mapleader=","
@ -27,7 +48,7 @@ let mapleader=","
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
" 0. GLOBALS "#0. GLOBALS
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
@ -37,13 +58,12 @@ let s:default_bg = 'dark'
let s:rainbow_theme = s:default_bg let s:rainbow_theme = s:default_bg
let g:quickfix_window_height = 16 " in rows let g:quickfix_window_height = 16 " in rows
"----------------------------------------------------------------------------------------- "---------------------------------------------------------------------------------------------------
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
" 1. PLUGINS "#1. PLUGINS
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
@ -54,140 +74,102 @@ call plug#begin('~/.vim/plugged')
" MISC " MISC
"//////////////////////////////////////////////////////////////// "////////////////////////////////////////////////////////////////
Plug 'bling/vim-airline' Plug 'bling/vim-airline' " Enhanced status/tabline.
Plug 'vim-scripts/AnsiEsc.vim' Plug 'embear/vim-localvimrc' " Add a .lvimrc to a folder to override .vimrc config.
Plug 'embear/vim-localvimrc' " Add a .lvimrc to a folder to override .vimrc config. Plug 'tpope/vim-obsession' " Continuously updated session files (tracks window positions, open folds, etc).
Plug 'tpope/vim-obsession' " Continuously updated session files Plug 'tpope/vim-fugitive' " Git wrapper (I particularly like :Gblame, which I've wrapped as :Blame)
Plug 'tpope/vim-fugitive' " Git wrapper Plug 'junegunn/goyo.vim' " Distraction-free mode with centered buffer.
Plug 'junegunn/goyo.vim' " Distraction-free mode with centered buffer Plug 'sir-pinecone/vim-ripgrep' " Fast grep-like search. Requires ripgrep; install Rust package: `cargo install ripgrep`.
Plug 'sir-pinecone/vim-ripgrep' " Wrapper around ripgrep (must intall ripgrep first; use Rust: cargo install ripgrep) Plug 'itchyny/vim-cursorword' " Underlines all instances of the symbol under the cursor.
Plug 'itchyny/vim-cursorword' " Underlines the word under the cursor Plug 'airblade/vim-gitgutter' " Displays a git diff in the vim gutter and allows staging/unstaging of hunks.
Plug 'airblade/vim-gitgutter' " See git diff in the gutter and stage/unstage hunks. Plug 'ctrlpvim/ctrlp.vim' " Fuzzy file, buffer, mru, tag, etc finder.
Plug 'ctrlpvim/ctrlp.vim' " Fuzzy file, buffer, mru, tag, etc finder Plug 'majutsushi/tagbar' " Display ctags in a window, ordered by scope.
Plug 'tommcdo/vim-lion' " For text alignment, use gl= and gL=
Plug 'tpope/tpope-vim-abolish' " Easily search for, substitute, and abbreviate multiple variants of a word. Add them to `vim/after/plugin/abolish.vim`
Plug 'vim-scripts/AnsiEsc.vim' " Ansi escape sequences concealed, but highlighted as specified.
Plug 'tommcdo/vim-kangaroo' " Maintain a manually-defined jump stack. Set with zp or <leader>a and pop with zP or <leader>aa.
Plug 'mh21/errormarker.vim' " Build error highlighting (requires skywind3000/asyncrun.vim).
Plug 'skywind3000/asyncrun.vim' " Async commands.
Plug 'nelstrom/vim-qargs' " For the GlobalReplaceIt function (i.e. search and replace).
" @fixme Disable the file reloading. Plug 'wincent/terminus' " Enhanced terminal integration for Vim (namely iTerm). Changes the cursor depending on the mode; enhanced pasting; file reloading on external changes.
if IsWindows() if IsWindows()
Plug 'suxpert/vimcaps' " Disable capslock (useful if the OS isn't configured to do so) Plug 'suxpert/vimcaps' " Disable capslock (useful if the OS isn't configured to do so).
else else
Plug 'Shougo/vimproc.vim', {'do' : 'make'} " Fuzzy search
Plug 'itchyny/dictionary.vim' " A way to query dictionary.com with :Dictionary " @incomplete Test out ctrlp for non-Windows setup.
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" Fuzzy search " @fixme Doesn't do anything under Windows...
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'ervandew/supertab' " Improved autocompletion.
Plug 'junegunn/fzf.vim'
endif endif
Plug 'majutsushi/tagbar'
Plug 'jeetsukumaran/vim-filesearch'
Plug 'rking/ag.vim'
Plug 'nelstrom/vim-qargs' " For search and replace
Plug 'tommcdo/vim-lion' " For text alignment, use gl= and gL=
" Easily search for, substitute, and abbreviate multiple variants of a word
Plug 'tpope/tpope-vim-abolish'
" Maintain a manually-defined jump stack. Set with zp and pop with zP
Plug 'tommcdo/vim-kangaroo'
" Async commands + build error highlighting
Plug 'skywind3000/asyncrun.vim'
Plug 'mh21/errormarker.vim'
"/////////////////// "///////////////////
" MAYBE SOME DAY " MAYBE SOME DAY
"/////////////////// "///////////////////
"Plug 'shougo/unite.vim' " Create user interfaces. Not currently needed. "Plug 'shougo/unite.vim' " Create user interfaces. Not currently needed.
"Plug 'itchyny/vim-winfix' " Fix the focus and the size of windows in Vim "Plug 'itchyny/vim-winfix' " Fix the focus and the size of windows in Vim.
"Plug 'scrooloose/nerdcommenter' " Better commenting "Plug 'scrooloose/nerdcommenter' " Better commenting.
"///////////////////
" DISABLED
"///////////////////
" I don't think I need this anymore...
"Plug 'craigemery/vim-autotag' " Automatically discover and 'properly' update ctags files on save
" Doesn't do anything on my Windows desktop...
"Plug 'ervandew/supertab' " For autocompletion
"//////////////////////////////////////////////////////////////// "////////////////////////////////////////////////////////////////
" COLORS " COLORS
"//////////////////////////////////////////////////////////////// "////////////////////////////////////////////////////////////////
Plug 'godlygeek/csapprox' " Try to make gvim themes look decent in Windows Plug 'sir-pinecone/rainbow' " Rainbow parens.
Plug 'godlygeek/csapprox' " Try to make gvim themes look decent in Windows
Plug 'sir-pinecone/rainbow' "Plug 'flazz/vim-colorschemes' " @warning: Has a lot of themes, but they break the other themes listed below
" WARNING: Has a lot of themes, but they break the other themes listed below
"Plug 'flazz/vim-colorschemes'
Plug 'elixir-lang/vim-elixir' Plug 'elixir-lang/vim-elixir'
Plug 'vim-airline/vim-airline-themes' Plug 'vim-airline/vim-airline-themes'
" Light Themes " Light Themes
Plug 'raggi/vim-color-raggi' " No Win support, unless using gvim Plug 'raggi/vim-color-raggi' " @note No Win support, unless using gvim.
Plug 'LanFly/vim-colors' " No Win support, unless using gvim Plug 'LanFly/vim-colors' " @note No Win support, unless using gvim.
" Dark Themes " Dark Themes
Plug 'rhysd/vim-color-spring-night' " No Win support, unless using gvim Plug 'rhysd/vim-color-spring-night' " @note No Win support, unless using gvim.
Plug 'nanotech/jellybeans.vim' Plug 'nanotech/jellybeans.vim'
Plug 'zcodes/vim-colors-basic' Plug 'zcodes/vim-colors-basic'
" Hybrid Themes " Hybrid Themes
Plug 'sickill/vim-monokai' Plug 'sickill/vim-monokai'
Plug 'chmllr/elrodeo-vim-colorscheme' " A little dark on Windows, term Plug 'chmllr/elrodeo-vim-colorscheme' " A little dark on Windows, term
Plug 'reedes/vim-colors-pencil' " High-contrast Plug 'reedes/vim-colors-pencil' " High-contrast
" Seabird themes " Seabird themes
" High contrast: seagull (light), petrel (dark) " High contrast: seagull (light), petrel (dark)
" Low contrast: greygull (light), stormpetrel (dark) " Low contrast: greygull (light), stormpetrel (dark)
Plug 'nightsense/seabird' " No Win support, unless using gvim Plug 'nightsense/seabird' " @note No Win support, unless using gvim.
"//////////////////////////////
" SYNTAX HIGHLIGHTING
"//////////////////////////////
"//////////////////////////////////////////////////////////////// Plug 'tpope/vim-markdown' " Markdown
" CLOJURE Plug 'octol/vim-cpp-enhanced-highlight' " C/C++
"//////////////////////////////////////////////////////////////// Plug 'vim-ruby/vim-ruby' " Ruby
" Temporarily disabled since I'm not doing any Clojure work atm. Plug 'fatih/vim-go' " Go
Plug 'rust-lang/rust.vim' " Rust
Plug 'peterhoeg/vim-qml' " QML
Plug 'jdonaldson/vaxe' " Haxe
" Clojure -- Disabled since I'm not doing any Clojure work atm.
"Plug 'tpope/vim-classpath' " For Java "Plug 'tpope/vim-classpath' " For Java
"Plug 'guns/vim-clojure-highlight' "Plug 'guns/vim-clojure-highlight'
"Plug 'guns/vim-clojure-static' "Plug 'guns/vim-clojure-static'
"Plug 'tpope/vim-fireplace', { 'for': 'clojure' } "Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
"//////////////////////////////
"////////////////////////////////////////////////////////////////
" OTHER LANGUAGES
"////////////////////////////////////////////////////////////////
" Rust
Plug 'rust-lang/rust.vim'
" Ruby
Plug 'vim-ruby/vim-ruby'
" Go
Plug 'fatih/vim-go'
" QML
Plug 'peterhoeg/vim-qml'
" Markdown
Plug 'tpope/vim-markdown'
"Plug 'vim-pandoc/vim-pandoc-syntax'
" C++
Plug 'octol/vim-cpp-enhanced-highlight'
" Haxe
Plug 'jdonaldson/vaxe'
call plug#end() call plug#end()
filetype plugin indent on filetype plugin indent on
"---------------------------------------------------------------------------------------------------
"-----------------------------------------------------------------------------------------
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
" 2. BASE CONFIG "#2. BASE CONFIG
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
@ -196,7 +178,6 @@ filetype plugin indent on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC EDITING CONFIGURATION " BASIC EDITING CONFIGURATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" allow unsaved background buffers and remember marks/undo for them
set hidden set hidden
set history=10000 set history=10000
set expandtab set expandtab
@ -205,24 +186,23 @@ set shiftwidth=4
set softtabstop=4 set softtabstop=4
set autoindent set autoindent
set laststatus=2 set laststatus=2
set showcmd " display incomplete commands set showcmd " Display incomplete commands.
set showmatch set showmatch
set incsearch " Highlight matches as you type set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches set hlsearch " Highlight matches.
set dictionary+=/usr/share/dict/words set dictionary+=/usr/share/dict/words
"set clipboard=unnamed " yank and paste with the system clipboard "set clipboard=unnamed " Yank and paste with the system clipboard.
set number set number
" make searches case-sensitive only if they contain upper-case characters set ignorecase smartcase " Make searches case-sensitive only if they contain upper-case characters.
set ignorecase smartcase set visualbell " No bell sounds.
set visualbell " No bell sounds
set ttyfast set ttyfast
" highlight current line
set cmdheight=2 set cmdheight=2
set switchbuf=useopen,split set switchbuf=useopen,split
set numberwidth=5 set numberwidth=5
set showtabline=2 set showtabline=2
set winwidth=79 set winwidth=79
" @warning: This must come AFTER `set ignorecase smartcase` otherwise vim spews out a ton of errors. No idea why!
if IsWindows() if IsWindows()
" Just assume we don't have a zsh shell " Just assume we don't have a zsh shell
set shell=bash set shell=bash
@ -230,62 +210,47 @@ else
set shell=zsh set shell=zsh
endif endif
" Prevent Vim from clobbering the scrollback buffer. See set t_ti= t_te= " Prevent Vim from clobbering the scrollback buffer. See http://www.shallowsky.com/linux/noaltscreen.html
" http://www.shallowsky.com/linux/noaltscreen.html set scrolloff=3 " keep more context when scrolling off the end of a buffer
set t_ti= t_te=
" keep more context when scrolling off the end of a buffer
set scrolloff=3
set cursorline set cursorline
set cursorcolumn set cursorcolumn
" Store temporary files in a central spot " Store temporary files in a central spot. Make sure these directories exist on disk.
set backup set backup
set backupcopy=yes set backupcopy=yes
set directory=X://tmp//vim// " For swap files set directory=X://tmp//vim// " For swap files.
set backupdir=X://tmp//vim// set backupdir=X://tmp//vim//
:au BufWritePre * let &bex = '.' . strftime("%Y-%m-%d-%T") . '.bak' :au BufWritePre * let &bex = '.' . strftime("%Y-%m-%d-%T") . '.bak'
set writebackup set writebackup
" allow backspacing over everything in insert mode set backspace=indent,eol,start " Allow backspacing over everything in insert mode.
set backspace=indent,eol,start
set complete+=kspell " Spell checking autocomplete. set complete+=kspell " Spell checking autocomplete.
set complete-=i " Don't scan all included files since it's really slow. set complete-=i " Don't scan all included files since it's really slow.
syntax on " Enable highlighting for syntax
" Enable highlighting for syntax
syntax on
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
" use emacs-style tab completion when selecting files, etc
set wildmenu set wildmenu
set wildmode=longest,list,full set wildmode=longest,list,full
set wildignore+=*/log/*,*.so,*.swp,*.zip,*/rdoc/* set wildignore+=*/log/*,*.so,*.swp,*.zip,*/rdoc/*
let &colorcolumn=s:max_line_length let &colorcolumn=s:max_line_length
" Requires ripgrep to be installed. set grepprg=rg\ --vimgrep " Requires ripgrep to be installed.
set grepprg=rg\ --vimgrep
" Show trailing whitespace. set list listchars=tab:»·,trail" Show trailing whitespace.
set list listchars=tab:»·,trail
" Adding this since the esc remap on the 'i' key had a long delay when pressed. set timeoutlen=300 ttimeoutlen=0 " Adding this since the esc remap on the 'i' key had a long delay when pressed.
set timeoutlen=300 ttimeoutlen=0
" Allow undo when doing back into a closed file " @new might be broken:
set undolevels=1000 " set updatetime=100 " I lowered this to make git-gutter updates faster.
set undolevels=1000 " Allow undo when going back into a closed file
set undoreload=10000 set undoreload=10000
" Keep undo history across sessions by storing it in a file " Keep undo history across sessions by storing it in a file.
if has('persistent_undo') if has('persistent_undo')
let undo_dir = expand(s:vim_dir . '/undo') let undo_dir = expand(s:vim_dir . '/undo')
" Create dirs " Create directory.
if IsWindows() let mkdir = 'mkdir -p '
let mkdir = 'mkdir '
else
let mkdir = 'mkdir -p '
endif
:silent call system(mkdir . s:vim_dir) :silent call system(mkdir . s:vim_dir)
:silent call system(mkdir . undo_dir) :silent call system(mkdir . undo_dir)
let &undodir = undo_dir let &undodir = undo_dir
@ -295,13 +260,13 @@ endif
" Fix vim's background colour erase - http://snk.tuxfamily.org/log/vim-256color-bce.html " Fix vim's background colour erase - http://snk.tuxfamily.org/log/vim-256color-bce.html
if &term =~ '256color' if &term =~ '256color'
" Disable Background Color Erase (BCE) so that color schemes " Disable Background Color Erase (BCE) so that color schemes
" work properly when Vim is used inside tmux and GNU screen. " work properly when Vim is used inside tmux and GNU screen.
" See also http://snk.tuxfamily.org/log/vim-256color-bce.html " See also http://snk.tuxfamily.org/log/vim-256color-bce.html
set t_ut= set t_ut=
endif endif
" Disable arrow keys " Disable arrow keys.
map <up> <nop> map <up> <nop>
map <down> <nop> map <down> <nop>
map <left> <nop> map <left> <nop>
@ -311,42 +276,41 @@ imap <down> <nop>
imap <left> <nop> imap <left> <nop>
imap <right> <nop> imap <right> <nop>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM AUTOCMDS " CUSTOM AUTOCMDS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup campoCmds augroup campoCmds
" Clear all autocmds in the group " Clear all autocmds in the group.
autocmd! autocmd!
" Automatically wrap at N characters " Automatically wrap at N characters.
autocmd FileType gitcommit setlocal colorcolumn=72 autocmd FileType gitcommit setlocal colorcolumn=72
autocmd BufRead,BufNewFile *.{md,txt,plan} execute "setlocal textwidth=" .s:max_line_length autocmd BufRead,BufNewFile *.{md,txt,plan} execute "setlocal textwidth=" .s:max_line_length
" Spell checking " Spell checking.
autocmd FileType gitcommit,markdown,text setlocal spell autocmd FileType gitcommit,markdown,text setlocal spell
" Jump to last cursor position unless it's invalid or in an event handler " Jump to last cursor position unless it's invalid or in an event handler.
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" Language identation " Language identation.
autocmd FileType ruby,haml,eruby,yaml,html,javascript,rust,go set ai sw=2 sts=2 et autocmd FileType ruby,haml,eruby,yaml,html,javascript,rust,go set ai sw=2 sts=2 et
autocmd FileType python,qml set sw=4 sts=4 et autocmd FileType python,qml set sw=4 sts=4 et
" Indent p tags " Indent HTML <p> tags.
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
" Properly indent schemes (scheme, racket, etc) " Properly indent schemes (scheme, racket, etc).
autocmd bufread,bufnewfile *.{lisp,scm,rkt} setlocal equalprg=scmindent.rkt autocmd bufread,bufnewfile *.{lisp,scm,rkt} setlocal equalprg=scmindent.rkt
" Auto reload VIM when settings changed " Auto reload VIM when settings changed.
autocmd BufWritePost .vimrc so $MYVIMRC autocmd BufWritePost .vimrc so $MYVIMRC
autocmd BufWritePost *.vim so $MYVIMRC autocmd BufWritePost *.vim so $MYVIMRC
autocmd BufWritePost vimrc.symlink so $MYVIMRC autocmd BufWritePost vimrc.symlink so $MYVIMRC
" Generate ctags " Generate ctags on save.
" Include local variables for c languages. " Also Include local variables for C-like languages.
au BufWritePost *.py,*.c,*.cpp,*.h silent! !eval 'ctags --c-types=+l --c++-types=+l --exclude=vendor -R -o newtags; mv newtags tags' & au BufWritePost *.py,*.c,*.cpp,*.h silent! !eval 'ctags --c-types=+l --c++-types=+l --exclude=vendor -R -o newtags; mv newtags tags' &
" Remove trailing whitespace on save all files. " Remove trailing whitespace on save all files.
@ -362,11 +326,11 @@ augroup campoCmds
" FILE TEMPLATES " FILE TEMPLATES
"//////////////////////////////////////////////////////////////// "////////////////////////////////////////////////////////////////
" Shell script template " Shell script template.
autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh
autocmd BufNewFile *.plan 0r ~/.vim/templates/skeleton.plan autocmd BufNewFile *.plan 0r ~/.vim/templates/skeleton.plan
" C/C++ template " C/C++ template.
autocmd bufnewfile *.{c,cc,cpp,h,hpp} 0r ~/.vim/templates/c_header_notice autocmd bufnewfile *.{c,cc,cpp,h,hpp} 0r ~/.vim/templates/c_header_notice
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/File:.*/s//File: " .expand("%") autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/File:.*/s//File: " .expand("%")
autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/Creation Date:.*/s//Creation Date: " .strftime("%Y-%m-%d") autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/Creation Date:.*/s//Creation Date: " .strftime("%Y-%m-%d")
@ -386,21 +350,23 @@ augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC KEY MAPS " MISC KEY MAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mapping ESC in insert mode and command mode to double i " Mapping ESC in insert mode and command mode to double i.
imap jj <Esc> imap jj <Esc>
"cmap ii <Esc> "cmap ii <Esc>
" suspend process " Suspend vim process and return to the shell. Can return to vim with `fg`.
nmap <leader>z <c-z> nmap <leader>z <c-z>
" Quickly edit/reload the vimrc file " Open the vimrc file for editing / reload vimrc file.
nmap <silent> <leader>ev :vsp $MYVIMRC<cr> nmap <silent> <leader>ev :vsp $MYVIMRC<cr>
nmap <silent> <leader>rv :so $MYVIMRC<cr> nmap <silent> <leader>rv :so $MYVIMRC<cr>
" Easy way to open a file in the directory of the current file " Type %/ in the command bar to have it replaced with the current buffer's
" path if the file is on disk. One thing I noticed is that you have to type
" the full %/ quickly otherwise it won't replace it.
:cmap %/ %:p:h/ :cmap %/ %:p:h/
" remap saving and quiting " Remap saving and quiting.
nmap <leader>w :w!<cr> nmap <leader>w :w!<cr>
nmap <leader>q :q<cr> nmap <leader>q :q<cr>
nmap <leader>qq :q!<cr> nmap <leader>qq :q!<cr>
@ -412,17 +378,17 @@ nmap <leader>x :x<cr>
:ca W w! :ca W w!
:ca Q q :ca Q q
" lowercase the e (have a habit of making it uppercase) " Lowercase the e (have a habit of making it uppercase).
:ca E e :ca E e
command! Q q " Bind :Q to :q command! Q q " Bind :Q to :q
command! Qall qall command! Qall qall
command! Qa qall command! Qa qall
" Disable Ex mode " Disable Ex mode.
map Q <Nop> map Q <Nop>
" Open a terminal within vim. Use `exit` to close it.
if exists(':terminal') if exists(':terminal')
" Terminal mapping
map <leader>t :terminal<cr> map <leader>t :terminal<cr>
tnoremap <leader>e <C-\><C-n> tnoremap <leader>e <C-\><C-n>
tnoremap <A-h> <C-\><C-n><C-w>h tnoremap <A-h> <C-\><C-n><C-w>h
@ -435,14 +401,14 @@ if exists(':terminal')
nnoremap <A-l> <C-w>l nnoremap <A-l> <C-w>l
endif endif
" Map ctrl-movement keys to window switching " Jump to other buffers.
map <c-k> <c-w><Up> map <c-k> <c-w><Up>
map <c-j> <c-w><Down> map <c-j> <c-w><Down>
map <c-l> <c-w><Right> map <c-l> <c-w><Right>
map <c-h> <c-w><Left> map <c-h> <c-w><Left>
" Make it easier to jump around the command line. The default behaviour is " Make it easier to jump around the command line. The default behaviour is
" using the arrow keys with or without shift " using the arrow keys with or without shift.
:cnoremap <C-J> <S-Left> :cnoremap <C-J> <S-Left>
:cnoremap <C-K> <S-Right> :cnoremap <C-K> <S-Right>
@ -451,33 +417,33 @@ map <c-h> <c-w><Left>
map <leader>m :vsplit<cr> map <leader>m :vsplit<cr>
map <leader>mm :split<cr> map <leader>mm :split<cr>
" Delete a word forward and backward " Forward delete and replace a word.
map <leader>a daw
map <leader>d ciw map <leader>d ciw
" Map paste and nonumber " Map paste and nonumber.
map <leader>p :set paste! paste?<cr> map <leader>p :set paste! paste?<cr>
map <leader>o :set number! number?<cr> map <leader>o :set number! number?<cr>
" Spell checking " Show spell checking.
" @note: you can add new entries to the dict by moving the cursor over the
" word and pressing `zg`.
map <leader>j :exec &spell==&spell? "se spell! spelllang=en_us" : "se spell!"<cr> map <leader>j :exec &spell==&spell? "se spell! spelllang=en_us" : "se spell!"<cr>
map <leader>= z= map <leader>= z=
" NOTE: you can add a new word to the dict with `zg`
" Clear the search buffer (highlighting) when hitting return " Clear the search buffer (highlighting) when hitting return.
function! MapCR() function! MapCR()
nnoremap <cr> :nohlsearch<cr> nnoremap <cr> :nohlsearch<cr>
endfunction endfunction
call MapCR() call MapCR()
nnoremap <leader><leader> <c-^> nnoremap <leader><leader> <c-^>
" Replace currently selected text with default register without yanking it " Replace currently selected text with default register without yanking it.
vnoremap p "_dP vnoremap p "_dP
" Use Marked.app to preview Markdown files... " Use Marked.app to preview Markdown files.
nnoremap <leader>pp :silent !open -a Marked.app '%:p'<cr> nnoremap <leader>pp :silent !open -a Marked.app '%:p'<cr>
" Switch between C++ source and header files " Switch between C++ source and header files.
map <leader>v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR> map <leader>v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
"map <leader>vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR> "map <leader>vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>
"map <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR> "map <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR>
@ -524,13 +490,13 @@ inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n> inoremap <s-tab> <c-n>
"----------------------------------------------------------------------------------------- "---------------------------------------------------------------------------------------------------
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
" 3. PLUGIN CONFIGS "#3. PLUGIN CONFIGS
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
@ -547,17 +513,22 @@ let g:localvimrc_ask = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap <F12> :TagbarToggle<cr> noremap <F12> :TagbarToggle<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" KANGAROO
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <leader>a zp
nmap <leader>aa zP
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" GITGUTTER " GITGUTTER
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:gitgutter_enabled = 0 let g:gitgutter_enabled = 1
let g:gitgutter_highlight_lines = 1 let g:gitgutter_highlight_lines = 0
nmap <leader>ha <Plug>GitGutterStageHunk nmap <leader>ha <Plug>GitGutterStageHunk
nmap <leader>hh :GitGutterToggle nmap <leader>hh :GitGutterToggle<cr>
nmap [h <Plug>GitGutterNextHunk nmap [h <Plug>GitGutterNextHunk
nmap ]h <Plug>GitGutterPrevHunk nmap ]h <Plug>GitGutterPrevHunk
" Run on file save. Realtime update is disabled in after/plugins/gitgutter.vim autocmd BufWritePost * GitGutter " Update marks on save
autocmd BufWritePost * GitGutter
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SYNTASTIC " SYNTASTIC
@ -686,13 +657,20 @@ endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tags+=tags;$HOME set tags+=tags;$HOME
"----------------------------------------------------------------------------------------- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TERMINUS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:TerminusMouse=0 " Disable mouse stuff.
let g:TerminusFocusReporting=0 " Disable auto file reloading on external changes.
"---------------------------------------------------------------------------------------------------
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
" 4. VISUALS "#4. VISUALS
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
@ -825,12 +803,12 @@ augroup vimrc_annotated_notes
\ containedin=.*Comment,vimCommentTitle \ containedin=.*Comment,vimCommentTitle
augroup END augroup END
"----------------------------------------------------------------------------------------- "---------------------------------------------------------------------------------------------------
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
" 5. HELPER FUNCTIONS "#5. HELPER FUNCTIONS
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
@ -977,14 +955,10 @@ function! Search(case_sensitive)
endif endif
if IsWindows() if IsWindows()
"@deprecated: Fsgrep is slow...."
"exec 'Fsgrep "' . term . '"'
exec 'Rg ' . rg_args . ' "' . term . '"' exec 'Rg ' . rg_args . ' "' . term . '"'
else else
"@deprecated: ripgrep is faster than Ag. " @incomplete Test out ripgrep on non-Windows OS
"exec 'Ag "' . term . '"' echo "Not implemented"
" @incomplete pass case sensitivity toggle to Find.
execute 'Find ' . term
endif endif
endfunction endfunction
map <leader>s :call Search(0)<cr> map <leader>s :call Search(0)<cr>
@ -996,44 +970,6 @@ map <leader>ss :call Search(1)<cr>
nnoremap <expr> o (&buftype is# "quickfix" ? "<CR>\|:lopen<CR>" : "o") nnoremap <expr> o (&buftype is# "quickfix" ? "<CR>\|:lopen<CR>" : "o")
nnoremap <expr> p (&buftype is# "quickfix" ? "<CR>\|:copen<CR>" : "p") nnoremap <expr> p (&buftype is# "quickfix" ? "<CR>\|:copen<CR>" : "p")
"////////////////////////////////////////////////////////////////
" FILESEARCH PLUGIN
"////////////////////////////////////////////////////////////////
let g:filesearch_viewport_split_policy = "B"
let g:filesearch_split_size = 10
let g:filesearch_autodismiss_on_select = 0
"////////////////////////////////////////////////////////////////
" SELECTA -- find files with fuzzy-search
"////////////////////////////////////////////////////////////////
" Run a given vim command on the results of fuzzy selecting from a given shell
" command. See usage below.
function! SelectaCommand(choice_command, selecta_args, vim_command)
if IsWindows()
let l:term = input('File name: ')
exec 'Fsfind "' . l:term . '"'
else
try
let l:selection = system(a:choice_command . " | selecta " . a:selecta_args)
catch /Vim:Interrupt/
" Swallow the ^C so that the redraw below happens; otherwise there will be
" leftovers from selecta on the screen
redraw!
return
endtry
redraw!
exec a:vim_command . " " . l:selection
endif
endfunction
" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
" DISABLED (2019-03) because I'm now using ctrl-p for fuzzy searching.
" nnoremap <leader>f :call SelectaCommand("find * -type f ! -path 'resources/public/js/*' ! -path 'resources/.sass-cache/*' ! -path 'target/*'", "", ":e")<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RENAME CURRENT FILE " RENAME CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@ -1049,13 +985,13 @@ endfunction
map <leader>n :call RenameFile()<cr> map <leader>n :call RenameFile()<cr>
"----------------------------------------------------------------------------------------- "---------------------------------------------------------------------------------------------------
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
" 6. PERSONAL "#6. PERSONAL
"################################################################ "################################################################
"################################################################ "################################################################
"################################################################ "################################################################
@ -1064,6 +1000,6 @@ map <leader>n :call RenameFile()<cr>
" FILE MAPPINGS " FILE MAPPINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Notes and other helpers " Notes and other helpers
map <leader>pn :sp ~/.dev-scratchpad<cr> map <leader>pn :sp ~/.dev-scratchpad.md<cr>
"let g:autotagStopAt = "$HOME" "let g:autotagStopAt = "$HOME"