Created
January 2, 2015 22:21
-
-
Save nfarrar/9f7c7b3bd52857584879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"============================================================================= | |
" FILE: vimrc | |
" AUTHOR: Nathan Farrar <[email protected]> | |
" License: MIT license {{{ | |
" Permission is hereby granted, free of charge, to any person obtaining | |
" a copy of this software and associated documentation files (the | |
" 'Software'), to deal in the Software without restriction, including | |
" without limitation the rights to use, copy, modify, merge, publish, | |
" distribute, sublicense, and/or sell copies of the Software, and to | |
" permit persons to whom the Software is furnished to do so, subject to | |
" the following conditions: | |
" | |
" The above copyright notice and this permission notice shall be included | |
" in all copies or substantial portions of the Software. | |
" | |
" THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
" }}} | |
"============================================================================= | |
" Documentation {{{1 | |
" About {{{2 | |
" After dabbling with vim for years, I finally took the plunge and switched to | |
" it (exclusively). I've spent countless hours learning vim's essential | |
" features and scripting engine to configure vim to work exactly the way I want. | |
" | |
" For years, I ripped off fragments of other people's configuration files and | |
" globbed them together into my own frankenstein. This was impossible to | |
" troubleshoot and force it to work how I wanted, because I didn't *really* | |
" understand exactly what was happening. I have painstakenly written | |
" every-single-line in this configuration to ensure that I explicitly know how | |
" every-single-line works. Excluding a few plugins, I understand exactly how | |
" *every* line in my vimrc works. | |
" | |
" I've used pathogen, vundle, neobundle and now vim-plug as my plugin manager. | |
" They're all great in their own ways. I use vim-plug now because it's a nice | |
" compromise between the minimalstic approach of pathogen & vundle but not as | |
" overwhelming as neobundle. It has asynchronous support built-in without | |
" the need for an additional plugin (vimproc/dispatch) and provides hooks for | |
" installing & compiling external dependencies (which allows me to fully | |
" automate the installation by just dropping the vimrc into place). | |
" | |
" My vimrc is monolothic in design rather than the typically favored modular | |
" approach. I favor this, because I can drop the entire setup into place by | |
" copying a single file. I also find it much easier to debug - but this is | |
" probably just due to a lack of experience with vim. | |
" | |
" I've added a lot of documentation to my vimrc while learning about various | |
" things myself at one point, this was close to 4,000 lines, which was far too | |
" much - so much of that was stripped out. I've tried to leave essential | |
" documentation in place and added references where necessary to point others to | |
" resources that I think may be helpful. I've also found that vim's help files | |
" are far more robust than I initially realized and most of what I was looking | |
" for was already there, I just needed to know how to use the help files | |
" effectively. | |
" Learning Vim {{{2 | |
" I've included some of my favorite vim resources in this preamble as | |
" a reference for others that may stumble across this configuration. | |
" | |
" - Derek Wyatt's Video Series http://derekwyatt.org/vim/tutorials/ | |
" - Vimcasts http://vimcasts.org/episodes/archive/ | |
" - Learn Vimscript the Hard Way http://goo.gl/2Z4i6F | |
" - LearnVimL https://github.com/dahu/LearnVimL | |
" | |
" - Vimcasts - On Sharpening the Saw http://goo.gl/g1AO4x | |
" - The infamous 'Grok Vi' Post http://goo.gl/DUcS2k | |
" - 7 habits of effective text editing http://goo.gl/6mwx | |
" - Learning Vim in 2014: The Basics http://goo.gl/wFswhM | |
" - Learning Vim in 2014: Vim Language http://goo.gl/YN0qnz | |
" - Vim Text Objects: Definitive Guide http://goo.gl/b4Q5u | |
" - Habit breaking, habit making http://goo.gl/r409l | |
" - A Vim Tutorial and Primer http://goo.gl/xIFz8 | |
" - Operator, The True Power of Vim http://goo.gl/m9tpP | |
" | |
" - How I boosted my Vim http://goo.gl/S92T | |
" - A Veteran's .vimrc http://goo.gl/PZ5fFO | |
" | |
" - vimrcfu.com http://vimrcfu.com/ | |
" - vimgolf.com http://vimgolf.com/ | |
" - usevim.com http://usevim.com/ | |
" - bestofvim.com http://www.bestofvim.com/ | |
" - /r/vim http://www.reddit.com/r/vim | |
" - /r/vimplugins http://www.reddit.com/r/vimplugins | |
" - @vimtips http://https://twitter.com/vimtips/ | |
" - @vimlinks http://twitter.com/VimLinks | |
" - @vimgolf http://twitter.com/vimgolf | |
" | |
" - vimcolors.com http://vimcolors.com/ | |
" - vimawesome http://try.nodebb.com/ | |
" - vimpusher http://www.vimpusher.com/ | |
" - vim-scripts.org http://vim-scripts.org/ | |
" - vim-bootstrap http://vim-bootstrap.com/ | |
" | |
" | |
" - vi-improved.org/vimrc http://goo.gl/zDmJXe | |
" - amix.dk/vimrc http://goo.gl/ClPhPX | |
" - ncrowell/vimrc http://goo.gl/HtR5DZ | |
" - timss/vimrc http://goo.gl/gHU8r7 | |
" - sjl/vimrc http://goo.gl/bxARLY | |
" - vdboor/vimrc.local http://goo.gl/9ljtO9 | |
" - gradel/vim-config http://goo.gl/Z091Aa | |
" - ATNI/vimpire http://goo.gl/cUvRnL | |
" Todo {{{2 | |
" | |
" - Cursor position & folds are not always restored correctly (especially when | |
" working with help documents) - this may be some kind of 'competing' between | |
" restore_views.vim & viminfo settings. Not sure. | |
" | |
" - Autocmd that maximizes help window is no good with multiple windows. figure | |
" out a way to save and restore the current window layout. | |
" | |
" - How to run current bash file from vim? | |
" | |
" - How to run current python file in vim? | |
" | |
" - More work with syntax highlighting and formating of python files. | |
" | |
" - I hate how relative numbers resets itself everytime you activate a buffer. | |
" Replace this with my own functions. | |
" | |
" - If a session is opened with startify and I switch to another session, | |
" the current session's buffers are all deleted (and the session is ruined). | |
" The new session is opened, but vim doesn't change to it's directory. | |
" | |
" - Prevent utl from pausing screen when opening hyperlinks. | |
" | |
" - Minimal configuration for vim-tiny & vim-small. | |
" | |
" - More robust encoding & terminalencoding checks & handling. | |
" Notes {{{2 | |
" - https://github.com/disassembler/vim | |
" - https://github.com/FrankyMartz/dotfiles | |
" https://stackoverflow.com/questions/18948491/running-python-code-in-vim | |
" https://stackoverflow.com/questions/953398/how-to-execute-file-im-editing-in-vim | |
" https://code.google.com/p/conque/ | |
" Review These: | |
" http://connermcd.com/ | |
" https://www.youtube.com/watch?v=HJ93UYeaoww | |
" https://www.youtube.com/watch?v=wh_WGWii7UE | |
" http://vim.sourceforge.net/scripts/script.php?script_id=3931 | |
" http://www.vim.org/scripts/script.php?script_id=365 | |
" Bookmarks: | |
" How To Add Bookmarks http://goo.gl/g3g8k | |
" Dotfiles: | |
" - Use ViM as PAGER http://goo.gl/ubXsf | |
" - farseer90718/dotfiles http://goo.gl/ol5sP9 | |
" - holman/dotfiles http://goo.gl/QwFQn | |
" Markdown: | |
" - https://vim-voom.github.io/ | |
" - https://github.com/vim-pandoc/vim-pandoc | |
" - https://github.com/vim-pandoc/vim-pandoc-syntax | |
" - http://naperwrimo.org/wiki/index.php?title=Vim_for_Writers | |
" Terminal: | |
" Right now I hardcode the terminal & encoding settings. Do this a little more | |
" robustly so we vim works out of the box on minimally or poorly configured | |
" systems. | |
" - Detect non-Unicode Xterms http://goo.gl/JkxbtZ | |
" - Graceful handling when $LANG == '' | |
" 'set langmenu=en' | |
" source $VIMRUNTIME/delmenu.vim | |
" source $VIMRUNTIME/menu.vim | |
" Ag: | |
" github:ggreer/the_silver_searcher http://goo.gl/4jrDRS | |
" github:mileszs/ack.vim http://goo.gl/jqrPtg | |
" Faster Grepping in Vim http://goo.gl/ncMD15 | |
" Using the silver searcher with Vim http://goo.gl/bqUJRH | |
" Use ag in ctrlp + vim http://goo.gl/Kpj6x5 | |
" Tmux: | |
" - vim-tmux-navigator http://goo.gl/VRST1J | |
" - tslime http://goo.gl/GvNSL7 | |
" - Vim & tmux - beyond basics (vimeo) http://goo.gl/rAoUh9 | |
" - vim + tmux: A Perfect Match http://goo.gl/yBM5u1 | |
" - Run specs in tmux via Tslime http://goo.gl/dVQDZC | |
" - Copy & Paste on OSX with tmux http://goo.gl/IeF2WQ | |
" Vimtiny: | |
" Vimrc for vim-tiny http://goo.gl/dFN94e | |
" What features does vim-tiny have? http://goo.gl/0vLCNV | |
" Vim-tiny configuration http://goo.gl/psWDwQ | |
" Unsorted: | |
" - http://usevim.com/2012/05/18/vim101-visual-mode-2/ | |
" - http://mkrmr.wordpress.com/2010/05/14/vim-tip-visual-block-editing/ | |
" - http://vimcasts.org/episodes/aligning-text-with-tabular-vim/ | |
" - https://defuse.ca/vimrc.htm | |
" - markdown auto tables https://gist.github.com/tpope/287147 | |
" - vim flowchart http://goo.gl/fW8syG | |
" Initialization {{{1 | |
" Abort if vim wasn't built with +eval (vim-tiny, vim-small, etc) ... | |
if !1 | finish | endif | |
" If vim is starting & vi compatibility is set, disable it (enable vim | |
" compatibility). This is technically not necessary. As soon as vim finds | |
" a vimrc file to load it automatically disables vi compatibility mode. | |
if has('vim_starting') | |
set nocompatible | |
endif | |
" Vim must be compiled with +multi_byte in order to use unicode encoding. I try | |
" to gracefully fallback to non multi_byte support for systems that suck, but | |
" I haven't fully tested it yet. | |
if has("multi_byte") | |
scriptencoding utf-8 " The encoding for this file. | |
set encoding=utf-8 " Use utf-8 internally. | |
set termencoding=utf-8 " Assume our terminal supports utf-8. | |
setglobal fileencoding=utf-8 " Save new files as utf-8. | |
endif | |
" My configuration requires that I have several directories available at | |
" runtime, otherwise errors are generated and things break. This snippet | |
" attempts to create the directories on bsd/linux systems - if the mkdir command | |
" is available. If it's not, it spits out an error warning and stops loading the | |
" vimrc configuration. | |
for rdir in ['autoload', 'backup', 'bin', 'session', 'spell', 'swap', 'view'] | |
let rdirpath = $HOME . '/.vim/' . rdir | |
if !isdirectory(rdirpath) | |
if !exists("*mkdir") | |
echo "Error, 'mkdir' not available. Manually create directories." | |
finish | |
else | |
call mkdir(rdirpath,'p') | |
echo "Created directory: " . rdirpath | |
endif | |
endif | |
endfor | |
" My configuration requires that I have several external binaries available at | |
" runtime. This checks to ensure they're available. If they're not, an error | |
" warning is spit and the vimrc stops loading. It would be better to gracefully | |
" continue loading the parts that we can, and maybe I'll fix it to do this | |
" someday, but I haven't done it yet. | |
for rexe in ['ag', 'ctags', 'curl', 'git'] | |
" Require that we have access to the specified executable. | |
if !executable(rexe) | |
echom 'Error, ' . rexe . ' is not available.' | |
finish | |
endif | |
endfor | |
" Attempt to automatically download and install vim-plug if possible. | |
let s:plugfile = $HOME . '/.vim/autoload/plug.vim' | |
let s:plugsrc = 'https://raw.githubusercontent.com/' . | |
\ 'junegunn/vim-plug/master/plug.vim' | |
if !filereadable(s:plugfile) | |
echom 'Vim-plug not found. Attempting automatic installation.' | |
exec '!curl -fLo' . s:plugfile s:plugsrc | |
endif | |
" Attempt to automatically download and install markdown2ctags.py if possible. | |
" The script is run as an external binary, so it has to have execute permission | |
" set. This provides tagbar compatible ctags for markdown files. | |
let s:m2cfile = $HOME . '/.vim/bin/markdown2ctags.py' | |
let s:m2csrc= 'https://raw.githubusercontent.com/jszakmeister/markdown2ctags/master/markdown2ctags.py' | |
if !filereadable(s:m2cfile) | |
echom 'markdown2ctags.py not found. Attempting automatic installation.' | |
exec '!curl -fLo' . s:m2cfile s:m2csrc | |
exec '!chmod a+x' . s:m2cfile | |
endif | |
" Plugins {{{1 | |
call plug#begin('~/.vim/bundle') | |
" Colors & Syntax: | |
Plug 'flazz/vim-colorschemes' " Giant colorscheme pack. | |
Plug 'sheerun/vim-polyglot' " Giant syntax pack (50+). | |
Plug 'LokiChaos/vim-tintin' " Syntax for tintin++ language. | |
" Basics: | |
Plug 'ciaranm/securemodelines' " Psuedo-modelines, more secure. | |
Plug 'vim-scripts/restore_view.vim' " Save & restore views. | |
Plug 'vim-scripts/YankRing.vim' " Yank/paste buffer stack. | |
Plug 'guns/xterm-color-table.vim' " xTerm color table. | |
Plug 'tpope/vim-vinegar' " Lightweight file explorer. | |
Plug 'myusuf3/numbers.vim' " Better Line numbering. | |
" Editing: | |
Plug 'tpope/vim-commentary' " Comment out blocks in visual mode. | |
Plug 'tpope/vim-surround' " Delete, change & add surroundings. | |
Plug 'tpope/vim-endwise' " Auto-insert syntatical 'endings'. | |
Plug 'terryma/vim-multiple-cursors' " Multiple selections. Like a boss. | |
Plug 'godlygeek/tabular' " Table formatting. | |
" Extras: | |
Plug 'vim-scripts/utl.vim' " Execute hyperlinks from vim. | |
Plug 'greyblake/vim-preview' " Preview markup files. | |
Plug 'bling/vim-airline' " Shiny interface. | |
Plug 'mhinz/vim-startify' " MRU, bookmark & session manager. | |
Plug 'sjl/gundo.vim' " Undo tree browser. | |
Plug 'kien/ctrlp.vim' " Fuzzy finder. | |
Plug 'majutsushi/tagbar' " Tag browser/outliner. | |
Plug 'christoomey/vim-tmux-navigator' " Navigate between vim/tmux splits. | |
Plug 'vimwiki/vimwiki' " A personal notebook/wiki engine. | |
Plug 'vim-scripts/calendar.vim--Matsumoto' " Calendars for vimwiki. | |
" Autocompletion: | |
" YouCompleteMe is a *huge* completion engine for vim. It supports a ton of | |
" languages (the entire C family, python (jedi-based), vim, shell scripts, ruby, | |
" php, etc. The YCM executables must be compiled locally. The vim-plug hook | |
" below attempts to do this for me automatically when installing the plugin. | |
Plug 'Valloric/YouCompleteMe', { 'do': './install.sh --clang-completer' } | |
" Syntax Checking: | |
" Syntastic is a 'linting' framework. | |
Plug 'scrooloose/syntastic' " Syntax highlighting framework. | |
Plug 'ynkdir/vim-vimlparser' " VimL parser (required by vimlint). | |
Plug 'syngan/vim-vimlint' " VimL linter for syntastic. | |
" Snippets: | |
Plug 'SirVer/ultisnips' " Snippets framework. | |
Plug 'honza/vim-snippets' " Prebaked snippets for ultisnips. | |
Plug 'edkolev/promptline.vim' " Shell prompt generator. | |
Plug 'edkolev/tmuxline.vim' " Tmux statusline generator. | |
" Python: | |
" Plug 'hynek/vim-python-pep8-indent' " | |
call plug#end() | |
" Disabled Plugins {{{ | |
" I recently threw in the towel with the 'unite mafia' and switched away from | |
" neobundle, vimproc, unite, vimfiler, vimshell, all my unite extensions, | |
" neocomplete, and neosnippets. Things are in a slight disarray atm. | |
" Integrating: | |
" Plug 'Lokaltog/vim-easymotion' | |
" Plug 'tpope/vim-fugitive' " Use git *in* vim. | |
" Plug 'airblade/vim-gitgutter' " Display git markers in gutter. | |
" Plug 'mhinz/vim-signify' | |
" Plug 'ajh17/vim-fist' " So I can fist gists. | |
" Interesting: | |
" Plug 'rking/ag.vim' " Fork of ack.vim for ag. | |
" Plug 'szw/vim-ctrlspace' " Vim workspace controller. | |
" Plug 'tpope/vim-characterize' " Easier unicode characters. | |
" Plug 'wellle/tmux-complete.vim' " Autocomplete words in tmux sessions. | |
" Plug 'benmills/vimux' " Send commands to tmux. | |
" Plug 'julienr/vim-cellmode' " Use ipython with tmux. | |
" Plug 'terryma/vim-expand-region' " Visually expand region selections. | |
" Plug 'dbakker/vim-lint' " Linting support for vimL. | |
" Plug 'ynkdir/vim-vimlparser' " VimL parser. | |
" Plug 'tpope/vim-speeddating' | |
" Plug 'vim-scripts/TwitVim' " Vim twitter client. | |
" Plug 'Konfekt/FastFold' " Faster folding | |
" Plug 'Konfekt/FoldText' | |
" Plug 'osyo-manga/vim-over' | |
" Plug 'airblade/vim-rooter' " Change directory to project root. | |
" Plug 'rizzatti/dash.vim' " Some kinda new fandangled snippets. | |
" Plug 'junegunn/vim-after-object' " Text objects *after* a target. | |
" Plug 'bruno-/vim-alt-mappings' " Enable alt/option meta. | |
" Plug 'vim-scripts/EnhancedJumps' " Enhanced CTRL-I/CTRL-O jumps. | |
" Plug 'dahu/MarkMyWords' " Arbitrary bookmarks for vimdocs. | |
" Plug 'oplatek/Conque-Shell' " It's a shell! | |
" Plugin Managers: | |
" Plug 'tpope/vim-pathogen' " Super lightweight. | |
" Plug 'Shougu/neobundle.vim' " Feature-rich fork of vundle. | |
" Plug 'junegunn/vim-plug' " Looks interesting. | |
" Plug 'sunaku/vim-unbundle' | |
" Unite Mafia: | |
" Plug 'Shougu/vimproc.vim' " Asynchronous task runner. | |
" Plug 'Shougo/unite.vim' " CtrlP on steroids. | |
" Plug 'Shougu/vimfiler.vim' " A feature-rich file explorer. | |
" Plug 'Shougu/vimshell.vim' " A shell, written in vimscript. | |
" Plug 'Shougu/neocomplete.vim' " A feature-rich completion engine. | |
" Plug 'Shougu/neosnippets.vim' " A feature-rich snippet manager. | |
" Plug 'Shougo/neosnippet-snippets' " Standard snippets for neosnippets. | |
" Development: | |
" Plug 'dahu/vimple' " VimL utility commands. | |
" Plug 'janko-m/vim-test' " Wrap test runners. | |
" Retired: | |
" Plug 'plasticboy/vim-markdown' " Markdown editing mode. | |
" Plug 'scrooloose/nerdtree' " File explorerator. | |
" Plug 'yuratomo/w3m.vim' " W3m browser *in* vim. | |
" Plug 'kana/vim-wwwsearch' " Search the web from vim. | |
" }}} | |
" Core Settings {{{1 | |
filetype indent plugin on " Enable filetype detection. | |
syntax on " Enable syntax highlighting. | |
set nomodeline " Fuck modelines (CVE-2002-1377). | |
set t_Co=256 " Assume we can handle 256 colors. | |
set ttyfast " Always enable ttyfast. | |
set fileformats="unix,dos,mac" " Determines EOLs from these options. | |
set backspace=eol,indent,start " Make backspace better. | |
set history=100 " Remember more command history. | |
set scrolloff=10 " Keep the buffer more 'centered' ... | |
set sidescrolloff=10 " ... do it horizontally, too. | |
" Errors: | |
set confirm " Prompt on buffer errors. | |
set noerrorbells " No errorbells ... | |
set visualbell " ... seriously, no errorbells ... | |
set t_vb= " ... seriously, no.fucking.bells. | |
" Buffer Behaviors: | |
set autochdir " Use the buffer's path as the pwd. | |
set autoread " Reload modified buffers. | |
set autowrite " Write modified buffers. | |
set hidden " Hide buffers (don't unload them). | |
" Searching: | |
set hlsearch " Enable search highlighting. | |
set ignorecase " Ignore case when searching ... | |
set smartcase " ... unless we use uppercase. | |
set gdefault " Use *real* regular expressions. | |
set incsearch " ... as we type them. | |
set wrapscan " Wrap searches back around buffer. | |
" Text Formatting: | |
set autoindent " Enable automatic indentation. | |
set copyindent " Preserve tab indents (override et). | |
set expandtab " Don't ever fucking use tabs. | |
set smarttab " Smarter tabs, kthxbye. | |
set shiftround " Round shifts to shiftwidth. | |
set tabstop=2 " Number of 'columns' in a tab. | |
set softtabstop=2 " Fix tabstop (<BS> twerks now). | |
set shiftwidth=2 " Shifts == tabs. Chriiiist. | |
" Visuals: | |
set number " Display line numbers. | |
set showcmd " Show partial commands while typing. | |
set showmatch " Highlight matching 'matchpairs'. | |
set matchtime=1 " Tenth's of seconds to flash match. | |
set laststatus=2 " Always display the statusline. | |
set nowrap " Don't softwrap lines. | |
" Backup & Swap Files: | |
set backupdir=$HOME/.vim/backup// " Save in .vim/backup with full path. | |
set directory=$HOME/.vim/swap// " Save in .vim/swap with full path. | |
set backup " Enable backup files. | |
set swapfile " Enable swap files. | |
" Needs more evaluation. | |
set timeout " Enable timeout (on by default). | |
set timeoutlen=300 " Delay in ms to wait for mappings. | |
set ttimeoutlen=50 " Delay in ms to wait for ? | |
set updatetime=1000 " Wait #MS to write swap & update | |
" cursor. | |
" set fillchars=vert:┃,diff:⎼,fold:⎼ | |
" Disabled Settings {{{2 | |
" Line numbering is handled by the 'numbers' plugin. | |
" I removed these from my default configuration and set these with file-specific | |
" autocommands instead. | |
" set textwidth=80 " Break at 80 characters. | |
" set colorcolumn=81 " Highlight column 81. | |
" This looks just like smartcase. Haven't examined it's behavior yet. | |
" set infercase " Fuck does this guy do? | |
" Not entirely sure what these do or how useful they are. | |
" set ruler | |
" set rulerformat | |
" This looks interesting. It may be a better way to modify the behavior of help | |
" buffers. | |
" set switchbuf | |
" Softwrapping is a pain in my ass. Not sure that I really need it. Need to play | |
" with this some more. | |
" set wrap " Enable soft wrapping ... | |
" set linebreak " ... but break at 'breakat'. | |
" set breakat='' " List of characters to wrap on. | |
" }}} | |
" Colors {{{1 | |
" - All colors are configured with the 'highlight' command. | |
" - How to detect if colorscheme is available, before trying to set it? | |
" | |
" Colorschemes: | |
" - https://github.com/nanotech/jellybeans.vim | |
" - https://github.com/ajh17/Spacegray.vim | |
" Guides: | |
" - http://blog.hanschen.org/2012/10/24/different-background-color-in-vim-past-80-columns/ | |
" - https://stackoverflow.com/questions/2447109/showing-a-different-background-colour-in-vim-past-80-characters | |
colorscheme jellybeans " Pretty colors. | |
set cursorcolumn " Highlight the current column. | |
set cursorline " Highlight the current line. | |
" Option Strings {{{1 | |
" Compatibility options (flags). The default is 'aABceFs'. | |
set cpo=aABceFsmq | |
" ||||||||| | |
" ||||||||+- When joining lines, leave the cursor between them. | |
" |||||||+-- When a new match is created (showmatch) pause for .5. | |
" ||||||+--- Set buffer options when entering the buffer. | |
" |||||+---- Default titles for unnamed buffers. | |
" |||+------ Smarter searching. | |
" ||+------- A backslash has no special meaning in mappings. | |
" |+-------- :write updates alternative file name. | |
" +--------- :read updates alternative file name. | |
" Formatting options (flags). Default is 'tcq'. | |
set fo=1ncroqlt | |
" |||||||| | |
" |||||||+--- Auto-wrap using textwidth. | |
" ||||||+---- Leave lines that were already long alone in insert mode. | |
" |||||+----- Allow formatting of comments with 'gq'. | |
" ||||+------ Continue comments with 'o' & 'O'. | |
" |||+------- <Enter> continues comments in insert mode. | |
" ||+-------- Auto-wrap comments using text-width. | |
" |+--------- Recognize numbered lists (requires autoformat). | |
" +---------- Break lines before 1-letter words rather than after. | |
" Wrapping options (flags). Default is 'b,s'. | |
set ww=b,s,h,l,<,>,~,[,] " everything wraps | |
" | | | | | | | | | | |
" | | | | | | | | +-- "]" Insert and Replace | |
" | | | | | | | +---- "[" Insert and Replace | |
" | | | | | | +------ "~" Normal | |
" | | | | | +-------- <Right> Normal and Visual | |
" | | | | +---------- <Left> Normal and Visual | |
" | | | +------------ "l" Normal and Visual (not recommended) | |
" | | +-------------- "h" Normal and Visual (not recommended) | |
" | +---------------- <Space> Normal and Visual | |
" +------------------ <BS> Normal and Visual | |
" Features {{{1 | |
" These settings take advantage of various optional features that may or may not | |
" be available depending on how the current version of vim was compiled. You can | |
" list your available features with the commands: | |
" vim --version | |
" :version | |
" Enable undo files. | |
if has('persistent_undo') && isdirectory($HOME . '/.vim/undo') | |
set undodir=~/.vim/undo " Save undo files here. | |
set undofile " Enable persistent undo. | |
set undolevels=1000 " Number of undo levels to save. | |
set undoreload=10000 " Save entire buffers to the undo tree | |
endif | |
" The 'types' of settings to save and restore from view files. I use the default | |
" 'viewdir' (on OS X & linux this is $HOME/.vim/view). | |
if has("mksession") && isdirectory($HOME . '/.vim/view') | |
set viewoptions=cursor,folds,slash,unix | |
endif | |
" Save and restore these settings from our session files. | |
if has("mksession") && isdirectory($HOME . '/.vim/session') | |
set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize | |
endif | |
if has('viminfo') | |
" set viminfo='100,<50,s10,h " Defaults. | |
set viminfo+=% " Save and restore the buffer list. | |
set viminfo+=h " Don't display hlsearch. | |
set viminfo='500 " Rember marks for # of files. | |
set viminfo+=\"100 " Max # lines for each register. | |
set viminfo+=:1000 " Max # lines of command history. | |
set viminfo+=! " Save & restore global variables. | |
set viminfo+=n$HOME/.vim/viminfo " Put viminfo in ~/.vim. | |
endif | |
if has("title") | |
set title " Set the terminal name. | |
set titleold="" " No thank you for flying vim! | |
set titlelen=40 " Maximum length of title string. | |
set titlestring=%t " Just show the filename. | |
endif | |
if has("wildmenu") | |
set wildmenu " Enable wildemenu. | |
set wildignorecase " Ignore case for filename matching. | |
set wildmode=longest:full,full " Better command expansion behavior. | |
set wildignore=*.DS_Store " Wildmenu will perform tab expansion | |
set wildignore+=.hg,.git,.svn " against filenames. Wildignore | |
set wildignore+=*.jpg,*.bmp,*.gif " allows us to define a list of | |
set wildignore+=*.pyc " patterns not to expand. | |
endif | |
if has('clipboard') | |
if has("mac") | |
" Assume wierd-ass macvim vim & use unnamed for everything. | |
set clipboard=unnamed | |
elseif has("unnamedplus") | |
set clipboard=unnamed,unnamedplus " Sync all yank buffers. | |
elseif has("unnamed") | |
set clipboard=unnamed " Just use the unnamed buffer then. | |
endif | |
endif | |
if has("folding") | |
" - http://dhruvasagar.com/2013/03/28/vim-better-foldtext | |
" - http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/ | |
" - https://github.com/Konfekt/FoldText | |
if has("multi_byte") | |
setlocal fillchars+=fold:⎼ | |
endif | |
set foldtext=BestFoldText() | |
" set nofoldenable " Leave all folds open. | |
" set foldmethod=indent " Use indentation to build fold marks. | |
" set foldnestmax=6 " Don't fold over 6 levels. | |
" set foldopen=all " Expand folds pretty much always. | |
" set foldtext=BetterFoldText() " Custom fold labels. | |
endif | |
if has('mouse') | |
set mouse=a " Enable mouse in all modes. | |
set mousehide " Hide the mouse unless we're using it. | |
if has('mouse_sgr') || v:version > 703 || v:version == 703 && has('patch632') | |
set ttymouse=sgr | |
else | |
set ttymouse=xterm2 | |
endif | |
if has("gui_running") | |
set mousefocus " Activate tabs on mouseover. | |
endif | |
endif | |
if has("virtualedit") | |
set virtualedit=block,onemore | |
endif | |
if has("gui_running") | |
set guioptions-=T | |
set guioptions-=e | |
set guitablabel=%M\ %t | |
endif | |
" Functions {{{1 | |
" Function definitions. | |
function! UIRefresh() | |
" Sometimes the interface gets screwy. For whatever-fucking-reason. I map this | |
" function to F1 so I can mash it when I'm pissed off cause it's all fucked | |
" up. If vim-airline is installed, the AirlineRefresh function will also be | |
" called. | |
redraw! " clear & redraw the screen | |
redrawstatus! " redraw all statuslines | |
if exists(":AirlineRefresh") | |
:AirlineRefresh | |
endif | |
endfunction | |
function! TogglePaste() | |
" A wrapper for 'pastetoggle'. This is bare minimum at the moment, needs some | |
" tweaking with enhancements. | |
" http://vim.wikia.com/wiki/Toggle_auto-indenting_for_code_paste | |
" http://vimdoc.sourceforge.net/htmldoc/options.html#'paste' | |
" http://vimdoc.sourceforge.net/htmldoc/options.html#'pastetoggle' | |
" https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode | |
set paste! | |
endfunction | |
function! ToggleInvisibles() | |
" Toggle the display of invisible characters. If multi_byte is supported, | |
" better-looking unicode characters will be used. If multi_byte is not | |
" supported, standard ascii characters will be used. | |
" Note: This still needs a little tweaking to make it work quite right. | |
if &list | |
set listchars= | |
set nolist | |
else | |
if has("multi_byte") | |
let &listchars = 'break:¶,' | |
let &listchars .= 'conceal:⬩,' | |
let &listchars .= 'eol:¬,' | |
let &listchars .= 'extends:❯,' | |
let &listchars .= 'nbsp:␣,' | |
let &listchars .= 'precedes:❮,' | |
let &listchars .= 'tab:»-,' | |
let &listchars .= 'trail:·' | |
" Alternative unicode characters. | |
" let &listchars .= 'extends:»,' | |
" let &listchars .= 'precedes:«,' | |
" let &listchars .= 'trail:•' | |
else | |
let &listchars = 'break:^,' | |
let &listchars .= 'conceal:.,' | |
let &listchars .= 'eol:$,' | |
let &listchars .= 'extends:>,' | |
let &listchars .= 'nbsp:.,' | |
let &listchars .= 'precedes:<,' | |
let &listchars .= 'tab:>-,' | |
let &listchars .= 'trail:.' | |
endif | |
echom 'Displaying listchars as ' . &listchars . '.' | |
set list | |
endif | |
endfunction | |
function! BetterFoldText() | |
" This is SJL's FoldText function. I'm not using it, but it's currently dumped | |
" here as a reference while building my own. | |
let line = getline(v:foldstart) | |
let nucolwidth = &fdc + &number * &numberwidth | |
let gwindowwidth = winwidth(0) - nucolwidth - 3 | |
let foldedlinecount = v:foldend - v:foldstart | |
" expand tabs into spaces | |
let onetab = strpart(' ', 0, &tabstop) | |
let line = substitute(line, '\t', onetab, 'g') | |
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) | |
let fillcharcount = windowwidth - len(line) - len(foldedlinecount) | |
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' | |
endfunction | |
" https://github.com/shalomb/dotfiles/blob/master/.vim/plugin/foldbetter.vim#L39 | |
function! BestFoldText() | |
return foldtext() | |
let &l:fillchars = substitute(&l:fillchars,',\?fold:.','','gi') | |
echom l:fillchars | |
endfunction | |
function! ToggleAutoFormating() | |
" Toggle autoformatting. This relies on the setting of 'formatoptions'. | |
if &formatoptions !~ 'a' | |
setlocal formatoptions+=a | |
echom "Autoformatting has been enabled." | |
else | |
setlocal formatoptions-=a | |
echom "Autoformatting has been disabled." | |
endif | |
endfunction | |
function! ToggleSpellChecking() | |
" Toggle spellchecking on and off. | |
let spelldir = $HOME . '/.vim/spell' | |
let spft = &filetype | |
" setlocal spellfile= | |
setlocal spell! | |
endfunction | |
function! ToggleCalendarWindow() | |
" Toggle displaying the calendar window. Requires the calendar plugin. | |
" Unlike most plugins, the calendar window inherits a bunch of 'editing' | |
" settings that are highly undesirable. When displaying the Calendar window, | |
" I disable them all and refocus my current window. | |
" https://github.com/vim-scripts/calendar.vim--Matsumoto | |
if buflisted("__Calendar") | |
let s:cur_win_num = winnr() | |
let s:cal_win_num = bufwinnr("__Calendar") | |
exe s:cal_win_num . "wincmd w" | wincmd c | |
exe s:cur_win_num . "wincmd w" | |
else | |
if exists(":Calendar") | |
let s:cur_win_num = winnr() | |
Calendar | |
else | |
echoerr 'calendar.vim is not installed.' | |
endif | |
endif | |
endfunction | |
function! ToggleSyntaxErrorWindow() | |
" if !exists("g:errorwindow") | |
" Toggle the syntastic location-list (contains linting errors). | |
endfunction | |
function! QuickfixToggle() | |
" http://learnvimscriptthehardway.stevelosh.com/chapters/38.html | |
if g:quickfix_is_open | |
cclose | |
let g:quickfix_is_open = 0 | |
execute g:quickfix_return_to_window . "wincmd w" | |
else | |
let g:quickfix_return_to_window = winnr() | |
copen | |
let g:quickfix_is_open = 1 | |
endif | |
endfunction | |
" http://vim.wikia.com/wiki/Cycle_through_buffers_including_hidden_buffers | |
function! BetterExit() | |
let calendarwinnr = bufwinnr('__Calendar') | |
if calendarwinnr == -1 | |
return | |
endif | |
let window_count = winnr('$') | |
let current_window = winnr() | |
let last_window = winnr('#') | |
" Enumerating the windows. | |
for win_id in range(1, winnr(window_count)) | |
" Get the id of the buffer associated with the current window. | |
let buf_id = winbufnr(win_id) | |
" If the current buffer buffer is not hidden, continue. | |
if !buflisted(buf_id) | |
continue | |
endif | |
endfor | |
endfunction | |
" Commands {{{1 | |
if executable('ag') | |
" Defines a new command Ag to search for the provided text and open | |
" a “quickfix” window. | |
command! -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw! | |
" When ag is available, use it as the default method for grepping in vim. | |
set grepprg=ag\ --nogroup\ --nocolor | |
endif | |
" Plugin Settings {{{1 | |
" Airline {{{2 | |
" Airline is a sexy 'powerline style' statusline & tabline interface for vim. | |
" The special symbols can be disabled (if so desired), but I like them - so | |
" I keep them enabled. In order to use these, your terminal must be displaying | |
" text using a font that's been patched with the powerline symbols (requires | |
" a unicode-capabable terminal emulator). | |
" | |
" I configure my terminal emulator, shell prompt, tmux statusline & vim | |
" interface using 'themes' to keep everything looking similar. | |
" | |
" 1. Get a theme from: https://github.com/mbadolato/iTerm2-Color-Schemes | |
" 2. Built a compatible prompt with promptline: | |
" https://github.com/edkolev/promptline.vim | |
" 3. Build a compatible tmux status line with tmuxline: | |
" https://github.com/edkolev/tmuxline.vim | |
" 4. Use vim-airline to setup a compatible statusline & tabline in vim: | |
" https://github.com/bling/vim-airline | |
" 5. Profit! | |
" | |
" Airline 'preloads' extensions it knows about (before it finishes loading) so | |
" that it can detect their settings and configure itself appropriately. | |
" Automatically populate airline's symbols dictionary from the standard | |
" powerline symbols (requires using a powerline-patched font in your terminal | |
" emulator). | |
let g:airline_powerline_fonts = 1 | |
let g:airline_branch_prefix = '⎇ ' " Git branch symbol. Double-width. | |
" Hardcode the colorscheme that airline will generate colors from. Some themes | |
" have better integration than others. This isn't *really* necessary. | |
" let g:airline_theme = 'jellybeans' | |
let g:airline_detect_modified = 1 " Detect modified buffers. | |
let g:airline_detect_paste = 1 " Detect paste mode. | |
let g:airline_detect_iminsert = 1 " Detect iminsert input. | |
let g:airline_inactive_collapse = 1 " Collapse inactive window names. | |
" Enable airline's built-in whitespace extension. This detects malformed | |
" indentation & trailing whitespace. These will be highlighted when 'set list' | |
" is enabled. | |
let g:airline#extensions#whitespace#checks = [ 'indent', 'trailing' ] | |
let g:airline#extensions#whitespace#max_lines = 20000 | |
let g:airline#extensions#whitespace#show_message = 1 | |
" Enable airline's built-in tabline extension. The default configuration | |
" displays tabs nicely, but if you don't use them often (I don't) this is still | |
" *extremely* useful for displaying buffers - it just requires a little extra | |
" configuration. | |
" Note: Things start to get wonky when I open up tabs, but I rarely do, so this | |
" works perfectly 99% of the time for me. | |
let g:airline#extensions#tabline#enabled = 1 " Enable enhanced tabline. | |
let g:airline#extensions#tabline#show_buffers = 1 " Don't collapse buffers. | |
let g:airline#extensions#tabline#buffer_nr_show = 1 " Show buffer ids, not tabs. | |
" Use only the filename as the buffer label, unless we have multiple files with | |
" the same name open - then use the condensed path as the buffer label. | |
let g:airline#extensions#tabline#formatter = 'unique_tail_improved' | |
let g:airline#extensions#tmuxline#enabled = 0 " Airline shouldn't theme tmux. | |
let g:airline#extensions#csv#enabled = 1 " Enable csv integration. | |
let g:airline#extensions#tagbar#enabled = 1 " Enable tagbar integration. | |
let g:airline#extensions#branch#enabled = 1 " Enable fugitive integration. | |
" let g:airline#extensions#hunks#enabled = 1 " vim-gitgutter & vim-signify | |
" Only necessary if airline theme doesn't define ctrlp colors. | |
" let g:airline#extensions#ctrlp#color_template = 'insert' (default) | |
" let g:airline#extensions#ctrlp#color_template = 'normal' | |
" let g:airline#extensions#ctrlp#color_template = 'visual' | |
" let g:airline#extensions#ctrlp#color_template = 'replace' | |
" Calendar {{{2 | |
let g:calendar_focus_today = 1 | |
let g:calendar_mark = 'right' | |
let g:calendar_datetime = 'title' | |
let g:calendar_weeknm = 1 | |
" CtrlP {{{2 | |
" Notes {{{ | |
" CtrlP is a 'fuzzy finder' that lets us find shit (files, bufffers, tags, etc). | |
" By default it uses vimgrep to search the sources. If I have ag available, | |
" I use that instead for searching files (because it's *much* faster). | |
" | |
" - CtrlP respects wildignore, but also g:ctrlp_custom_ignore. | |
" - CtrlP uses vimgrep by default, but can be configured to use other commands | |
" (i.e. Ag). | |
" | |
" References: | |
" github:kien/ctrlp http://goo.gl/GNZmb8 | |
" github:skwp/dotfiles/vimrc/ctrlp.vim http://goo.gl/fsbecy | |
" }}} | |
" When opening a file with <cr>, CtrlP avoids opening it in windows created by | |
" plugins, help and quickfix. Use this to setup some exceptions: > | |
" let g:ctrlp_reuse_window = 'netrw' | |
" When opening a file, if it's already open in a window somewhere, CtrlP will | |
" try to jump to it instead of opening a new instance: > | |
" let g:ctrlp_switch_buffer = 'Et' | |
" When starting up, CtrlP sets its local working directory according to this | |
" variable: > | |
" - r - the nearest ancestor that contains one of these directories or files: | |
" .git .hg .svn .bzr _darcs | |
" - w - begin finding a root from the current working directory outside of CtrlP | |
" instead of from the directory of the current file (default). Only applies | |
" when 'r' is also present. | |
" let g:ctrlp_working_path_mode = 'rw' | |
" Set this to 1 if you want CtrlP to scan for dotfiles and dotdirs: > | |
let g:ctrlp_show_hidden = 1 | |
" If vim *cannot* find the ag executable then use the default (vimgrep). | |
if !executable('ag') | |
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' | |
else | |
" Ag is *really* fast, we don't need to cache files. | |
let g:ctrlp_use_caching = 0 | |
" When listing files with CtrlP, generate the input source using ag. Ag | |
" respects .gitignore by default. | |
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
endif | |
" Numbers {{{2 | |
" Numbers handles line numbering better than the built-in methods. By default, | |
" it toggles line number on and off when activating a buffer (which gets really | |
" annoying) when switching back and forth. I have not found a way to prevent | |
" this behavior yet. :/ | |
let g:numbers_exclude = ['calendar', 'gundo', 'startify', 'tagbar'] | |
" Gundo {{{2 | |
" Gundo provides an | |
let g:gundo_right = 1 | |
let g:gundo_help = 0 | |
" Startify {{{2 | |
" Startify is a 'start buffer' for vim. By default, it displays a list of | |
" recently used files & directories, bookmarks, and sessions (I reconfigured | |
" this slightly). It provides some wrapper functions for dealing with sessions | |
" that allows them to be automatically saved to a specific directory | |
" (~/.vim/session in my case), so that they can be managed more efficiently. | |
" Save all sessions (using :SSave) to this directory. | |
let g:startify_session_dir = '~/.vim/session' | |
" Automatically update sessions before leaving vim or loading a new session | |
" via ':Sload'. | |
let g:startify_session_persistence = 1 | |
" Delete all open buffers when loading a session via ':SLoad'. | |
let g:startify_session_delete_buffers = 1 | |
" When opening a file or bookmark with startify, automatically change vim's | |
" current working directory to file's location. | |
let g:startify_change_to_dir = 1 | |
" Custom header for startify buffer. | |
let g:startify_custom_header = [ | |
\ ' ________ __ __ ', | |
\ ' __ /\_____ \/\ \\ \ ', | |
\ ' __ __ /\_\ ___ ___ \/___//''/''\ \ \\ \ ', | |
\ ' /\ \/\ \\/\ \ /'' __` __`\ /'' /'' \ \ \\ \_ ', | |
\ ' \ \ \_/ |\ \ \/\ \/\ \/\ \ /'' /''__ \ \__ ,__\', | |
\ ' \ \___/ \ \_\ \_\ \_\ \_\ /\_/ /\_\ \/_/\_\_/ ', | |
\ ' \/__/ \/_/\/_/\/_/\/_/ \// \/_/ \/_/ ', | |
\ '', | |
\ '', | |
\ ] | |
" Custom startify sections. | |
let g:startify_list_order = | |
\ [ | |
\ [' Recent Files:'], 'files', | |
\ [' Bookmarks:'], 'bookmarks', | |
\ [' Sessions:'], 'sessions' | |
\ ] | |
" Filter these file patterns from the MRU list. Without this, it gets polluted | |
" quickly by helpfiles and junk. | |
let g:startify_skiplist = [ | |
\ 'COMMIT_EDITMSG', | |
\ $VIMRUNTIME .'/doc', | |
\ 'bundle/.*/doc', | |
\ '.vimgolf', | |
\ ] | |
" I keep my startify bookmarks configuration in a separate, system-local file. | |
" Check for it's existence and source it if it's present. | |
" My startify bookmarks - these are project directories I'm currently working on | |
" and like to rapidly 'bounce' between. | |
let g:startify_bookmark_file = $HOME . "/.vim/startify-bookmarks.vim" | |
" If our startify bookmarks file exists, source it. | |
if filereadable(g:startify_bookmark_file) | |
execute 'source'.g:startify_bookmark_file | |
endif | |
" Syntastic {{{2 | |
" | |
" - Syntastic is not compatible with vim-virtualenv. | |
" - YCM disables syntastics checkers for c, c++, objc, & objc++. | |
" - Linting VimL is really slow & autocommands that reload your vimrc bypass the | |
" settings that automaticaly enable/disable linting on save and loading | |
" (making really slow checks happen each time you updating your vimrc). | |
" Fortunately, setting 'vim' to passive using the mode_map setting is still | |
" respected and will disable these checks unless explicitly called. | |
" The mode map settings allow more fine-grained control over how syntastic | |
" behaves. Some of the other settings seem not to be respected, but mode_map | |
" does. | |
let g:syntastic_mode_map = | |
\ { | |
\ "mode": "passive", | |
\ "active_filetypes": ["python", "ruby", "php"], | |
\ "passive_filetypes": ["vim"] | |
\ } | |
" Better error & warning symbols if we have unicode support. | |
if has("multi_byte") | |
let g:syntastic_error_symbol = "✗" | |
let g:syntastic_warning_symbol = "⚠" | |
endif | |
" These settings do not seem to be respected, regardless of anything else. The | |
" mode_map settings seems to work though. | |
" let g:syntastic_check_on_open = 0 " Disable lint on open/close. | |
" let g:syntastic_check_on_wq = 0 " Disable linting on save. | |
" Automatic cursor positioning - doesn't seem to be working as expected. The | |
" description of the difference in behavior between 2 & 3 does not make sense. | |
" let g:syntastic_auto_jump = 0 " Don't move cursor to errors. | |
" let g:syntastic_auto_jump = 1 " Jump to first error or warning. | |
" let g:syntastic_auto_jump = 2 " Jump to first issue, if its an error. | |
" let g:syntastic_auto_jump = 3 " Jump to first error, or not at all. | |
" The location-list is a separate buffer that we can shove linting errors into. | |
" Always populate the error location list, even if we aren't automatically | |
" displaying it. | |
" let g:syntastic_always_populate_loc_list = 1 | |
" let g:syntastic_auto_loc_list = 0 " Don't open or close error window. | |
" let g:syntastic_auto_loc_list = 1 " Open when errors, close when none. | |
" let g:syntastic_auto_loc_list = 2 " Don't open, close when no errors. | |
" Tagbar {{{2 | |
" Tags are pretty gnarly to figure out (IMHO) but wildely useful once they're | |
" working correctly. Tagbar is heavily based on/inspired by Taglist. I use | |
" exuberant-ctags to build my vim-compatible tags, which does not come with | |
" markdown support. Markdown2ctags.py does a great job of providing the tags for | |
" tagbar. | |
let g:tagbar_left = 0 " open tagbar on the right-hand side | |
let g:tagbar_width = 40 " tagbar is 40 characters wide | |
let g:tagbar_zoomwidth = 100 " use the width of longest tag | |
let g:tagbar_autofocus = 1 " don't automatically focus tagbar | |
let g:tagbar_compact = 1 " don't display blank lines or help | |
let g:tagbar_autoshowtag = 1 " open folds when jumping to a tag | |
" Add support for markdown files in tagbar using markdown2ctags.py. | |
let g:tagbar_type_markdown = { | |
\ 'ctagstype': 'markdown', | |
\ 'ctagsbin' : $HOME . '/.vim/bin/markdown2ctags.py', | |
\ 'ctagsargs' : '-f - --sort=yes', | |
\ 'kinds' : [ | |
\ 's:sections', | |
\ 'i:images' | |
\ ], | |
\ 'sro' : '|', | |
\ 'kind2scope' : { | |
\ 's' : 'section', | |
\ }, | |
\ 'sort': 0, | |
\ } | |
" Ultisnips {{{2 | |
" - https://github.com/sirver/ultisnips | |
" - https://github.com/honza/vim-snippets/tree/master/UltiSnips | |
" Utl {{{2 | |
" There's a lot of shit utl can do. I need to spend some time figuring it out. | |
" | |
" References: | |
" - vim-scripts/utl.vim | |
" - zmughal/vimrc http://goo.gl/SYXKHc | |
" - zmughal/vimrc http://goo.gl/9KdqqW | |
" - proudlygeek/my-vimrc http://goo.gl/fKkbDu | |
" - https://github.com/kristofklee/dotfiles/blob/e7e2a9fe302b00a5a35756c6ec65ccb741d2f5f5/vimrc | |
" - https://github.com/jayed/pyclewn/blob/bf1df16ebd2d9ee8cee2669b3b53f476993dfe20/_vim/bundle.available/utl/plugin/utl_rc.vim | |
if has("mac") | |
let g:utl_cfg_hdl_scm_http_system = "!open '%u'" | |
endif | |
" vim-markdown {{{2 | |
" Configuration for plasticboy's 'markdown-mode'. | |
" - This requires godlygeek's tabular plugin. | |
" let g:vim_markdown_folding_disabled=0 " Disable folding configuration. | |
" let g:vim_markdown_initial_foldlevel=1 " Set the intial foldlevel. | |
" let g:vim_markdown_frontmatter=1 " Enable frontmatter syntax: | |
" let g:vim_markdown_math=1 " Enable LaTex math. | |
" vim-tmux-navigator {{{2 | |
let g:tmux_navigator_no_mappings = 1 | |
" let g:tmux_navigator_save_on_switch = 1 | |
" nnoremap <silent> {Left-mapping} :TmuxNavigateLeft<CR> | |
" nnoremap <silent> {Down-Mapping} :TmuxNavigateDown<CR> | |
" nnoremap <silent> {Up-Mapping} :TmuxNavigateUp<CR> | |
" nnoremap <silent> {Right-Mapping} :TmuxNavigateRight<CR> | |
" nnoremap <silent> {Previous-Mapping} :TmuxNavigatePrevious<CR> | |
" vimwiki {{{2 | |
" Vimwiki is *huge* and kind of difficult to get started with. I usually try to | |
" stay away from plugins like this and hack my own functionality together, but | |
" it's pretty good so I'm using it. | |
" | |
" | |
" - https://github.com/vimwiki/vimwiki | |
" - https://github.com/vimwiki/vimwiki/issues/95 | |
" | |
" <Leader>ww - open index file of default wiki | |
" #<Leader>ww - open index file of # wiki | |
" Set .wiki as the default file extension and markdown as the default file | |
" syntax for .wiki files. Wikis *apparently* still need to specify their syntax | |
" and extension. Not sure exactly what this setting is doing. | |
let g:vimwiki_ext2syntax = {'.wiki': 'markdown'} | |
" Don't automatically parse camelcase words to wiki links. | |
let g:vimwiki_camel_case = 0 | |
" Enable calendar integration via calendar.vim. | |
let g:vimwiki_use_calendar = 1 | |
" The root path where I store my notebooks. | |
let g:vimwiki_root = $HOME . '/Documents/Wiki' | |
let g:vimwiki_list = [ | |
\ {'path': g:vimwiki_root, 'syntax': 'markdown', 'ext': '.wiki'} | |
\ ] | |
" Yankring {{{2 | |
" To save yankring persistently between sessions, you must tell viminfo to save | |
" & restore global variables with: 'set viminfo+=!' | |
let g:yankring_history_dir = '$HOME/.vim/' " Where to store yankring files. | |
let g:yankring_history_file = 'yankring.vim' " The name of the yankring file. | |
" YouCompleteMe {{{2 | |
" https://blog.dbrgn.ch/2013/5/27/using-jedi-with-ymc/ | |
" Mappings {{{1 | |
" I keep all my key mappings in a single section, otherwise I lose track of them | |
" and they attack me when I'm least expecting it. It's kind of awkward not | |
" having them in specific 'settings' related categories (i.e. folding mappings | |
" with folding settings), but you can't have your fucking cake and eat it too. | |
" | |
" Note: It makes me want to cut myself that I can't comment my mappings on the | |
" same line I define them on. | |
" | |
" References: | |
" - https://www.reddit.com/r/vim/comments/2po023/which_key_do_you_bind_to_esc/ | |
" Use semicolon as colon. #pinkysaver | |
" nnoremap ; : | |
" Colon as semicolon. | |
" nnoremap : ; | |
" Doublecolon for colon. | |
" nnoremap ;; ; | |
" Function Key mappings. Toggle various shit. Like a boss. | |
" http://vim.wikia.com/wiki/Displaying_the_current_Vim_environment | |
" https://github.com/vim-scripts/listmaps.vim | |
noremap <silent> <F1> :call UIRefresh()<CR> | |
noremap <silent> <F2> :call TogglePaste()<CR> | |
noremap <silent> <F3> :call ToggleInvisibles()<CR> | |
noremap <silent> <F4> :call ToggleSpellChecking()<CR> | |
noremap <silent> <F5> :call ToggleAutoFormating()<CR> | |
noremap <silent> <F6> :call NumbersToggle()<CR> | |
" Pretty standard mapleader. There are better options. This will likely change | |
" in the near future. | |
let mapleader="," | |
" I make heavy use of two-stroke pneumonic mappings. ',' is a shitty leader key, | |
" but that's what I'm using (for now). Because this binds up my right hand, most | |
" of my leader bindings utilize a keypair that's easy to hit with my left hand. | |
nnoremap <silent> <Leader>tc :call ToggleCalendarWindow()<CR> | |
nnoremap <silent> <Leader>tg :GundoToggle<CR> | |
nnoremap <silent> <Leader>tt :TagbarToggle<CR> | |
nnoremap <silent> <Leader>tq :call QuickfixToggle()<cr> | |
" CtrlP mappings. | |
nnoremap <silent> <Leader>cf :CtrlP<CR> | |
nnoremap <silent> <Leader>cb :CtrlPBuffer<CR> | |
nnoremap <silent> <Leader>cr :CtrlPMRU<CR> | |
nnoremap <silent> <Leader>sp :set spell!<CR> | |
nnoremap <silent> <Leader>st :Startify<CR> | |
nnoremap <silent> <Leader>vs :source $MYVIMRC<CR> | |
nnoremap <silent> <Leader>ve :e $MYVIMRC<CR> | |
" vim-preview mappings | |
nnoremap <silent> <Leader>p :Preview<CR> | |
nnoremap <silent> <Leader>Pm :PreviewMarkdown<CR> | |
nnoremap <silent> <Leader>Pt :PreviewTextile<CR> | |
nnoremap <silent> <Leader>Pr :PreviewRdoc<CR> | |
nnoremap <silent> <Leader>Ph :PreviewHtml<CR> | |
" vimwiki mappings | |
" - https://github.com/richard-ma/personal-config/blob/master/vimrc | |
map <Leader>wf <Plug>VimwikiFollowLink | |
map <Leader>we <Plug>VimwikiSplitLink | |
map <Leader>wq <Plug>VimwikiVSplitLink | |
map <Leader>wb <Plug>VimwikiGoBackLink | |
map <Leader>wn <Plug>VimwikiNextLink | |
map <Leader>wp <Plug>VimwikiPrevLink | |
map <Leader>wd <Plug>VimwikiDeleteLink | |
map <Leader>wr <Plug>VimwikiRenameLink | |
map <Leader>wm <Plug>VimwikiToggleListItem | |
"Calendar | |
map <Leader>wc :Calendar<CR> | |
" Window Navigation mappings. | |
noremap <C-j> <C-W>j | |
noremap <C-k> <C-W>k | |
noremap <C-h> <C-W>h | |
noremap <C-l> <C-W>l | |
noremap <C-c> <C-W>c | |
" If the ag executable is available, map it to the '\' key for performing file | |
" searches. | |
" Note: Look into using ag with ack.vim. | |
if executable("ag") | |
" We can map it to any character, such as \: | |
" Bind \ (backward slash) to grep shortcut. | |
" NOTE: This should be moved to the mappings section. | |
nnoremap \ :Ag<SPACE> | |
endif | |
" bind K to grep word under cursor | |
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR> | |
" Better folding commands. | |
" - <Space> Toggle current fold with spacebar. | |
" - zO: zO works better when recursively opening partial folds. | |
" - zk: Close (kill) all *other* folds (focus our current fold). | |
if has('folding') | |
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR> | |
nnoremap zO zczO | |
" nnoremap zk zMzvzz | |
endif | |
" When navigating searches, keep the current match centered in the middle of the | |
" screen. | |
noremap n nzz | |
noremap N Nzz | |
" Clear search term. | |
nnoremap <leader>c :let @/=""<CR> | |
" nnoremap <C-l> :nohlsearch<CR><C-l> | |
" nnoremap <silent> <Esc><Esc> :let @/=""<CR> | |
"Make Y like others | |
map Y y$ | |
" By default Vim jumps to the start of yanked/pasted text. This seems unnatural | |
" to me. These mappings cause us to jump to the end of the inserted text. | |
nnoremap p p`] | |
vnoremap y y`] | |
vnoremap p p`] | |
" Don't deselect blocks in visual mode when indenting/unindenting. | |
vnoremap > >gv | |
vnoremap < <gv | |
" Visual select a block of text that was just pasted. | |
vnoremap gV `[v`] | |
" Spell correct current word | |
" imap <c-z> <esc>,zea | |
if has("mouse") | |
" Better mouse pasting. | |
" nnoremap <RightMouse> "+p | |
" xnoremap <RightMouse> "+p | |
" inoremap <RightMouse> <C-r><C-o>+ | |
" cnoremap <RightMouse> <C-r>+ | |
" <2-LeftMouse> " Open fold, select word or % match. | |
" nnoremap <expr> <2-LeftMouse> | |
" \foldclosed(line('.')) == -1 ? "\<2-LeftMouse>" : 'zo' | |
endif | |
" Autocommands {{{1 | |
" | |
" - List current autocmds: `:autocmd`, `:verbose autocmd` | |
" - List current augroups: `:augroup` | |
" - List of available automd events: `:h autocmd-events` | |
" - List all filetypes: `:echo glob($VIMRUNTIME . '/ftplugin/*.vim')` | |
" | |
" - http://learnvimscriptthehardway.stevelosh.com/chapters/12.html | |
" - http://learnvimscriptthehardway.stevelosh.com/chapters/14.html | |
" - http://learnvimscriptthehardway.stevelosh.com/chapters/44.html | |
" - http://learnvimscriptthehardway.stevelosh.com/chapters/18.html | |
if has('autocmd') | |
" I constantly forget to turn on/off paste mode. Such a motherfucker. This at | |
" least disables it as soon we we leave insert mode. | |
augroup ag_nopaste | |
au! | |
" Clear paste mode when going back to normal mode | |
au InsertLeave * set nopaste | |
augroup END | |
" Some of my default settings are horrific when applied to 'non-editing' | |
" buffers - like the undo window, tagbar window, calendar window, etc. This | |
" automatically disables those features for those buffers. | |
augroup ag_noedit_buffers | |
au! | |
" Disable default 'editing' settings in non-editing buffers. | |
au FileType calendar,gundo,tagbar setlocal | |
\ nocursorcolumn nocursorline | |
\ scrolloff=0 sidescrolloff=0 | |
\ nohlsearch | |
\ virtualedit= | |
augroup END | |
augroup ag_vimrc | |
autocmd! | |
" Automatically reload our vimrc whenever we change it. | |
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | | |
\if has('gui_running') | so $MYGVIMRC | endif | :AirlineRefresh | |
augroup END | |
" Filetype detection for brewfile & caskfile. | |
augroup ag_brewfiles | |
au BufNewFile,BufRead brewfile set filetype=sh | |
au BufNewFile,BufRead caskfile set filetype=sh | |
augroup END | |
augroup ft_asm | |
au! | |
au FileType asm setlocal noet sw=8 ts=8 sts=8 tw=0 | |
augroup END | |
augroup ft_c | |
au! | |
au FileType c setlocal fdm=marker fmr={,} | |
augroup END | |
augroup ft_help | |
au! | |
au FileType help setlocal textwidth=80 | |
" Make helpdoc buffers fullscreen. Fuck yeah. | |
" au BufWinEnter *.txt if &ft == 'help' | wincmd o | endif | |
augroup END | |
" Make the textwidth *wider* for markdown files. Use 4 spaces for indentation. | |
augroup ft_markdown | |
au! | |
au FileType mkd setlocal et ts=4 sts=4 sw=4 tw=120 | |
\ colorcolumn=121 | |
augroup END | |
" | |
augroup ft_python | |
au! | |
au FileType python setlocal et ts=4 sts=4 sw=4 tw=80 | |
augroup END | |
augroup ft_shell | |
au! | |
au FileType sh setlocal tw=80 et ts=2 sts=2 sw=2 | |
\ colorcolumn=81 | |
augroup END | |
augroup ft_vim | |
au! | |
au FileType vim setlocal tw=80 et ts=2 sts=2 sw=2 fdm=marker | |
\ colorcolumn=81 | |
augroup END | |
augroup ft_zsh | |
au! | |
au FileType sh setlocal tw=80 et ts=2 sts=2 sw=2 | |
\ colorcolumn=81 | |
augroup END | |
endif | |
" }}}1 | |
" vim: set et ts=2 sts=2 sw=2 tw=80 fdm=marker: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment