Skip to content

Instantly share code, notes, and snippets.

@epsilonhalbe
Created June 4, 2012 10:24
Show Gist options
  • Save epsilonhalbe/2867645 to your computer and use it in GitHub Desktop.
Save epsilonhalbe/2867645 to your computer and use it in GitHub Desktop.
vim configuration file
" .vimrc
" OrigAuthor: Steve Losh <steve@stevelosh.com>
" OrigSource: http://bitbucket.org/sjl/dotfiles/src/tip/vim/
" Author: Martin Heuschober <epsilonhalbe@gmail.com>
" Source: http://http://github.com/epsilonhalbe/dotfiles/vimrc
"
" This file changes a lot. I'll try to document pieces of it whenever I have
" a few minutes to kill.
" Preamble ---------------------------------------------------------------- {{{
set nocompatible
filetype off
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
filetype plugin on
" }}}
" Basic options ----------------------------------------------------------- {{{
set encoding=utf-8
set modelines=0
" to see which indentation modes are set type in command mode
" verbose set ai? cin? cink? cino? si? inde? indk?
set noautoindent
set smartindent
set showmode
set showcmd
set hidden
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
"set number
set relativenumber
set statusline=
set statusline+=%f\ %2*%m\ %1*%h
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%{fugitive#statusline()}
set statusline+=%*
set laststatus=2
set history=1000
set undofile
set undoreload=10000
set cpoptions+=J
set list
set listchars=tab:%G▸%@\ ,eol:¬,extends:%G❯%@,precedes:%G❮%@,trail:.,nbsp:.
set shell=/bin/zsh
set lazyredraw
set matchtime=3
set showbreak=%G↪%@
set splitbelow
set splitright
set fillchars=diff:%G⣿%@
""set ttimeout
""set notimeout
""set nottimeout
set autowrite
set shiftround
set autoread
set title
set linebreak
"set dictionary=/usr/share/dict/words
set viminfo='10,\"100,:20,%,n~/.viminfo
set viminfo+=! " make sure it can save viminfo
set cf " enable error files and error jumping
set ffs=unix,dos,mac
set iskeyword+=_,$,@,%,#,-,ü,ä,ö,ß " none of these should be word dividers, so make them not be
set title " show title in xterm
""set shortmess=atI " shorten command-line text and other info tokens (see :help shortmess)
set nojoinspaces
" Wildmenu completion {{{
set wildmenu
set wildmode=list:longest
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc,*.log,*.idx " LaTeX intermediate files
set wildignore+=*_aux,*.glg,*.glo,*.gls,*.ist " LaTeX intermediate files
set wildignore+=*.nlo,*.nls,*.pdf,*.bbl,*.dvi " still LaTeX intermediate files
set wildignore+=*.ilg,*.fdb_latexmk,*.synctex.gz " $(B!D(B LaTeX intermediate files
set wildignore+=*.blg,*.ind " $(B!D!D!D(B LaTeX intermediate files
set wildignore+=*.hi " Haskell linker files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
" Clojure/Leiningen
set wildignore+=classes
set wildignore+=lib
" }}}
" Make Vim able to edit crontab files again.
set backupskip=/tmp/*,/private/tmp/*"
" Save when losing focus
au FocusLost * :wa
" Resize splits when the window is resized
au VimResized * exe "normal! \<c-w>="
" Line Return {{{
" Make sure Vim returns to the same line when you reopen a file.
" Thanks, Amit
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
" }}}
" Tabs, spaces, wrapping {{{
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set whichwrap+=<,>,h,l,[,]
set nowrap
set textwidth=80
"set formatoptions=qrn1
set formatoptions=tcrqn
set colorcolumn=+1
" Backups {{{
set undodir=~/.vim/tmp/undo// " undo files
" create undodir directory if possible and does not exist yet
let targetdir=$HOME . "/.vim/tmp/undo"
if isdirectory(targetdir) != 1 && getftype(targetdir) == "" && exists("*mkdir")
call mkdir(targetdir, "p", 0700)
endif
set backupdir=~/.vim/tmp/backup// " backups
" create undodir directory if possible and does not exist yet
let targetdir=$HOME . "/.vim/tmp/backup"
if isdirectory(targetdir) != 1 && getftype(targetdir) == "" && exists("*mkdir")
call mkdir(targetdir, "p", 0700)
endif
set directory=~/.vim/tmp/swap// " swap files
" create undodir directory if possible and does not exist yet
let targetdir=$HOME . "/.vim/tmp/swap"
if isdirectory(targetdir) != 1 && getftype(targetdir) == "" && exists("*mkdir")
call mkdir(targetdir, "p", 0700)
endif
set backup " enable backups
set noswapfile " It's 2012, Vim.
set makeef=error.err " When using make, where should it dump the file
" }}}
" Leader {{{
let mapleader = ";"
let maplocalleader ="\\"
inoremap :w <esc>
inoremap :{ <esc>:w<cr>
inoremap :} <esc>:w<cr>
" }}}
" Color scheme {{{
syntax on
if has("gui_running")
"set background=light " we are not using a dark background
"set background=dark " we are not using a light background
colorscheme xoria256
if (hostname() == 'wollnashorn')
set guifont=DejaVu\ Sans\ Mono\ 12
else
set guifont=DejaVu\ Sans\ Mono\ 10
endif
"set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
highlight Cursor guifg=black guibg=DarkOrange
highlight iCursor guifg=black guibg=Green
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait0
cnoreabbrev <expr> x getcmdtype() == ":" && getcmdline() == 'x' ? 'bd' : 'x'
cnoreabbrev <expr> q getcmdtype() == ":" && getcmdline() == 'q' ? 'bd' : 'q'
else
set t_Co=256
"set background=light " we are not using a light background
"set background=dark " we are not using a light background
colorscheme xoria256
"autocmd InsertEnter * highlight CursorLine ctermbg=23 ctermfg=None
" Revert Color to default when leaving Insert Mode
"autocmd InsertLeave * highlight CursorLine ctermbg=237 ctermfg=None
endif
if &term =~ "xterm\\|rxvt"
" use an orange cursor in insert mode
let &t_SI = "\<Esc>]12;green\x7"
" use a red cursor otherwise
let &t_EI = "\<Esc>]12;orange\x7"
silent !echo -ne "\033]12;orange\007"
" reset cursor when vim exits
autocmd VimLeave * silent !echo -ne "\033]12;white\007"
" use \003]12;gray\007 for gnome-terminal
endif
" Make trailing whitespace visible with ,s
nmap <silent> <leader>s :set nolist!<CR>
" Highlight trailing whitespace
highlight WhitespaceEOL term=standout ctermbg=DarkYellow guibg=DarkYellow
match WhitespaceEOL /\s\+$/
call matchadd('WhitespaceEOL', '\(\s\+$\| \+\ze\t\|\t\zs \+\)\(\%#\)\@!')
highlight ColorColumn guibg=Gray15 ctermbg=235
highlight CursorLine guibg=Gray23 ctermbg=235
" }}}
" Language and Spelling {{{
setlocal spelllang=en
highlight SpellBad term=reverse ctermbg=12 gui=undercurl guisp=Red " badly spelled word
highlight SpellCap term=reverse ctermbg=9 gui=undercurl guisp=Blue " word with wrong caps
highlight SpellRare term=reverse ctermbg=13 gui=undercurl guisp=Magenta " rare word
highlight SpellLocale term=underline ctermbg=11 gui=undercurl guisp=DarkCyan " word only exists in other region
" Ignore CamelCase words when spell checking
fun! IgnoreSpell()
syn match CamelCase /\<[A-Z][a-z]\+[A-Z].\{-}\>/ contains=@NoSpell transparent
syn cluster Spell add=CamelCase
syntax match InlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/ contains=@NoSpell transparent
syn cluster Spell add=InlineURL
endfun
"autocmd BufRead,BufNewFile * :call IgnoreSpell()
" }}}
function CheckRo()
if &readonly
set colorcolumn=0
endif
endfunction
au BufReadPost * call CheckRo()
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" }}}
" }}}
" Abbreviations ----------------------------------------------------------- {{{
function! EatChar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunction
function! MakeSpacelessIabbrev(from, to)
execute "iabbrev <silent> ".a:from." ".a:to."<C-R>=EatChar('\\s')<CR>"
endfunction
call MakeSpacelessIabbrev('sl/', 'http://stevelosh.com/')
call MakeSpacelessIabbrev('bb/', 'http://bitbucket.org/')
call MakeSpacelessIabbrev('bbs/', 'http://bitbucket.org/sjl/')
call MakeSpacelessIabbrev('gh/', 'http://github.com/')
call MakeSpacelessIabbrev('ghs/', 'http://github.com/sjl/')
iabbrev ldis %Gಠ%@_%Gಠ%@
iabbrev lsad %Gಥ%@_%Gಥ%@
iabbrev lhap %Gಥ‿ಥ%@
iabbrev sl@ steve@stevelosh.com
iabbrev vrcf `~/.vimrc` file
" Mistypes {{{
"iabbrev teh the
iabbrev lenght length
iabbrev Lenght Length
iabbrev persistant persistent
" conveniences
call MakeSpacelessIabbrev('.../', '$(B!D(B')
" }}}
" }}}
" Searching and movement -------------------------------------------------- {{{
" Use sane regexes.
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
"set gdefault
set scrolloff=3
set sidescroll=1
"set sidescrolloff=10
set virtualedit+=block
noremap <leader><space> :noh<cr>
noremap <leader><S-space> :call clearmatches()<cr>
"runtime macros/matchit.vim
"map <tab> % "i don't want it totally messes up vim snippets and % is not too hard a button to press
" Made D behave
nnoremap D d$
" Keep search matches in the middle of the window and pulse the line when moving
" to them.
nnoremap n nzzzv
nnoremap N Nzzzv
" Don't move on *
nnoremap * *<c-o>
" Same when jumping around
nnoremap g; g;zz
nnoremap g, g,zz
" Window resizing
nnoremap <c-left> 5<c-w>>
nnoremap <c-right> 5<c-w><
nnoremap <c-up> 5<c-w>+
nnoremap <c-down> 5<c-w>-
" Easier to type, and I never use the default behavior.
noremap H ^
noremap L g_
" Heresy
inoremap <c-a> <esc>I
inoremap <c-e> <esc>A
" Open a Quickfix window for the last search.
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" Ack for the last search.
nnoremap <silent> <leader>? :execute "Ack! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'"<CR>
" Fix linewise visual selection of various text objects
nnoremap VV V
nnoremap Vit vitVkoj
nnoremap Vat vatV
nnoremap Vab vabV
nnoremap VaB vaBV
" Error navigation {{{
"
" Location List QuickFix Window
" (e.g. Syntastic) (e.g. Ack)
" ----------------------------------
" Next | M-j M-Down |
" Previous | M-k M-Up |
" ----------------------------------
"
nnoremap %G∆%@ :lnext<cr>zvzz
nnoremap $(C"*(B :lprevious<cr>zvzz
inoremap %G∆%@ <esc>:lnext<cr>zvzz
inoremap $(C"*(B <esc>:lprevious<cr>zvzz
nnoremap <m-Down> :cnext<cr>zvzz
nnoremap <m-Up> :cprevious<cr>zvzz
" }}}
" Directional Keys {{{
" It's 2012.
noremap j gj
noremap k gk
" Easy buffer navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <leader>v <C-w>v
" }}}
" Highlight word {{{
nnoremap <silent> <leader>hh :execute 'match InterestingWord1 /\<<c-r><c-w>\>/'<cr>
nnoremap <silent> <leader>h1 :execute 'match InterestingWord1 /\<<c-r><c-w>\>/'<cr>
nnoremap <silent> <leader>h2 :execute '2match InterestingWord2 /\<<c-r><c-w>\>/'<cr>
nnoremap <silent> <leader>h3 :execute '3match InterestingWord3 /\<<c-r><c-w>\>/'<cr>
" }}}
" Visual Mode */# from Scrooloose {{{
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o>
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o>
" }}}
" }}}
" Folding ----------------------------------------------------------------- {{{
set foldlevelstart=2
set foldlevel=5
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" Make zO recursively open whatever top level fold we're in, no matter where the
" cursor happens to be.
"nnoremap zO zCzO
" Use ,z to "focus" the current fold.
nnoremap <leader>z zMzvzz
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = 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 . '$(B!D(B' . repeat(" ",fillcharcount) . foldedlinecount . '$(B!D(B' . ' '
endfunction " }}}
set foldtext=MyFoldText()
"highlight Folded guibg=Gray8 guifg=Gray ctermbg=235 ctermfg=0
" }}}
" Destroy infuriating keys ------------------------------------------------ {{{
" Fuck you, help key.
"noremap <F1> :set invfullscreen<CR>
"inoremap <F1> <ESC>:set invfullscreen<CR>a
cabbrev vhelp vert bo help
cabbrev thelp tab help
" Fuck you too, manual key.
"nnoremap K <nop>
" Stop it, hash key.
inoremap # X<BS>#
" }}}
" Various filetype-specific stuff ----------------------------------------- {{{
" C {{{
augroup ft_c
au!
au FileType c setlocal foldmethod=syntax
augroup END
" }}}
" Clojure {{{
let g:slimv_leader = '\'
let g:slimv_keybindings = 2
augroup ft_clojure
au!
au FileType clojure call TurnOnClojureFolding()
au FileType clojure compiler clojure
au FileType clojure setlocal report=100000
au FileType clojure nnoremap <buffer> o jI<cr><esc>kA
au FileType clojure nnoremap <buffer> O I<cr><esc>kA
au BufWinEnter Slimv.REPL.clj setlocal winfixwidth
au BufNewFile,BufRead Slimv.REPL.clj setlocal nowrap
au BufNewFile,BufRead Slimv.REPL.clj setlocal foldlevel=99
au BufNewFile,BufRead Slimv.REPL.clj nnoremap <buffer> A GA
au BufNewFile,BufRead Slimv.REPL.clj nnoremap <buffer> <localleader>R :emenu REPL.<Tab>
" Fix the eval mapping.
au FileType clojure nmap <buffer> \ee \ed
" Indent top-level form.
au FileType clojure nmap <buffer> <localleader>= v((((((((((((=%
" Use a swank command that works, and doesn't require new app windows.
"au FileType clojure let g:slimv_swank_cmd='!dtach -n /tmp/dtach-swank.sock -r winch lein swank'
augroup END
" }}}
" Confluence {{{
augroup ft_c
au!
au BufRead,BufNewFile *.confluencewiki setlocal filetype=confluencewiki
" Wiki pages should be soft-wrapped.
au FileType confluencewiki setlocal wrap linebreak nolist
augroup END
" }}}
" Cram {{{
let cram_fold=1
augroup ft_cram
au!
au BufNewFile,BufRead *.t set filetype=cram
au Syntax cram setlocal foldlevel=1
augroup END
" }}}
" CSS and LessCSS {{{
augroup ft_css
au!
au BufNewFile,BufRead *.less setlocal filetype=less
au Filetype less,css setlocal foldmethod=marker
au Filetype less,css setlocal foldmarker={,}
au Filetype less,css setlocal omnifunc=csscomplete#CompleteCSS
au Filetype less,css setlocal iskeyword+=-
" Use <leader>S to sort properties. Turns this:
"
" p {
" width: 200px;
" height: 100px;
" background: red;
"
" ...
" }
"
" into this:
" p {
" background: red;
" height: 100px;
" width: 200px;
"
" ...
" }
au BufNewFile,BufRead *.less,*.css nnoremap <buffer> <localleader>S ?{<CR>jV/\v^\s*\}?$<CR>k:sort<CR>:noh<CR>
" Make {<cr> insert a pair of brackets in such a way that the cursor is correctly
" positioned inside of them AND the following code doesn't get unfolded.
au BufNewFile,BufRead *.less,*.css inoremap <buffer> {<cr> {}<left><cr><space><space><space><space>.<cr><esc>kA<bs>
augroup END
" }}}
" Django {{{
augroup ft_django
au!
au BufNewFile,BufRead urls.py setlocal nowrap
au BufNewFile,BufRead urls.py normal! zR
au BufNewFile,BufRead dashboard.py normal! zR
au BufNewFile,BufRead local_settings.py normal! zR
au BufNewFile,BufRead admin.py setlocal filetype=python.django
au BufNewFile,BufRead urls.py setlocal filetype=python.django
au BufNewFile,BufRead models.py setlocal filetype=python.django
au BufNewFile,BufRead views.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal foldmethod=marker
au BufNewFile,BufRead forms.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal foldmethod=marker
augroup END
" }}}
" Firefox {{{
augroup ft_firefox
au!
au BufRead,BufNewFile ~/Library/Caches/*.html setlocal buftype=nofile
augroup END
" }}}
" Fish {{{
augroup ft_fish
au!
au BufNewFile,BufRead *.fish setlocal filetype=fish
augroup END
" }}}
" Haskell {{{
augroup ft_haskell
au!
au BufEnter *.hs compiler ghc
let g:htip_bindkeys=1
let b:lhs_markup = "tex"
let g:haskell_indent_if = 2
augroup END
" }}}
" HTML and HTMLDjango {{{
augroup ft_html
au!
au BufNewFile,BufRead *.html setlocal filetype=htmldjango
au FileType html,jinja,htmldjango setlocal foldmethod=manual
" Use <localleader>f to fold the current tag.
au FileType html,jinja,htmldjango nnoremap <buffer> <localleader>f Vatzf
" Use Shift-Return to turn this:
" <tag>|</tag>
"
" into this:
" <tag>
" |
" </tag>
au FileType html,jinja,htmldjango nnoremap <buffer> <s-cr> vit<esc>a<cr><esc>vito<esc>i<cr><esc>
" Smarter pasting
au FileType html,jinja,htmldjango nnoremap <buffer> p :<C-U>YRPaste 'p'<CR>v`]=`]
au FileType html,jinja,htmldjango nnoremap <buffer> P :<C-U>YRPaste 'P'<CR>v`]=`]
au FileType html,jinja,htmldjango nnoremap <buffer> -Fð :<C-U>YRPaste 'p'<CR>
au FileType html,jinja,htmldjango nnoremap <buffer> $(C"3(B :<C-U>YRPaste 'P'<CR>
" Indent tag
au FileType html,jinja,htmldjango nnoremap <buffer> <localleader>= Vat=
" Django tags
au FileType jinja,htmldjango inoremap <buffer> <c-t> {%<space><space>%}<left><left><left>
" Django variables
au FileType jinja,htmldjango inoremap <buffer> <c-f> {{<space><space>}}<left><left><left>
augroup END
" }}}
" Java {{{
augroup ft_java
au!
au FileType java setlocal foldmethod=marker
au FileType java setlocal foldmarker={,}
augroup END
" }}}
" Javascript {{{
augroup ft_javascript
au!
au FileType javascript setlocal foldmethod=marker
au FileType javascript setlocal foldmarker={,}
" Make {<cr> insert a pair of brackets in such a way that the cursor is correctly
" positioned inside of them AND the following code doesn't get unfolded.
au Filetype javascript inoremap <buffer> {<cr> {}<left><cr><space><space><space><space>.<cr><esc>kA<bs>
augroup END
" }}}
" LaTeX {{{
augroup ft_tex
au FileType tex setlocal spell
au FileType tex let b:delimitMate_matchpairs = "(:),[:],{:},<:>,-Y´:¡,¥:´,\\(:\\),%G⟨%@:%G⟩%@,%G❴%@:%G❵%@"
au FileType tex let b:delimitMate_quotes = "\" ' $"
command Tev ATP_TeXVerbos
"let g:showmarks_enable = 1
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
let g:indent_guides_indent_levels = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=Gray15 ctermbg=235
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=Gray14 ctermbg=236
let g:showmarks_enable=1
"au FileType tex setlocal foldmethod=marker foldmarker=\\begin\{,\\end\{
augroup END
"augroup ft_bib
"set tabstop=8
""set nolist
"" hi WhitespaceEOL NONE
"augroup END
" }}}
" Lisp {{{
augroup ft_lisp
au!
au FileType lisp call TurnOnLispFolding()
augroup END
" }}}
" Markdown {{{
augroup ft_markdown
au!
au BufNewFile,BufRead *.m*down setlocal filetype=markdown
" Use <localleader>1/2/3 to add headings.
au Filetype markdown nnoremap <buffer> <localleader>1 yypVr=
au Filetype markdown nnoremap <buffer> <localleader>2 yypVr-
au Filetype markdown nnoremap <buffer> <localleader>3 I### <ESC>
augroup END
" }}}
" Nginx {{{
augroup ft_nginx
au!
au BufRead,BufNewFile /etc/nginx/conf/* set ft=nginx
au BufRead,BufNewFile /etc/nginx/sites-available/* set ft=nginx
au BufRead,BufNewFile /usr/local/etc/nginx/sites-available/* set ft=nginx
au BufRead,BufNewFile vhost.nginx set ft=nginx
au FileType nginx setlocal foldmethod=marker foldmarker={,}
augroup END
" }}}
" OrgMode {{{
augroup ft_org
au!
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
"==============================================================
" THE UNNECESSARY STUFF"
"=============================================================
" Everything below here is a customization. None are needed.
"============================================================
" vars below are used to define default Todo list and
" default Tag list. Both of these can also be defined
" on a document-specific basis by config lines in a file.
" See :h vimorg-todo-metadata and/or :h vimorg-tag-metadata
" 'TODO | DONE' is the default,so not really necessary to define it at all
let g:org_todo_setup='TODO | DONE'
" OR, e.g.,:
"let g:org_todo_setup='TODO NEXT STARTED | DONE CANCELED'
" include a tags setup string if you want:
let g:org_tags_alist='{@home(h) @work(w)} {easy(e) hard(d)} {computer(c) phone(p)}'
"
" g:org_agenda_dirs specify directories that, along with
" their subtrees, are searched for list of .org files when
" accessing EditAgendaFiles(). Specify your own here, otherwise
" default will be for g:org_agenda_dirs to hold single
" directory which is directory of the first .org file opened
" in current Vim instance:
" Below is line I use in my Windows install:
" NOTE: case sensitive even on windows.
let g:org_agenda_select_dirs=["~/org"]
let g:org_agenda_files = split(glob("~/org/org-mod*.org"),"\n")
" ---------------------
" Emacs setup
" --------------------
" To use Emacs you will need to define the client. On
" Linux/OSX this is typically simple, just:
"let g:org_command_for_emacsclient = 'emacsclient'
"
"On Windows it is more complicated, and probably involves creating
" a 'soft link' to the emacsclient executable (which is 'emacsclientw')
" See :h vimorg-emacs-setup
"let g:org_command_for_emacsclient = 'c:\users\herbert\emacsclientw.exe'
" ---------------------
" Custom Agenda Searches
" --------------------
" the assignment to g:org_custom_searches below defines searches that a
" a user can then easily access from the Org menu or the Agenda Dashboard.
" (Still need to add help on how to define them, assignment below
" is hopefully illustrative for now. . . . )
let g:org_custom_searches = [
\ { 'name':"Next week's agenda", 'type':'agenda',
\ 'agenda_date':'+1w','agenda_duration':'w'}
\, { 'name':"Next week's TODOS", 'type':'agenda',
\ 'agenda_date':'+1w','agenda_duration':'w','spec':'+UNFINISHED_TODOS'}
\, { 'name':'Home tags', 'type':'heading_list', 'spec':'+HOME'}
\, { 'name':'Home tags', 'type':'sparse_tree', 'spec':'+HOME'}
\ ]
" --------------------------------
" Custom colors
" --------------------------------"
" OrgCustomColors() allows a user to set highlighting for particular items
function! OrgCustomColors()
" various text item "highlightings" are below
" these are the defaults. Uncomment and change a line if you
" want different highlighting for the element
"
" below are defaults for any TODOS you define. TODOS that
" come before the | in a definition will use 'NOTDONETODO'
" and those that come after are DONETODO
"hi! DONETODO guifg=green ctermfg=green
"hi! NOTDONETODO guifg=red ctermfg=lightred
" heading level highlighting is done in pairs, one for the
" heading when unfoled and one for folded. Default is to make
" them the same except for the folded version being bold:
" assign OL1 pair for level 1, OL2 pair for level 2, etc.
"hi! OL1 guifg=somecolor guibg=somecolor
"hi! OL1Folded guifg=somecolor guibg=somecolor gui=bold
" tags are lines below headings that have :colon:separated:tags:
hi! Org_Tag guifg=lightgreen ctermfg=blue
" lines that begin with '#+' in column 0 are config lines
"hi! Org_Config_Line guifg=darkgray ctermfg=magenta
"drawers are :PROPERTIES: and :LOGBOOK: lines and their associated
" :END: lines
"hi! Org_Drawer guifg=pink ctermfg=magenta
"hi! Org_Drawer_Folded guifg=pink ctermfg=magenta gui=bold cterm=bold
" this applies to value names in :PROPERTIES: blocks
"hi! Org_Property_Value guifg=pink ctermfg=magenta
" three lines below apply to different kinds of blocks
"hi! Org_Block guifg=#555555 ctermfg=magenta
"hi! Org_Src_Block guifg=#555555 ctermfg=magenta
"hi! Org_Table guifg=#888888 guibg=#333333 ctermfg=magenta
" dates are date specs between angle brackets (<>) or square brackets ([])
"hi! Org_Date guifg=magenta ctermfg=magenta gui=underline cterm=underline
" Org_Star is used to "hide" initial asterisks in a heading
hi! Org_Star guifg=#1c1c1c ctermfg=234
"hi! Props guifg=#ffa0a0 ctermfg=gray
" bold, itals, underline, and code are highlights applied
" to character formatting
"hi! Org_Code guifg=darkgray gui=bold ctermfg=14
"hi! Org_Itals gui=italic guifg=#aaaaaa ctermfg=lightgray
"hi! Org_Bold gui=bold guifg=#aaaaaa ctermfg=lightgray
"hi! Org_Underline gui=underline guifg=#aaaaaa ctermfg=lightgray
"hi! Org_Lnumber guifg=#999999 ctermfg=gray
" these lines apply to links: [[link]], and [[link][link desc]]
"if has("conceal")
" hi! default linkends guifg=blue ctermfg=blue
"endif
"hi! Org_Full_Link guifg=cyan gui=underline ctermfg=lightblue cterm=underline
"hi! Org_Half_Link guifg=cyan gui=underline ctermfg=lightblue cterm=underline
" applies to the Heading line that can be displayed in column view
"highlight OrgColumnHeadings guibg=#444444 guifg=#aaaaaa gui=underline
" Use g:org_todo_custom_highlights to set up highlighting for individual
" TODO items. Without this all todos that designate an uninished state
" will be highlighted using NOTDONETODO highlight (see above)
" and all todos that designate a finished state will be highlighted using
" the DONETODO highlight (see above).
let g:org_todo_custom_highlights =
\ { 'NEXT': { 'guifg':'#888888', 'guibg':'#222222',
\ 'ctermfg':'gray', 'ctermbg':'darkgray'},
\ 'WAITING': { 'guifg':'#aa3388',
\ 'ctermfg':'red' } }
endfunction
" below are two examples of Org-mode "hook" functions
" These present opportunities for end-user customization
" of how VimOrganizer works. For more info see the
" documentation for hooks in Emacs' Org-mode documentation:
" http://orgmode.org/worg/org-configs/org-hooks.php#sec-1_40
"
" These two hooks are currently the only ones enabled in
" the VimOrganizer codebase, but they are easy to add so if
" there's a particular hook you want go ahead and request it
" or look for where these hooks are implemented in
" /ftplugin/org.vim and use them as example for placing your
" own hooks in VimOrganizer:
function! Org_property_changed_functions(line,key, val)
"call confirm("prop changed: ".a:line."--key:".a:key." val:".a:val)
endfunction
function! Org_after_todo_state_change_hook(line,state1, state2)
"call confirm("changed: ".a:line."--key:".a:state1." val:".a:state2)
"call OrgConfirmDrawer("LOGBOOK")
"let str = ": - State: " . org#Pad(a:state2,10) . " from: " . Pad(a:state1,10) .
" \ ' [' . org#Timestamp() . ']'
"call append(line("."), repeat(' ',len(matchstr(getline(line(".")),'^\s*'))) . str)
endfunction
au Filetype org nmap <buffer> Q vahjgq
au Filetype org setlocal textwidth=0
au Filetype org setlocal guifont=DejaVu\ Sans\ Mono\ 20
let g:org_plugins = ['ShowHide', '|', 'Navigator', 'EditStructure', '|', 'Todo', 'Date', 'Misc']
let g:org_todo_keywords = ['TODO', '|', 'DONE']
let g:org_debug = 1
augroup END
" }}}
" Pentadactyl {{{
augroup ft_pentadactyl
au!
au BufNewFile,BufRead .pentadactylrc set filetype=pentadactyl
au BufNewFile,BufRead ~/Library/Caches/TemporaryItems/pentadactyl-*.tmp set nolist wrap linebreak columns=100 colorcolumn=0
augroup END
" }}}
" Puppet {{{
augroup ft_puppet
au!
au Filetype puppet setlocal foldmethod=marker
au Filetype puppet setlocal foldmarker={,}
augroup END
" }}}
" Python {{{
augroup ft_python
au!
" au FileType python setlocal omnifunc=pythoncomplete#Complete
au FileType python setlocal define=^\s*\\(def\\\\|class\\)
au FileType python compiler nose
au FileType man nnoremap <buffer> <cr> :q<cr>
" Jesus tapdancing Christ, built-in Python syntax, you couldn't let me
" override this in a normal way, could you?
au FileType python if exists("python_space_error_highlight") | unlet python_space_error_highlight | endif
" Jesus, Python. Five characters of punctuation for a damn string?
au FileType python inoremap <buffer> <d-'> _(u'')<left><left>
augroup END
" }}}
" QuickFix {{{
augroup ft_quickfix
au!
au Filetype qf setlocal colorcolumn=0 nolist nocursorline nowrap
augroup END
" }}}
" ReStructuredText {{{
augroup ft_rest
au!
au Filetype rst nnoremap <buffer> <localleader>1 yypVr=
au Filetype rst nnoremap <buffer> <localleader>2 yypVr-
au Filetype rst nnoremap <buffer> <localleader>3 yypVr~
au Filetype rst nnoremap <buffer> <localleader>4 yypVr`
augroup END
" }}}
" Ruby {{{
augroup ft_ruby
au!
au Filetype ruby setlocal foldmethod=syntax
autocmd FileType ruby set omnifunc=rubycomplete#Complete
" ... and Rails
autocmd FileType ruby let g:rubycomplete_rails = 1
" ... and to include Classes in global completions
autocmd FileType ruby let g:rubycomplete_classes_in_global = 1
" Thorfile, Rakefile and Gemfile are Ruby
augroup END
" }}}
" Vagrant {{{
augroup ft_vagrant
au!
au BufRead,BufNewFile Vagrantfile set ft=ruby
augroup END
" }}}
" Vim {{{
augroup ft_vim
au!
au FileType vim setlocal foldmethod=marker
au FileType help setlocal textwidth=78
au BufWinEnter *.txt if &ft == 'help' | wincmd J | endif
augroup END
" }}}
" }}}
" Quick editing ----------------------------------------------------------- {{{
nnoremap <leader>vv <C-w>s<C-w>j:e $MYVIMRC<cr>
nnoremap <leader>vs <C-w>s<C-w>j:e ~/.vim/bundle/ultisnips/UltiSnips/<cr>
nnoremap <leader>vu <C-w>s<C-w>j:e ~/.vim/ftplugin/tex/unilatex.vim<cr>
nnoremap <leader>vo <C-w>s<C-w>j:e ~/org<cr>4j
nnoremap <leader>vx <C-w>s<C-w>j:e ~/.xmonad/xmonad.hs<cr>
nnoremap <leader>ev :e $MYVIMRC<cr>
nnoremap <leader>es :e ~/.vim/bundle/ultisnips/UltiSnips/<cr>
nnoremap <leader>eu :e ~/.vim/ftplugin/tex/unilatex.vim<cr>
nnoremap <leader>eo :e ~/org<cr>4j
nnoremap <leader>ex :e ~/.xmonad/xmonad.hs<cr>
nnoremap <leader>tv :tabe $MYVIMRC<cr>
nnoremap <leader>ts :tabe ~/.vim/bundle/ultisnips/UltiSnips/<cr>
nnoremap <leader>tu :tabe ~/.vim/ftplugin/tex/unilatex.vim<cr>
nnoremap <leader>to :tabe ~/org<cr>4j
nnoremap <leader>tx :tabe ~/.xmonad/xmonad.hs<cr>
"nnoremap <leader>eh <C-w>s<C-w>j:e ~/.hgrc<cr>
"nnoremap <leader>em <C-w>s<C-w>j:e ~/.mutt/muttrc<cr>
"nnoremap <leader>ez <C-w>s<C-w>j:e ~/lib/dotfiles/zsh<cr>4j
"nnoremap <leader>ek <C-w>s<C-w>j:e ~/lib/dotfiles/keymando/keymandorc.rb<cr>
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
map <Leader>t :tabe <C-R>=expand("%:p:h") . "/" <CR>
" }}}
" Shell ------------------------------------------------------------------- {{{
function! s:ExecuteInShell(command) " {{{
let command = join(map(split(a:command), 'expand(v:val)'))
let winnr = bufwinnr('^' . command . '$')
silent! execute winnr < 0 ? 'botright vnew ' . fnameescape(command) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap nonumber
echo 'Execute ' . command . '...'
silent! execute 'silent %!'. command
silent! redraw
silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>:AnsiEsc<CR>'
silent! execute 'nnoremap <silent> <buffer> q :q<CR>'
silent! execute 'AnsiEsc'
echo 'Shell command ' . command . ' executed.'
endfunction " }}}
command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>)
nnoremap <leader>! :Shell
" }}}
" Convenience mappings ---------------------------------------------------- {{{
" sane <esc> function!
"inoremap <silent> <Esc> <Esc>`^
"inoremap <silent> <Esc> <C-O>:stopinsert<CR>
" Clean trailing whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<cr>
" Send visual selection to gist.github.com as a private, filetyped Gist
" Requires the gist command line too (brew install gist)
vnoremap <leader>G :w !gist -p -t %:e \| pbcopy<cr>
" Change case
nnoremap <C-u> gUiw
inoremap <C-u> <esc>gUiwea
nnoremap <C-y> guiw
inoremap <C-y> <esc>guiwea
" insert newline and stay normal (inserting is not that hard)
nnoremap o o<esc>
nnoremap O O<esc>
" inserting a single letter
function! RepeatChar(char, count)
return repeat(a:char, a:count)
endfunction
nnoremap s :<C-U>exec "normal i".RepeatChar(nr2char(getchar()), v:count1)<CR>
nnoremap -Fó :<C-U>exec "normal a".RepeatChar(nr2char(getchar()), v:count1)<CR>
" Substitute
nnoremap <leader>s :%s//<left>
" fooo eai u aui eai u
" fooo:eai:u:aui:eai:u
vnoremap <leader>: :s/\%V\ /:/g<cr>
" Emacs bindings in command line mode
cnoremap <c-a> <home>
cnoremap <c-e> <end>
" Diffoff
nnoremap <leader>D :diffoff!<cr>
" Yankring
nnoremap <silent> <F11> :YRShow<cr>
" Formatting, TextMate-style
set formatprg=par\ -w80r
nnoremap Q gqip
vnoremap F JAa<esc>x^$
" Easier linewise reselection: selects the previously pasted (to indent $(B!D(B)
nnoremap <leader>V V`]
" Indenting visual blocks
vnoremap > ><C-v>']$
vnoremap < <<C-v>']$
" Split line (sister to [J]oin lines)
" The normal use of S is covered by cc, so don't worry about shadowing it.
nnoremap S i<cr><esc><right>
nnoremap <silent> J :let p=getpos('.')<bar>join<bar>call setpos('.', p)<cr>
" HTML tag closing
inoremap <C-_> <Space><BS><Esc>:call InsertCloseTag()<cr>a
" Align text
nnoremap <leader>Al :left<cr>
nnoremap <leader>Ac :center<cr>
nnoremap <leader>Ar :right<cr>
vnoremap <leader>Al :left<cr>
vnoremap <leader>Ac :center<cr>
vnoremap <leader>Ar :right<cr>
" Less chording
"nnoremap ; :
" Cmdheight switching
nnoremap <leader>1 :set cmdheight=1<cr>
nnoremap <leader>2 :set cmdheight=2<cr>
" Source sources current line/selection
vnoremap <leader>S y:execute @@<cr>
nnoremap <leader>S ^vg_y:execute @@<cr>
" Replaste
nnoremap <D-p> "_ddPV`]=
" Marks and Quotes
noremap ' `
noremap -Aæ '
noremap ` <C-^>
" Select (charwise) the contents of the current line, excluding indentation.
" Great for pasting Python lines into REPLs.
nnoremap vv ^vg_
" Calculator
inoremap <C-B> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
" Better Completion
set completeopt=longest,menuone,preview
" Sudo to write
cmap w!! w !sudo tee % >/dev/null
" I suck at typing.
nnoremap <localleader>= ==
vnoremap - =
" Easy filetype switching {{{
nnoremap _md :set ft=markdown<CR>
nnoremap _hd :set ft=htmldjango<CR>
nnoremap _jt :set ft=htmljinja<CR>
nnoremap _cw :set ft=confluencewiki<CR>
nnoremap _pd :set ft=python.django<CR>
nnoremap _d :set ft=diff<CR>
" }}}
" Toggle paste
set pastetoggle=<F8>
" Quickreturn
inoremap <c-cr> <esc>A<cr>
inoremap <s-cr> <esc>A:<cr>
" Block Colors {{{
let g:blockcolor_state = 0
function! BlockColor() " {{{
if g:blockcolor_state
let g:blockcolor_state = 0
call matchdelete(77880)
call matchdelete(77881)
call matchdelete(77882)
call matchdelete(77883)
else
let g:blockcolor_state = 1
call matchadd("BlockColor1", '^ \{4}.*', 1, 77880)
call matchadd("BlockColor2", '^ \{8}.*', 2, 77881)
call matchadd("BlockColor3", '^ \{12}.*', 3, 77882)
call matchadd("BlockColor4", '^ \{16}.*', 4, 77883)
endif
endfunction " }}}
nnoremap <leader>B :call BlockColor()<cr>
" }}}
" Insert Mode Completion {{{
inoremap <c-l> <c-x><c-l>
inoremap <c-f> <c-x><c-f>
" }}}
" }}}
" Training mappings ------------------------------------------------------- {{{
" Use L, dammit.
nnoremap Ajk <nop>
nnoremap A<esc> <nop>
"nnoremap <cr> <nop>
" }}}
" CTags ------------------------------------------------------------------- {{{
" For some reason ctags refuses to ignore Python variables, so I'll just hack
" the tags file with sed and strip them out myself.
"
" Sigh.
nnoremap <leader><cr> :silent !/usr/local/bin/ctags -R . && sed -i .bak -E -e '/^[^ ]+ [^ ]+.py .+v$/d' tags<cr>
" }}}
" Plugin settings --------------------------------------------------------- {{{
" Ack {{{
map <leader>a :Ack!
let g:ackprg="ack -H --nocolor --nogroup --column"
" }}}
" Autoclose {{{
nmap <Leader>x <Plug>ToggleAutoCloseMappings
" }}}
" Commentary {{{
nmap <leader>c <Plug>CommentaryLine
xmap <leader>c <Plug>Commentary
au FileType htmldjango setlocal commentstring={#\ %s\ #}
" }}}
" TagBar {{{
autocmd BufWinEnter *.py,*.c nested TagbarOpen "open tagbar on certain filetypes
nnoremap <silent> <F9> :TagbarToggle<CR>
let g:tagbar_type_tex = {
\ 'ctagstype' : 'latex',
\ 'kinds' : [
\ 'c:chapters',
\ 's:sections',
\ 'u:subsections',
\ 'b:subsubsections',
\ 'g:graphics',
\ 'l:labels',
\ 'r:refs:1',
\ 'L:listings',
\ 'p:pagerefs:1'
\ ],
\ 'sort' : 0,
\ }
" }}}
" Ctrl-P {{{
let g:ctrlp_map = '<leader>,'
let g:ctrlp_working_path_mode = 0
let g:ctrlp_match_window_reversed = 1
let g:ctrlp_split_window = 0
let g:ctrlp_max_height = 20
let g:ctrlp_prompt_mappings = {
\ 'PrtSelectMove("j")': ['<c-j>', '<down>', '<s-tab>'],
\ 'PrtSelectMove("k")': ['<c-k>', '<up>', '<tab>'],
\ 'PrtHistory(-1)': ['<c-n>'],
\ 'PrtHistory(1)': ['<c-p>'],
\ 'ToggleFocus()': ['<c-tab>'],
\ }
let g:ctrlp_extensions = ['tag']
nnoremap <leader>. :CtrlPTag<cr>
" }}}
" Easymotion {{{
let g:EasyMotion_do_mapping = 0
nnoremap <silent> <Leader>f :call EasyMotionF(0, 0)<CR>
onoremap <silent> <Leader>f :call EasyMotionF(0, 0)<CR>
vnoremap <silent> <Leader>f :<C-U>call EasyMotionF(1, 0)<CR>
nnoremap <silent> <Leader>F :call EasyMotionF(0, 1)<CR>
onoremap <silent> <Leader>F :call EasyMotionF(0, 1)<CR>
vnoremap <silent> <Leader>F :<C-U>call EasyMotionF(1, 1)<CR>
onoremap <silent> <Leader>t :call EasyMotionT(0, 0)<CR>
onoremap <silent> <Leader>T :call EasyMotionT(0, 1)<CR>
" }}}
" Fugitive {{{
nnoremap <leader>gd :Gdiff<cr>
nnoremap <leader>gs :Gstatus<cr>
nnoremap <leader>gw :Gwrite<cr>
nnoremap <leader>ga :Gadd<cr>
nnoremap <leader>gb :Gblame<cr>
nnoremap <leader>gco :Gcheckout<cr>
nnoremap <leader>gci :Gcommit<cr>
nnoremap <leader>gm :Gmove<cr>
nnoremap <leader>gr :Gremove<cr>
nnoremap <leader>gl :Shell git gl -18<cr>:wincmd \|<cr>
augroup ft_fugitive
au!
au BufNewFile,BufRead .git/index setlocal nolist
augroup END
" "Hub"
nnoremap <leader>H :Gbrowse<cr>
vnoremap <leader>H :Gbrowse<cr>
" }}}
" Gundo {{{
nnoremap <F5> :GundoToggle<CR>
let g:gundo_debug = 1
let g:gundo_preview_bottom = 1
" }}}
" Haskellmode {{{
let g:haddock_browser = "/usr/bin/opera"
let g:haddock_browser_callformat = "%s %s"
let g:ghc = "/usr/bin/ghc"
" }}}
" HTML5 {{{
let g:event_handler_attributes_complete = 0
let g:rdfa_attributes_complete = 0
let g:microdata_attributes_complete = 0
let g:atia_attributes_complete = 0
" }}}
" Linediff {{{
vnoremap <leader>l :Linediff<cr>
nnoremap <leader>L :LinediffReset<cr>
" }}}
" Lisp (built-in) {{{
let g:lisp_rainbow = 1
" }}}
" Makegreen {{{
"nnoremap \| :call MakeGreen('')<cr>
" }}}
" NEOComplCache {{{
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : '',
\ }
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
imap <C-k> <Plug>(neocomplcache_snippets_expand)
smap <C-k> <Plug>(neocomplcache_snippets_expand)
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
" SuperTab like snippets behavior.
"imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
" Recommended key-mappings.
"<CR>: close popup and save indent.
inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()
" AutoComplPop like behavior.
let g:neocomplcache_enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<TAB>"
"inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" Enable omni completion.
"autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
"autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
"autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
"autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
"if !exists('g:neocomplcache_omni_patterns')
" let g:neocomplcache_omni_patterns = {}
"endif
"let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
""autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
"let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
"let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
"}}}
" NERD Tree {{{
noremap <F2> :NERDTreeToggle<cr>
inoremap <F2> <esc>:NERDTreeToggle<cr>
au Filetype nerdtree setlocal nolist
let NERDTreeHighlightCursorline=1
let NERDTreeIgnore=['.vim$', '\~$', '.*\.pyc$', 'pip-log\.txt$', 'whoosh_index', 'xapian_index', '.*.pid', 'monitor.py', '.*-fixtures-.*.json', '.*\.o$', 'db.db']
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" }}}
" Powerline {{{
let g:Powerline_symbols = 'fancy'
" }}}
" Python-Mode {{{
let g:pymode_doc = 1
let g:pymode_doc_key = '<localleader>ds'
let g:pydoc = 'pydoc'
let g:pymode_syntax = 0
let g:pymode_run = 0
let g:pymode_lint = 0
let g:pymode_breakpoint = 0
let g:pymode_utils_whitespaces = 0
let g:pymode_virtualenv = 0
let g:pymode_options_indent = 0
let g:pymode_options_fold = 0
let g:pymode_options_other = 0
let g:pymode_rope = 1
let g:pymode_rope_global_prefix = "<localleader>R"
let g:pymode_rope_local_prefix = "<localleader>r"
let g:pymode_rope_auto_project = 1
let g:pymode_rope_enable_autoimport = 0
let g:pymode_rope_autoimport_generate = 1
let g:pymode_rope_autoimport_underlineds = 0
let g:pymode_rope_codeassist_maxfixes = 10
let g:pymode_rope_sorted_completions = 1
let g:pymode_rope_extended_complete = 1
let g:pymode_rope_autoimport_modules = ["os", "shutil", "datetime"]
let g:pymode_rope_confirm_saving = 1
let g:pymode_rope_vim_completion = 1
let g:pymode_rope_guess_project = 1
let g:pymode_rope_goto_def_newwin = 0
let g:pymode_rope_always_show_complete_menu = 0
" }}}
" Rainbox Parentheses {{{
nnoremap <leader>R :SeeParentheses<cr>
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
command! SeeParentheses call SeeParentheses()
function! SeeParentheses() " {{{
if exists("b:see_parens")
unlet b:see_parens
set syntax=on
highlight SpellBad term=reverse ctermbg=12 gui=undercurl guisp=Red
else
set syntax=off
highlight SpellBad term=none ctermbg=12 gui=none guisp=Red
let b:see_parens= 1
endif
endfunction " }}}
" }}}
" Scratch {{{
command! ScratchToggle call ScratchToggle()
function! ScratchToggle() " {{{
if exists("w:is_scratch_window")
unlet w:is_scratch_window
exec "q"
else
exec "normal! :Sscratch\<cr>\<C-W>J:resize 13\<cr>"
let w:is_scratch_window = 1
endif
endfunction " }}}
nnoremap <silent> <leader><tab> :ScratchToggle<cr>
" }}}
" ShowMarks {{{
let g:showmarks_enable = 0
let g:showmarks_ignore_type="hmpqr"
" }}}
" SLIMV {{{
"let g:slimv_lisp = '"java -cp `lein classpath` clojure.main"'
let g:slimv_repl_split = 4
let g:slimv_repl_syntax = 1
" }}}}
" Sparkup {{{
let g:sparkupNextMapping = '<c-s>'
"}}}
" Syntastic {{{
let g:syntastic_enable_signs = 1
"let g:syntastic_disabled_filetypes = ['html']
"let g:syntastic_stl_format = '[%E{%e Errors}%B{, }%W{%w Warnings}]'
let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'
"let g:syntastic_jsl_conf = '$HOME/.vim/jsl.conf'
" }}}
" Threesome {{{
let g:threesome_leader = "-"
let g:threesome_initial_mode = "grid"
let g:threesome_initial_layout_grid = 1
let g:threesome_initial_layout_loupe = 0
let g:threesome_initial_layout_compare = 0
let g:threesome_initial_layout_path = 0
let g:threesome_initial_diff_grid = 1
let g:threesome_initial_diff_loupe = 0
let g:threesome_initial_diff_compare = 0
let g:threesome_initial_diff_path = 0
let g:threesome_initial_scrollbind_grid = 0
let g:threesome_initial_scrollbind_loupe = 0
let g:threesome_initial_scrollbind_compare = 0
let g:threesome_initial_scrollbind_path = 0
let g:threesome_wrap = "nowrap"
" }}}
" UltiSnip {{{
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" }}}
" VimClojure {{{
let vimclojure#HighlightBuiltins = 1
let vimclojure#ParenRainbow = 1
let vimclojure#WantNailgun = 0
" }}}
" YankRing {{{
function! YRRunAfterMaps()
nnoremap Y :<C-U>YRYankCount 'y$'<CR>
omap <expr> L YRMapsExpression("", "$")
omap <expr> H YRMapsExpression("", "^")
endfunction
" }}}
" }}}
" Text objects ------------------------------------------------------------ {{{
" Shortcut for [] {{{
onoremap id i[
onoremap ad a[
vnoremap id i[
vnoremap ad a[
" }}}
" Next and Last {{{
" Motion for "next/last object". For example, "din(" would go to the next "()"
" pair and delete its contents.
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
onoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
xnoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
function! s:NextTextObject(motion, dir)
let c = nr2char(getchar())
if c ==# "b"
let c = "("
elseif c ==# "B"
let c = "{"
elseif c ==# "d"
let c = "["
endif
exe "normal! ".a:dir.c."v".a:motion.c
endfunction
" }}}
" }}}
" Ack motions ------------------------------------------------------------- {{{
" Motions to Ack for things. Works with pretty much everything, including:
"
" w, W, e, E, b, B, t*, f*, i*, a*, and custom text objects
"
" Awesome.
"
" Note: If the text covered by a motion contains a newline it won't work. Ack
" searches line-by-line.
nnoremap <silent> \a :set opfunc=<SID>AckMotion<CR>g@
xnoremap <silent> \a :<C-U>call <SID>AckMotion(visualmode())<CR>
function! s:CopyMotionForType(type)
if a:type ==# 'v'
silent execute "normal! `<" . a:type . "`>y"
elseif a:type ==# 'char'
silent execute "normal! `[v`]y"
endif
endfunction
function! s:AckMotion(type) abort
let reg_save = @@
call s:CopyMotionForType(a:type)
execute "normal! :Ack! --literal " . shellescape(@@) . "\<cr>"
let @@ = reg_save
endfunction
" }}}
" Error toggles ----------------------------------------------------------- {{{
command! ErrorsToggle call ErrorsToggle()
function! ErrorsToggle() " {{{
if exists("w:is_error_window")
unlet w:is_error_window
exec "q"
else
exec "Errors"
lopen
let w:is_error_window = 1
endif
endfunction " }}}
command! -bang -nargs=? QFixToggle call QFixToggle(<bang>0)
function! QFixToggle(forced) " {{{
if exists("g:qfix_win") && a:forced == 0
cclose
unlet g:qfix_win
else
copen 10
let g:qfix_win = bufnr("$")
endif
endfunction " }}}
nmap <silent> <F3> :ErrorsToggle<cr>
noremap <silent> <F1> :QFixToggle<cr>
" }}}
" Utils ------------------------------------------------------------------- {{{
function! g:echodammit(msg)
exec 'echom "----------> ' . a:msg . '"'
endfunction
" Synstack {{{
" Show the stack of syntax highlighting classes affecting whatever is under the
" cursor.
function! SynStack() "{{{
echo join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), " > ")
endfunc "}}}
nnoremap ß :call SynStack()<CR>
" }}}
" Toggle whitespace in diffs {{{
set diffopt-=iwhite
let g:diffwhitespaceon = 1
function! ToggleDiffWhitespace() "{{{
if g:diffwhitespaceon
set diffopt-=iwhite
let g:diffwhitespaceon = 0
else
set diffopt+=iwhite
let g:diffwhitespaceon = 1
endif
diffupdate
endfunc "}}}
nnoremap <leader>dw :call ToggleDiffWhitespace()<CR>
" }}}
" }}}
" Hg ---------------------------------------------------------------------- {{{
function! s:HgDiff()
diffthis
let fn = expand('%:p')
let ft = &ft
wincmd v
edit __hgdiff_orig__
setlocal buftype=nofile
normal ggdG
execute "silent r!hg cat --rev . " . fn
normal ggdd
execute "setlocal ft=" . ft
diffthis
diffupdate
endf
command! -nargs=0 HgDiff call s:HgDiff()
nnoremap <leader>hd :HgDiff<cr>
function! s:HgBlame()
let fn = expand('%:p')
wincmd v
wincmd h
edit __hgblame__
vertical resize 28
setlocal scrollbind winfixwidth nolist nowrap nonumber buftype=nofile ft=none
normal ggdG
execute "silent r!hg blame -undq " . fn
normal ggdd
execute ':%s/\v:.*$//'
wincmd l
setlocal scrollbind
syncbind
endf
command! -nargs=0 HgBlame call s:HgBlame()
nnoremap <leader>hb :HgBlame<cr>
" }}}
" Nyan! ------------------------------------------------------------------- {{{
function! NyanMe() " {{{
hi NyanFur guifg=#BBBBBB
hi NyanPoptartEdge guifg=#ffd0ac
hi NyanPoptartFrosting guifg=#fd3699 guibg=#fe98ff
hi NyanRainbow1 guifg=#6831f8
hi NyanRainbow2 guifg=#0099fc
hi NyanRainbow3 guifg=#3cfa04
hi NyanRainbow4 guifg=#fdfe00
hi NyanRainbow5 guifg=#fc9d00
hi NyanRainbow6 guifg=#fe0000
echohl NyanRainbow1
echon ""
echohl NyanRainbow2
echon "%G≋%@"
echohl NyanRainbow3
echon ""
echohl NyanRainbow4
echon "%G≋%@"
echohl NyanRainbow5
echon ""
echohl NyanRainbow6
echon "%G≋%@"
echohl NyanRainbow1
echon ""
echohl NyanRainbow2
echon "%G≋%@"
echohl NyanRainbow3
echon ""
echohl NyanRainbow4
echon "%G≋%@"
echohl NyanRainbow5
echon ""
echohl NyanRainbow6
echon "%G≋%@"
echohl None
echo ""
echohl NyanRainbow1
echon ""
echohl NyanRainbow2
echon "%G≋%@"
echohl NyanRainbow3
echon ""
echohl NyanRainbow4
echon "%G≋%@"
echohl NyanRainbow5
echon ""
echohl NyanRainbow6
echon "%G≋%@"
echohl NyanRainbow1
echon ""
echohl NyanRainbow2
echon "%G≋%@"
echohl NyanRainbow3
echon ""
echohl NyanRainbow4
echon "%G≋%@"
echohl NyanRainbow5
echon ""
echohl NyanRainbow6
echon "%G≋%@"
echohl NyanFur
echon "%G╰%@"
echohl NyanPoptartEdge
echon "%G⟨%@"
echohl NyanPoptartFrosting
echon "%G⣮⣯⡿%@"
echohl NyanPoptartEdge
echon "%G⟩%@"
echohl NyanFur
echon "%G⩾%@^-Fù^%G⩽%@"
echohl None
echo ""
echohl NyanRainbow1
echon ""
echohl NyanRainbow2
echon "%G≋%@"
echohl NyanRainbow3
echon ""
echohl NyanRainbow4
echon "%G≋%@"
echohl NyanRainbow5
echon ""
echohl NyanRainbow6
echon "%G≋%@"
echohl NyanRainbow1
echon ""
echohl NyanRainbow2
echon "%G≋%@"
echohl NyanRainbow3
echon ""
echohl NyanRainbow4
echon "%G≋%@"
echohl NyanRainbow5
echon ""
echohl NyanRainbow6
echon "%G≋%@"
echohl None
echon " "
echohl NyanFur
echon "-Y¡ %G‟%@"
echohl None
sleep 1
redraw
echo " "
echo " "
echo "Noms?"
redraw
endfunction " }}}
command! NyanMe call NyanMe()
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment