Created
September 29, 2014 03:46
-
-
Save jvillasante/59df6498d9feff6eb69b 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => General | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" This can be used on either platform to switch to the other encoding. | |
" :set fileformat=unix | |
" :set fileformat=dos | |
" detect OS {{{ | |
let s:is_windows = has('win32') || has('win64') | |
let s:is_cygwin = has('win32unix') | |
let s:is_macvim = has('gui_macvim') | |
"}}} | |
if s:is_windows && !s:is_cygwin | |
set shell=c:\windows\system32\cmd.exe | |
else | |
set shell=/bin/bash | |
endif | |
try | |
lang en_us | |
catch | |
endtry | |
" the past is better left in the past | |
set nocompatible | |
set exrc " enable per-directory .vimrc files | |
set secure " disable unsafe commands in local .vimrc files | |
" set modelines=1 | |
set modeline | |
set modelines=5 | |
" Set to auto read when a file is changed from the outside | |
set autoread | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader = "," | |
let g:mapleader = "," | |
" Size of GVim window | |
if has("gui_running") | |
set lines=999 columns=999 | |
endif | |
set noautochdir | |
set sessionoptions=folds,sesdir,tabpages,winsize | |
set viewoptions=folds,options,cursor,unix,slash | |
" Treat all numerals as decimal | |
set nrformats= | |
set splitbelow | |
" set splitright | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => VIM user interface | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Set 2 lines to the cursor - when moving vertically using j/k | |
set so=2 | |
" mouse | |
set mouse=a | |
" Set 4 chars to the cursor - when moving horizontally | |
set sidescrolloff=4 | |
set wildmenu " nice menu when completing commands | |
set wildchar=<Tab> " expand the command line using tab | |
set wildmode=list:longest,full " completion behaves similar to a shell | |
" Ignore compiled files | |
set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing | |
set wildignore+=*DS_Store* | |
set wildignore+=vendor/** | |
set wildignore+=node_modules/** | |
set wildignore+=build/** | |
set wildignore+=dist/** | |
set wildignore+=log/** | |
set wildignore+=tmp/** | |
set wildignore+=*.png,*.jpg,*.gif | |
set wildignore+=*.so,*.swp,*.zip,*/.Trash/**,*.pdf,*.dmg,*/Library/**,*/.rbenv/** | |
set wildignore+=*/.nx/**,*.app | |
"Always show current position | |
set ruler | |
" Height of the command bar | |
set cmdheight=2 | |
" A buffer becomes hidden when it is abandoned | |
set hid | |
set hidden | |
" Configure backspace so it acts as it should act | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" autoindent | |
:set autoindent | |
:set cindent | |
" searching | |
set nohlsearch "highlight searches | |
set incsearch "incremental searching | |
set ignorecase "ignore case for searching | |
set smartcase "do case-sensitive if there's a capital letter | |
if executable('ack') | |
set grepprg=ack\ --nogroup\ --column\ --smart-case\ --nocolor\ --follow\ $* | |
set grepformat=%f:%l:%c:%m | |
endif | |
if executable('ag') | |
set grepprg=ag\ --nogroup\ --column\ --smart-case\ --nocolor\ --follow | |
set grepformat=%f:%l:%c:%m | |
endif | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" For regular expressions turn magic on | |
set magic | |
" Always use very magic regex mode when searching | |
nnoremap / /\v | |
nnoremap ? ?\v | |
" Don't jump around when yanking paragraphs | |
noremap yip mayip`a | |
noremap yap mayap`a | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
" No annoying sound on errors | |
set noerrorbells visualbell t_vb= | |
if has('autocmd') | |
autocmd GUIEnter * set visualbell t_vb= | |
endif | |
" Stifle many interruptive prompts | |
set shortmess=atI | |
set history=1000 " remember more commands and search history | |
set undolevels=1000 " use many levels of undo | |
set showcmd " display an incomplete command (lower right corner) | |
set showmode " show editing mode | |
set number " show line numbers | |
set foldenable "enable folds by default | |
set foldmethod=indent | |
" set foldmethod=syntax "fold via syntax of files | |
set foldlevelstart=99 "open all folds by default | |
let g:xml_syntax_folding=1 "enable xml folding | |
set cursorline | |
set title | |
" Always show the menu, insert longest match | |
set completeopt=menuone,longest | |
set tags=tags;/ | |
set showfulltag | |
set ruler | |
set textwidth=120 | |
set colorcolumn=120 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlighting | |
syntax enable | |
syntax on | |
" Set extra options when running in GUI mode | |
if has("gui_running") | |
set guioptions-=m | |
set guioptions-=T | |
set guioptions-=r | |
set guioptions-=l | |
set guioptions-=b | |
set guitablabel=%M\ %t | |
set t_Co=256 | |
endif | |
" Font. Very important. | |
if has("gui_running") | |
set guifont=Inconsolata\ 14 | |
else | |
set guifont=Inconsolata\ 14 | |
endif | |
" Set utf8 as standard encoding and en_US as the standard language | |
" set encoding=utf-8 nobomb " BOM often causes trouble | |
scriptencoding utf-8 | |
set encoding=utf-8 | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Files, backups and undo | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Turn backup off, since most stuff is in SVN, git et.c anyway... | |
set nobackup | |
set nowb | |
set noswapfile | |
set nowritebackup | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use spaces instead of tabs | |
set expandtab | |
" Be smart when using tabs ;) | |
set smarttab | |
set expandtab | |
" 1 tab == 2 spaces | |
set shiftwidth=2 | |
set tabstop=2 | |
" Linebreak on 500 characters | |
set lbr | |
set tw=500 | |
set ai "Auto indent | |
set si "Smart indent | |
set nowrap "No Wrap lines | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Windows and buffers | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Specify the behavior when switching between buffers | |
try | |
set switchbuf=useopen,usetab,newtab | |
set stal=2 | |
catch | |
endtry | |
" Remember info about open buffers on close | |
set viminfo^=% | |
"""""""""""""""""""""""""""""" | |
" => Status line | |
"""""""""""""""""""""""""""""" | |
" Always show the status line | |
set laststatus=2 | |
" Format the status line | |
" set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Mappings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Remap ,, to reverse the last character-search command (cause , is mapped to leader) | |
nnoremap ,, , | |
nmap <leader>w :w!<cr> " Fast saving | |
" Type %% on Vim's command-line promt to automatically expand to the path of the active buffer, | |
" just as though we had typed %:h<Tab>. | |
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :call VisualSelection('f')<CR> | |
vnoremap <silent> # :call VisualSelection('b')<CR> | |
" Treat long lines as break lines (useful when moving around in them) | |
map j gj | |
map k gk | |
" Smart way to move between windows | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" history scrollers | |
cnoremap <C-p> <Up> | |
cnoremap <C-n> <Down> | |
" Close the current buffer | |
map <leader>bd :Bclose<cr> | |
" Close all the buffers | |
map <leader>ba :1,1000 bd!<cr> | |
" Useful mappings for managing tabs | |
map <leader>tn :tabnew<cr> | |
map <leader>to :tabonly<cr> | |
map <leader>tc :tabclose<cr> | |
map <leader>tm :tabmove | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Remap VIM 0 to first non-blank character | |
map 0 ^ | |
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac | |
nmap <M-j> mz:m+<cr>`z | |
nmap <M-k> mz:m-2<cr>`z | |
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z | |
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z | |
if has("mac") || has("macunix") | |
nmap <D-j> <M-j> | |
nmap <D-k> <M-k> | |
vmap <D-j> <M-j> | |
vmap <D-k> <M-k> | |
endif | |
nnoremap <silent> <C-o> <Esc>:call AddEmptyLineBelow()<CR> | |
nnoremap ' ` | |
nnoremap ` ' | |
" ,/ to toggle highlight. | |
noremap * :set hlsearch<CR>:nohlsearch<CR>* | |
noremap / :set hlsearch<CR>:nohlsearch<CR>/ | |
noremap ? :set hlsearch<CR>:nohlsearch<CR>? | |
nnoremap <leader>/ :set invhlsearch<CR> | |
inoremap <leader>/ <ESC>:set invhlsearch<CR>gi | |
" the evilchelu hack! | |
inoremap <ESC> <space><BS><ESC> | |
" omni autocomplete in insert mode: | |
imap <C-SPACE> <C-N> | |
" Quickly edit/reload the vimrc file | |
nmap <silent> <leader>ev :e $MYVIMRC<CR> | |
nmap <silent> <leader>sv :so $MYVIMRC<CR> | |
nmap <silent> <leader>eg :e $MYGVIMRC<CR> | |
nmap <silent> <leader sg :so $MYGVIMRC<CR> | |
" get rid of that stupid help key... | |
inoremap <F1> <ESC> | |
nnoremap <F1> <ESC> | |
vnoremap <F1> <ESC> | |
" smooth scrolling | |
:map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y> | |
:map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E> | |
" formatting shortcuts | |
nmap <leader>fef :call Preserve("normal gg=G")<CR> | |
nmap <leader>f$ :call StripTrailingWhitespace()<CR> | |
vmap <leader>s :sort<cr> | |
noremap <leader>b :call ToggleBackgroundColor()<cr> | |
noremap <leader>rn :call RenameFile()<cr> | |
" autocmd | |
" go back to previous position of cursor if any | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe 'normal! g`"zvzz' | | |
\ endif | |
autocmd FileType js,scss,css autocmd BufWritePre <buffer> call StripTrailingWhitespace() | |
autocmd FileType css,scss setlocal foldmethod=marker foldmarker={,} | |
autocmd FileType css,scss nnoremap <silent> <leader>S vi{:sort<CR> | |
autocmd FileType markdown setlocal nolist | |
autocmd FileType vim setlocal fdm=indent keywordprg=:help | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => vimgrep searching and cope displaying | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" When you press gv you vimgrep after the selected text | |
vnoremap <silent> gv :call VisualSelection('gv')<CR> | |
" Open vimgrep and put the cursor in the right position | |
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left> | |
" Vimgreps in the current file | |
map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right> | |
" When you press <leader>r you can search and replace the selected text | |
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR> | |
" Do :help cope if you are unsure what cope is. It's super useful! | |
" | |
" When you search with vimgrep, display your results in cope by doing: | |
" <leader>cc | |
" | |
" To go to the next search result do: | |
" <leader>n | |
" | |
" To go to the previous search results do: | |
" <leader>p | |
" | |
map <leader>cc :botright cope<cr> | |
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg | |
map <leader>n :cn<cr> | |
map <leader>p :cp<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Spell checking | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Pressing ,ss will toggle and untoggle spell checking | |
map <leader>ss :setlocal spell!<cr> | |
" Shortcuts using <leader> | |
map <leader>sn ]s | |
map <leader>sp [s | |
map <leader>sa zg | |
map <leader>s? z= | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Misc | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Remove the Windows ^M - when the encodings gets messed up | |
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm | |
" Quickly open a buffer for scripbble | |
map <leader>q :e ~/buffer<cr> | |
" Toggle paste mode on and off | |
map <leader>pp :setlocal paste!<cr> | |
" select the HTML to change. When we press <leader>q the selection will be formatted; when we press <leader>h we will undo the format. | |
vmap <silent> <leader>h :s?^\(\s*\)+ '\([^']\+\)',*\s*$?\1\2?g<CR> | |
vmap <silent> <leader>q :s?^\(\s*\)\(.*\)\s*$? \1 + '\2'?<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Helper functions | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! CmdLine(str) | |
exe "menu Foo.Bar :" . a:str | |
emenu Foo.Bar | |
unmenu Foo | |
endfunction | |
function! VisualSelection(direction) range | |
let l:saved_reg = @" | |
execute "normal! vgvy" | |
let l:pattern = escape(@", '\\/.*$^~[]') | |
let l:pattern = substitute(l:pattern, "\n$", "", "") | |
if a:direction == 'b' | |
execute "normal ?" . l:pattern . "^M" | |
elseif a:direction == 'gv' | |
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') | |
elseif a:direction == 'replace' | |
call CmdLine("%s" . '/'. l:pattern . '/') | |
elseif a:direction == 'f' | |
execute "normal /" . l:pattern . "^M" | |
endif | |
let @/ = l:pattern | |
let @" = l:saved_reg | |
endfunction | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
en | |
return '' | |
endfunction | |
" Don't close window, when deleting a buffer | |
command! Bclose call <SID>BufcloseCloseIt() | |
function! <SID>BufcloseCloseIt() | |
let l:currentBufNum = bufnr("%") | |
let l:alternateBufNum = bufnr("#") | |
if buflisted(l:alternateBufNum) | |
buffer # | |
else | |
bnext | |
endif | |
if bufnr("%") == l:currentBufNum | |
new | |
endif | |
if buflisted(l:currentBufNum) | |
execute("bdelete! ".l:currentBufNum) | |
endif | |
endfunction | |
function! AddEmptyLineAbove() | |
let l:scrolloffsave = &scrolloff | |
" Avoid jerky scrolling with ^E at top of window | |
set scrolloff=0 | |
call append(line(".") - 1, "") | |
if winline() != winheight(0) | |
silent normal! <C-e> | |
endif | |
let &scrolloff = l:scrolloffsave | |
endfunction | |
function! AddEmptyLineBelow() | |
call append(line("."), "") | |
endfunction | |
function! Preserve(command) | |
" preparation: save last search, and cursor position. | |
let _s=@/ | |
let l = line(".") | |
let c = col(".") | |
" do the business: | |
execute a:command | |
" clean up: restore previous search history, and cursor position | |
let @/=_s | |
call cursor(l, c) | |
endfunction | |
function! StripTrailingWhitespace() | |
call Preserve("%s/\\s\\+$//e") | |
endfunction | |
function! EnsureExists(path) | |
if !isdirectory(expand(a:path)) | |
call mkdir(expand(a:path)) | |
endif | |
endfunction | |
function! CloseWindowOrKillBuffer() | |
let number_of_windows_to_this_buffer = len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')")) | |
" never bdelete a nerd tree | |
if matchstr(expand("%"), 'NERD') == 'NERD' | |
wincmd c | |
return | |
endif | |
if number_of_windows_to_this_buffer > 1 | |
wincmd c | |
else | |
bdelete | |
endif | |
endfunction | |
" Rename the current file | |
function! RenameFile() | |
let old_name = expand('%') | |
let new_name = input('New file name: ', expand('%'), 'file') | |
if new_name != '' && new_name != old_name | |
exec ':saveas ' . new_name | |
exec ':silent !rm ' . old_name | |
redraw! | |
endif | |
endfunction | |
" Toggle background color | |
function! ToggleBackgroundColor() | |
" $background means return whats currently in `set bacground` | |
" and `==?` means that the comparison will be case sensitive no matter what | |
if &background ==? 'dark' | |
let &background = 'light' | |
" same as `set background=light` | |
else | |
let &background = 'dark' | |
endif | |
endfunction | |
"=============================================================================== | |
" NeoBundle | |
"=============================================================================== | |
if has('vim_starting') | |
set runtimepath+=~/.vim/bundle/neobundle.vim/ | |
endif | |
call neobundle#rc(expand('~/.vim/bundle/')) | |
" Let NeoBundle manage NeoBundle | |
NeoBundleFetch 'Shougo/neobundle.vim' | |
NeoBundle 'Shougo/vimproc', { 'build': { | |
\ 'windows': 'make -f make_mingw32.mak', | |
\ 'cygwin': 'make -f make_cygwin.mak', | |
\ 'mac': 'make -f make_mac.mak', | |
\ 'unix': 'make -f make_unix.mak', | |
\}} | |
" Unite | |
NeoBundle 'Shougo/unite.vim' "{{{ | |
let bundle = neobundle#get('unite.vim') | |
function! bundle.hooks.on_source(bundle) | |
call unite#filters#matcher_default#use(['matcher_fuzzy']) | |
call unite#filters#sorter_default#use(['sorter_rank']) | |
call unite#set_profile('files', 'smartcase', 1) | |
call unite#custom#source('line,outline','matchers','matcher_fuzzy') | |
endfunction | |
let g:unite_data_directory='~/.vim/.cache/unite' | |
let g:unite_enable_start_insert=1 | |
let g:unite_split_rule = "botright" | |
let g:unite_force_overwrite_statusline = 0 | |
let g:unite_winheight = 10 | |
let g:unite_source_history_yank_enable=1 | |
let g:unite_source_rec_max_cache_files=5000 | |
let g:unite_prompt='» ' | |
if executable('ag') | |
let g:unite_source_grep_command='ag' | |
let g:unite_source_grep_default_opts='--nogroup --nocolor --column' | |
let g:unite_source_grep_recursive_opt='' | |
let g:unite_source_rec_async_command= 'ag --nocolor --nogroup --hidden -g ""' | |
elseif executable('ack') | |
let g:unite_source_grep_command='ack' | |
let g:unite_source_grep_default_opts='--nogroup --nocolor --column' | |
let g:unite_source_grep_recursive_opt='' | |
endif | |
autocmd FileType unite call s:unite_settings() | |
function! s:unite_settings() | |
nmap <buffer> <esc> <plug>(unite_exit) | |
imap <buffer> <esc> <plug>(unite_exit) | |
imap <buffer> <C-j> <plug>(unite_select_next_line) | |
imap <buffer> <C-k> <plug>(unite_select_previous_line) | |
inoremap <silent><buffer><expr> <C-x> unite#do_action('split') | |
inoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit') | |
inoremap <silent><buffer><expr> <C-t> unite#do_action('tabopen') | |
endfunction | |
nmap <space> [unite] | |
nnoremap [unite] <nop> | |
" See h: unite-examples | |
" nnoremap [unite]f :<C-u>Unite -no-split -buffer-name=files -start-insert file/async<cr> | |
nnoremap [unite]f :<C-u>Unite -auto-resize -buffer-name=files -start-insert file_rec/async<cr> | |
nnoremap [unite]F :<C-u>Unite -auto-resize -buffer-name=files -start-insert buffer tab file_mru directory_mru<cr> | |
nnoremap [unite]r :<C-u>Unite -auto-resize -auto-resize -buffer-name=mru -start-insert file_mru<cr> | |
nnoremap [unite]b :<C-u>Unite -auto-resize -buffer-name=buffers buffer<cr> | |
nnoremap [unite]l :<C-u>Unite -auto-resize -buffer-name=line line<cr> | |
nnoremap [unite]y :<C-u>Unite -auto-resize -buffer-name=yank history/yank<cr> | |
nnoremap [unite]/ :<C-u>Unite -auto-resize -buffer-name=search grep:.<cr> | |
nnoremap [unite]m :<C-u>Unite -auto-resize -auto-resize -buffer-name=mappings mapping<cr> | |
"}}} | |
" NeoBundleLazy 'osyo-manga/unite-airline_themes', {'autoload':{'unite_sources':'airline_themes'}} "{{{ | |
" nnoremap <silent> [unite]a :<C-u>Unite -winheight=10 -auto-preview -buffer-name=airline_themes airline_themes<cr> | |
" "}}} | |
NeoBundleLazy 'ujihisa/unite-colorscheme', {'autoload':{'unite_sources':'colorscheme'}} "{{{ | |
nnoremap <silent> [unite]c :<C-u>Unite -winheight=10 -auto-preview -buffer-name=colorschemes colorscheme<cr> | |
"}}} | |
NeoBundleLazy 'tsukkee/unite-tag', {'autoload':{'unite_sources':['tag','tag/file']}} "{{{ | |
nnoremap <silent> [unite]t :<C-u>Unite -auto-resize -buffer-name=tag tag tag/file<cr> | |
"}}} | |
NeoBundleLazy 'osyo-manga/unite-quickfix', {'autoload':{'unite_sources':'quickfix'}} "{{{ | |
nnoremap <silent> [unite]q :<C-u>Unite -auto-resize -buffer-name=quickfix quickfix<cr> | |
"}}} | |
NeoBundleLazy 'Shougo/unite-outline', {'autoload':{'unite_sources':'outline'}} "{{{ | |
nnoremap <silent> [unite]o :<C-u>Unite -no-split -auto-preview -buffer-name=outline -start-insert outline<cr> | |
"}}} | |
NeoBundleLazy 'tsukkee/unite-help', {'autoload':{'unite_sources':'help'}} "{{{ | |
nnoremap <silent> [unite]h :<C-u>Unite -auto-resize -buffer-name=help help<cr> | |
"}}} | |
NeoBundleLazy 'Shougo/junkfile.vim', {'autoload':{'commands':'JunkfileOpen','unite_sources':['junkfile','junkfile/new']}} "{{{ | |
let g:junkfile#directory=expand("~/.vim/.cache/junk") | |
nnoremap <silent> [unite]j :<C-u>Unite -auto-resize -buffer-name=junk junkfile/new junkfile -start-insert<cr> | |
"}}} | |
" Core | |
NeoBundle 'tmhedberg/matchit' | |
NeoBundle 'itchyny/lightline.vim' "{{{ | |
let g:lightline = { | |
\ 'colorscheme': 'solarized', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], [ 'filename' ] ], | |
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ] | |
\ }, | |
\ 'component_function': { | |
\ 'filename': 'MyFilename', | |
\ 'fileformat': 'MyFileformat', | |
\ 'filetype': 'MyFiletype', | |
\ 'fileencoding': 'MyFileencoding', | |
\ 'mode': 'MyMode', | |
\ }, | |
\ 'component_expand': { | |
\ 'syntastic': 'SyntasticStatuslineFlag', | |
\ }, | |
\ 'component_type': { | |
\ 'syntastic': 'error', | |
\ }, | |
\ 'subseparator': { 'left': '|', 'right': '|' } | |
\ } | |
function! MyModified() | |
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' | |
endfunction | |
function! MyReadonly() | |
return &ft !~? 'help' && &readonly ? 'RO' : '' | |
endfunction | |
function! MyFilename() | |
let fname = expand('%:t') | |
return fname == 'ControlP' ? g:lightline.ctrlp_item : | |
\ fname == '__Tagbar__' ? g:lightline.fname : | |
\ fname =~ '__Gundo\|NERD_tree' ? '' : | |
\ &ft == 'vimfiler' ? vimfiler#get_status_string() : | |
\ &ft == 'unite' ? unite#get_status_string() : | |
\ &ft == 'vimshell' ? vimshell#get_status_string() : | |
\ ('' != MyReadonly() ? MyReadonly() . ' ' : '') . | |
\ ('' != fname ? fname : '[No Name]') . | |
\ ('' != MyModified() ? ' ' . MyModified() : '') | |
endfunction | |
function! MyFileformat() | |
return winwidth(0) > 70 ? &fileformat : '' | |
endfunction | |
function! MyFiletype() | |
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' | |
endfunction | |
function! MyFileencoding() | |
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' | |
endfunction | |
function! MyMode() | |
let fname = expand('%:t') | |
return fname == '__Tagbar__' ? 'Tagbar' : | |
\ fname == 'ControlP' ? 'CtrlP' : | |
\ fname == '__Gundo__' ? 'Gundo' : | |
\ fname == '__Gundo_Preview__' ? 'Gundo Preview' : | |
\ fname =~ 'NERD_tree' ? 'NERDTree' : | |
\ &ft == 'unite' ? 'Unite' : | |
\ &ft == 'vimfiler' ? 'VimFiler' : | |
\ &ft == 'vimshell' ? 'VimShell' : | |
\ winwidth(0) > 60 ? lightline#mode() : '' | |
endfunction | |
let g:tagbar_status_func = 'TagbarStatusFunc' | |
function! TagbarStatusFunc(current, sort, fname, ...) abort | |
let g:lightline.fname = a:fname | |
return lightline#statusline(0) | |
endfunction | |
augroup AutoSyntastic | |
autocmd! | |
autocmd BufWritePost *.c,*.cpp call s:syntastic() | |
augroup END | |
function! s:syntastic() | |
SyntasticCheck | |
call lightline#update() | |
endfunction | |
let g:unite_force_overwrite_statusline = 0 | |
let g:vimfiler_force_overwrite_statusline = 0 | |
let g:vimshell_force_overwrite_statusline = 0 | |
" let g:lightline = { | |
" \ 'colorscheme': 'solarized', | |
" \ 'active': { | |
" \ 'left': [ [ 'mode', 'paste' ], | |
" \ [ 'readonly', 'filename', 'modified' ] ] | |
" \ }, | |
" \ 'component': { | |
" \ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}', | |
" \ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}' | |
" \ }, | |
" \ 'component_visible_condition': { | |
" \ 'readonly': '(&filetype!="help"&& &readonly)', | |
" \ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))' | |
" \ }, | |
" \ 'separator': { 'left': '', 'right': '' }, | |
" \ 'subseparator': { 'left': '|', 'right': '|' } | |
" \ } | |
"}}} | |
" NeoBundle 'bling/vim-airline' "{{{ | |
" let g:airline_powerline_fonts = 1 | |
" let g:airline#extensions#tabline#enabled = 1 | |
" " let g:airline_left_sep = '' | |
" " let g:airline_left_alt_sep = '' | |
" " let g:airline_right_sep = '' | |
" " let g:airline_right_alt_sep = '' | |
" " let g:airline#extensions#tabline#enabled = 1 | |
" " let g:airline#extensions#tabline#left_sep=' ' | |
" " let g:airline#extensions#tabline#left_alt_sep='|' | |
" "}}} | |
NeoBundle 'tpope/vim-surround' | |
NeoBundle 'tpope/vim-repeat' | |
NeoBundle 'tpope/vim-unimpaired' "{{{ | |
nmap <c-up> [e | |
nmap <c-down> ]e | |
vmap <c-up> [egv | |
vmap <c-down> ]egv | |
"}}} | |
" Snippets | |
NeoBundle 'Shougo/neosnippet-snippets' | |
NeoBundle 'Shougo/neosnippet' "{{{ | |
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets,~/.vim/snippets' | |
let g:neosnippet#enable_snipmate_compatibility=1 | |
imap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ? "\<C-n>" : "\<TAB>") | |
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>" | |
imap <expr><S-TAB> pumvisible() ? "\<C-p>" : "" | |
smap <expr><S-TAB> pumvisible() ? "\<C-p>" : "" | |
"}}} | |
NeoBundle 'Valloric/YouCompleteMe' "{{{ | |
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py' | |
" For java projects... | |
" let g:EclimCompletionMethod = 'omnifunc' | |
"}}} | |
" NeoBundle 'Valloric/ListToggle' | |
NeoBundle 'scrooloose/syntastic' "{{{ | |
let g:syntastic_enable_signs=1 | |
let g:syntastic_auto_jump=1 | |
let g:syntastic_check_on_open=1 | |
let g:syntastic_cpp_compiler_options = ' -std=c++98' | |
"}}} | |
" Editing | |
NeoBundle 'tpope/vim-speeddating' | |
NeoBundle 'tomtom/tcomment_vim' | |
NeoBundle 'terryma/vim-expand-region' | |
NeoBundle 'terryma/vim-multiple-cursors' | |
" " NeoBundle 'chrisbra/NrrwRgn' | |
NeoBundleLazy 'godlygeek/tabular', {'autoload':{'commands':'Tabularize'}} "{{{ | |
nmap <Leader>a& :Tabularize /&<CR> | |
vmap <Leader>a& :Tabularize /&<CR> | |
nmap <Leader>a= :Tabularize /=<CR> | |
vmap <Leader>a= :Tabularize /=<CR> | |
nmap <Leader>a: :Tabularize /:<CR> | |
vmap <Leader>a: :Tabularize /:<CR> | |
nmap <Leader>a:: :Tabularize /:\zs<CR> | |
vmap <Leader>a:: :Tabularize /:\zs<CR> | |
nmap <Leader>a, :Tabularize /,<CR> | |
vmap <Leader>a, :Tabularize /,<CR> | |
nmap <Leader>a<Bar> :Tabularize /<Bar><CR> | |
vmap <Leader>a<Bar> :Tabularize /<Bar><CR> | |
"}}} | |
NeoBundle 'jiangmiao/auto-pairs' | |
" Navigation | |
NeoBundle 'rking/ag.vim' "{{{ | |
if executable('ag') | |
let g:agprg="ag --nogroup --column --smart-case --follow" | |
endif | |
"}}} | |
NeoBundleLazy 'scrooloose/nerdtree', {'autoload':{'commands':['NERDTreeToggle','NERDTreeFind']}} "{{{ | |
let NERDTreeShowHidden=0 | |
let NERDTreeQuitOnOpen=0 | |
let NERDTreeShowLineNumbers=0 | |
let NERDTreeChDirMode=0 | |
let NERDTreeShowBookmarks=1 | |
let NERDTreeBookmarksFile='~/.vim/.cache/NERDTreeBookmarks' | |
let NERDTreeIgnore=['\~$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr'] | |
map <leader>n :NERDTreeToggle<CR> | |
nnoremap <F2> :NERDTreeToggle<CR> | |
nnoremap <F3> :NERDTreeFind<CR> | |
"}}} | |
NeoBundleLazy 'majutsushi/tagbar', {'autoload':{'commands':'TagbarToggle'}} "{{{ | |
nnoremap <silent> <F9> :TagbarToggle<CR> | |
"}}} | |
" Idents | |
NeoBundle 'nathanaelkane/vim-indent-guides' "{{{ | |
let g:indent_guides_start_level=1 | |
let g:indent_guides_guide_size=1 | |
let g:indent_guides_enable_on_vim_startup=0 | |
let g:indent_guides_color_change_percent=3 | |
if !has('gui_running') | |
let g:indent_guides_auto_colors=0 | |
function! s:indent_set_console_colors() | |
hi IndentGuidesOdd ctermbg=235 | |
hi IndentGuidesEven ctermbg=236 | |
endfunction | |
autocmd VimEnter,Colorscheme * call s:indent_set_console_colors() | |
endif | |
"}}} | |
" Textobjects | |
NeoBundle 'kana/vim-textobj-user' | |
NeoBundle 'kana/vim-textobj-indent' | |
NeoBundle 'kana/vim-textobj-entire' | |
NeoBundle 'lucapette/vim-textobj-underscore' | |
" NeoBundle 'richsoni/vim-ecliptic' | |
" Misc | |
NeoBundleLazy 'tpope/vim-markdown', {'autoload':{'filetypes':['markdown']}} | |
NeoBundleLazy 'nelstrom/vim-markdown-folding', {'autoload':{'filetypes':['markdown']}} | |
NeoBundle 'mhinz/vim-startify' "{{{ | |
let g:startify_session_dir = '~/.vim/.cache/sessions' | |
let g:startify_change_to_vcs_root = 1 | |
let g:startify_show_sessions = 1 | |
nnoremap <F1> :Startify<cr> | |
"}}} | |
NeoBundleLazy 'zhaocai/GoldenView.Vim', {'autoload':{'mappings':['<Plug>ToggleGoldenViewAutoResize']}} "{{{ | |
let g:goldenview__enable_default_mapping=0 | |
nmap <F4> <Plug>ToggleGoldenViewAutoResize | |
"}}} | |
NeoBundle 'chrisbra/vim_faq' | |
NeoBundle 'aaronbieber/vim-quicktask' | |
NeoBundle 'vim-scripts/sudo.vim' "{{{ | |
" (command line): vim sudo:/etc/passwd | |
" (within vim): :e sudo:/etc/passwd | |
"}}} | |
" Color themems | |
NeoBundle 'altercation/vim-colors-solarized' "{{{ | |
set background=dark | |
let g:solarized_termtrans=1 | |
let g:solarized_termcolors=256 | |
let g:solarized_contrast="high" | |
let g:solarized_visibility="high" | |
colorscheme solarized | |
"}}} | |
filetype plugin indent on | |
syntax enable | |
NeoBundleCheck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment