Last active
October 19, 2018 16:10
-
-
Save alexanderjeurissen/9375562 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
" E 888 888 d88b | |
" d8b 888 e88~~8e Y88b / /~~~8e 888-~88e e88~\888 e88~~8e 888-~\ Y88P d88~\ | |
" /Y88b 888 d888 88b Y88b/ 88b 888 888 d888 888 d888 88b 888 __/ C888 | |
" / Y88b 888 8888__888 Y88b e88~-888 888 888 8888 888 8888__888 888 Y88b | |
" /____Y88b 888 Y888 , /Y88b C888 888 888 888 Y888 888 Y888 , 888 888D | |
" / Y88b 888 '88___/ / Y88b `88_-888 888 888 '88_/888 "88___/ 888 \_88P | |
" Y88b / ,e, | |
" Y88b / " 888-~88e-~88e 888-~\ e88~~\ | |
" Y88b / 888 888 888 888 888 d888 | |
" Y888/ 888 888 888 888 888 8888 | |
" Y8/ 888 888 888 888 888 Y888 | |
" Y 888 888 888 888 888 "88__/ | |
" _ _ _ | |
" _____ _____ _____ _____ _____ ___ ___| |_| |_(_)_ __ __ _ ___ _____ _____ _____ _____ _____ | |
" |_____|_____|_____|_____|_____| / __|/ _ \ __| __| | '_ \ / _` / __| |_____|_____|_____|_____|_____| | |
" |_____|_____|_____|_____|_____| \__ \ __/ |_| |_| | | | | (_| \__ \ |_____|_____|_____|_____|_____| | |
" |___/\___|\__|\__|_|_| |_|\__, |___/ | |
" |___/ | |
"section:settings | |
set mouse= | |
set dict=/usr/share/dict/words | |
set fileencoding=utf-8 | |
set nocompatible " Use Vim settings, rather then Vi settings | |
set nobackup | |
set nowritebackup | |
set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287 | |
set autowrite " Automatically :write before running commands | |
set shortmess=aAIsT | |
set cmdheight=2 | |
set nowrap | |
set smartcase | |
set textwidth=150 | |
set sessionoptions-=options " Don't save options | |
set sessionoptions+=resize | |
set completeopt=menu | |
set mousemodel=popup | |
set fillchars=vert:¦ | |
set cc=+1,+2 | |
set list | |
set listchars=tab:▸\ ,trail:-,extends:>,precedes:<,eol:¬ | |
set tags=./tags | |
let mapleader=',' | |
"UNdo & backup | |
set undofile " Save undo's after file closes | |
set undodir=$HOME/.vim/undo " where to save undo histories | |
set undolevels=1000 " How many undos | |
set undoreload=10000 " number of lines to save for undo | |
set backup | |
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
" Softtabs, 2 spaces | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
"open help in a new tab instead of vimbuffer | |
cnoreabbrev <expr> h getcmdtype() == ":" && getcmdline() == 'h' ? 'vert help' : 'h' | |
"set terminal colors if gui isn't running | |
if !has("gui_running") | |
set t_Co=256 | |
set term=screen-256color | |
"Access colors present in 256 colorspace" | |
let base16colorspace=256 | |
endif | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern. | |
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") | |
syntax on | |
endif | |
filetype plugin indent on | |
augroup vimrcEx | |
autocmd! | |
" Set syntax highlighting for specific file types | |
autocmd BufRead,BufNewFile Appraisals set filetype=ruby | |
autocmd BufRead,BufNewFile *.md set filetype=markdown | |
autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable | |
" Enable spellchecking for Markdown and git commit | |
autocmd FileType markdown setlocal spell | |
autocmd FileType gitcommit setlocal spell | |
" Automatically wrap at 80 characters for Markdown, ruby, css and coffescript | |
autocmd BufRead,BufNewFile *.md setlocal textwidth=80 | |
autocmd BufRead,BufNewFile *.erb setlocal textwidth=80 | |
autocmd BufRead,BufNewFile *.rb setlocal textwidth=80 | |
autocmd BufRead,BufNewFile *.css setlocal textwidth=80 | |
autocmd BufRead,BufNewFile *.coffee setlocal textwidth=80 | |
" Automatically wrap at 150 characters for javascript files | |
autocmd BufRead,BufNewFile *.js setlocal textwidth=150 | |
" Add html highlighting when editing rails views | |
autocmd BufRead,BufNewFile *.erb set filetype=eruby.html | |
" Add javascript highlighting when embeded in HTML file | |
autocmd BufRead,BufNewFile *.html set filetype=html.javascript | |
" Add javascript highlighting when embeded in erb file | |
autocmd BufRead,BufNewFile *.js.erb set filetype=eruby.javascript | |
" Automatically remove trailing whitespaces | |
autocmd BufWritePre *.* :call Preserve("%s/\\s\\+$//e") | |
augroup END | |
" Numbers | |
set number | |
set numberwidth=5 | |
" Treat <li> and <p> tags like the block tags they are | |
let g:html_indent_tags = 'li\|p' | |
" Open new split panes to right and bottom, which feels more natural | |
set splitbelow | |
set splitright | |
set clipboard=unnamed | |
autocmd FileType gitcommit setlocal textwidth=70 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it for commit messages, when the position is invalid, or when | |
" inside an event handler (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
" ____ _ _ | |
" _____ _____ _____ _____ _____ | _ \| |_ _ __ _(_)_ __ ___ _____ _____ _____ _____ _____ | |
" |_____|_____|_____|_____|_____| | |_) | | | | |/ _` | | '_ \/ __| |_____|_____|_____|_____|_____| | |
" |_____|_____|_____|_____|_____| | __/| | |_| | (_| | | | | \__ \ |_____|_____|_____|_____|_____| | |
" |_| |_|\__,_|\__, |_|_| |_|___/ | |
" |___/ | |
"section plugins | |
"setup NeoVim {{{ | |
set nocompatible " Be iMproved | |
"Note: Skip initialization for vim-tiny or vim-small. | |
if !1 | finish | endif | |
if has('vim_starting') | |
set nocompatible " Be iMproved | |
"Required: | |
set runtimepath+=~/.vim/bundle/neobundle.vim/ | |
endif | |
let g:neobundle#types#git#default_protocol = 'git' | |
"Required: | |
call neobundle#begin(expand('~/.vim/bundle/')) | |
" Let NeoBundle manage NeoBundle | |
"Required: | |
NeoBundleFetch 'Shougo/neobundle.vim' | |
"}}} | |
"Pluggin mapping & configuration {{{ | |
let s:settings = {} | |
let s:settings.plugin_groups = [] | |
call add(s:settings.plugin_groups, 'core') | |
call add(s:settings.plugin_groups, 'github') | |
call add(s:settings.plugin_groups, 'editing') | |
call add(s:settings.plugin_groups, 'indent') | |
call add(s:settings.plugin_groups, 'autocomplete') | |
call add(s:settings.plugin_groups, 'navigation') | |
call add(s:settings.plugin_groups, 'unite') | |
call add(s:settings.plugin_groups, 'gruvbox') | |
" call add(s:settings.plugin_groups, 'solarized') | |
call add(s:settings.plugin_groups, 'web') | |
call add(s:settings.plugin_groups, 'javascript') | |
" call add(s:settings.plugin_groups, 'ruby') | |
call add(s:settings.plugin_groups, 'misc') | |
"beginplug | |
if count(s:settings.plugin_groups, 'core') "{{{ | |
NeoBundle 'tpope/vim-sensible' | |
NeoBundle 'bling/vim-airline' "{{{ | |
let g:airline_powerline_fonts = 1 | |
let g:airline_enable_branch = 1 | |
" | |
"Vim-powerline symbols | |
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_branch_prefix = '⭠' | |
let g:airline_readonly_symbol = '⭤' | |
let g:airline_linecolumn_prefix = '⭡' | |
let g:airline#extensions#syntastic#enabled = 1 | |
let g:airline_section_warning = '✗' | |
let g:airline_section_error = '⚠' | |
let g:airline#extensions#tagbar#enabled = 0 | |
"Airline Whitespace | |
let g:airline#extensions#whitespace#enabled = 1 | |
let g:airline#extensions#whitespace#symbol = '..' | |
let g:airline#extensions#whitenpace#checks = [ 'indent', 'trailing' ] | |
let g:airline#extensions#whitespace#show_message = 0 | |
"Tabline | |
let g:airline#extensions#tabline#left_sep = '' | |
let g:airline#extensions#tabline#left_alt_sep = '⮁' | |
let g:airline#extensions#tabline#enabled = 0 | |
let g:airline#extensions#tabline#show_buffers = 1 | |
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number | |
let g:airline#extensions#tabline#tab_min_count = 1 | |
let g:airline_readonly_symbol = '⭤' | |
let g:airline_linecolumn_prefix = '⭡' | |
let g:airline#extensions#syntastic#enabled = 1 | |
let g:airline_section_warning = '✗' | |
let g:airline_section_error = '⚠' | |
function! s:toggleFix() | |
exec ':AirlineToggle' | |
exec ':AirlineToggle' | |
endfunction | |
autocmd BufEnter,FileType * call s:toggleFix() | |
"}}} | |
NeoBundle 'spolu/dwm.vim' "{{{ | |
"disable default dwm mappings | |
let g:dwm_map_keys=0 | |
let g:dwm_master_pane_width="66%" | |
" Split the current buffer helper function! | |
" based on a git post of https://github.com/jdonaldson | |
function! DWM_Split() | |
" Move current master pane to the stack | |
call DWM_Stack(1) | |
" Create a vertical split | |
vert topleft split | |
call DWM_ResizeMasterPaneWidth() | |
endfunction | |
" Cleans up the window layout if dwm buffer is closed arbitrarily | |
" based on a git post of https://github.com/jdonaldson | |
function! DWM_Close_AND_Fix() | |
silent exe ':bd' | |
let w = 1 | |
" stack all windows | |
while (w <= winnr("$")) | |
exe w . "wincmd w" | |
wincmd K | |
let w+=1 | |
endwhile | |
" make the last current window the main window | |
wincmd H | |
" resize according to user preference | |
call DWM_ResizeMasterPaneWidth() | |
endfunction | |
" 1. split to tiled windows | |
nnoremap <silent> <leader>vs :call DWM_New()<CR> | |
" 2. close dwm windows | |
nnoremap <silent> <Leader>q :call DWM_Close_AND_Fix()<CR> | |
" 3. quickly switch current window with the main pane and toggle backupdir | |
nnoremap <silent> <leader>vm :call DWM_Focus()<CR> | |
" 4. jump to next and previous window | |
" map <silent><C-H> <C-W>W | |
" map <expr><C-L> winnr("$") == 1 ? ":call DWM_Split()\<CR>" : "\<C-W>w" | |
nnoremap <silent><C-L> :call DWM_Rotate(1)<CR> | |
nnoremap <silent><C-H> :call DWM_Rotate(0)<CR> | |
"}}} | |
endif "}}} | |
if count(s:settings.plugin_groups, 'github') "{{{ | |
NeoBundleLazy 'mattn/gist-vim' , { 'depends': 'mattn/webapi-vim', 'autoload': { 'commands': 'Gist' } } "{{{ | |
" Vim gist | |
let g:gist_clip_command = 'pbcopy' | |
let g:gist_detect_filetype = 1 | |
" let g:gist_open_browser_after_post = 1 | |
let g:gist_show_privates = 1 | |
" :w and :w! update a gist. | |
let g:gist_update_on_write = 1 | |
"GistID: 9375562 | |
"}}} | |
NeoBundle 'tpope/vim-fugitive' "{{{ | |
nnoremap <silent> <leader>gst :Gstatus<CR> | |
nnoremap <silent> <leader>gd :Gvdiff<CR> | |
nnoremap <silent> <leader>gc :Gcommit<CR> | |
nnoremap <silent> <leader>gb :Gblame<CR> | |
nnoremap <silent> <leader>gl :Glog<CR> | |
nnoremap <silent> <leader>gp :Git push<CR> | |
nnoremap <silent> <leader>gr :Gread<CR> | |
nnoremap <silent> <leader>gw :Gwrite<CR> | |
nnoremap <silent> <leader>ge :Gedit<CR> | |
"}}} | |
NeoBundleLazy 'int3/vim-extradite' | |
"gitgutter | |
let g:gitgutter_eager=0 | |
endif "}}} | |
if count(s:settings.plugin_groups, 'editing') "{{{ | |
NeoBundle 'tommcdo/vim-exchange' | |
NeoBundle 'osyo-manga/vim-over' | |
NeoBundle 'tpope/vim-surround' | |
NeoBundle 'tpope/vim-abolish' | |
NeoBundle 'kris89/vim-multiple-cursors' "{{{ | |
let g:multi_cursor_quit_key='<Esc>' | |
"}}} | |
NeoBundle 'vim-scripts/tComment' | |
NeoBundle 'tpope/vim-endwise' | |
NeoBundle 'myusuf3/numbers.vim' | |
endif "}}} | |
if count(s:settings.plugin_groups, 'indent') "{{{ | |
NeoBundleLazy 'nathanaelkane/vim-indent-guides.git' | |
NeoBundle 'editorconfig/editorconfig-vim' | |
endif "}}} | |
if count(s:settings.plugin_groups, 'autocomplete') "{{{ | |
NeoBundle 'MarcWeber/vim-addon-mw-utils' | |
NeoBundle 'tomtom/tlib_vim' | |
NeoBundle 'mattn/emmet-vim' "{{{ | |
let g:user_emmet_install_global = 1 | |
imap <expr> <tab> emmet#expandAbbrIntelligent("\<tab>") | |
imap <buffer> <tab> emmet#expandAbbrIntelligent("\<tab>") | |
let g:user_emmet_next_key='<C-n>' | |
let g:user_emmet_settings = { | |
\ 'html.javascript' : { | |
\ 'extends' : 'html', | |
\ 'filters' : 'html', | |
\ } | |
\} | |
"}}} | |
NeoBundle 'tpope/vim-repeat' | |
NeoBundle 'Shougo/neocomplete' "{{{ | |
let g:acp_enableAtStartup = 0 | |
let g:neocomplete#enable_at_startup = 1 | |
let g:neocomplete#enable_smart_case = 1 | |
let g:neocomplete#enable_auto_delimiter = 1 | |
let g:neocomplete#max_list = 15 | |
let g:neocomplete#force_overwrite_completefunc = 1 | |
" 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:neocomplete#sources#omni#input_patterns') | |
let g:neocomplete#sources#omni#input_patterns = {} | |
endif | |
" Define dictionary. | |
let g:neocomplete#sources#dictionary#dictionaries = { | |
\ 'default' : '', | |
\ 'vimshell' : $HOME.'/.vimshell_hist', | |
\ 'scheme' : $HOME.'/.gosh_completions' | |
\ } | |
" Define keyword. | |
if !exists('g:neocomplete#keyword_patterns') | |
let g:neocomplete#keyword_patterns = {} | |
endif | |
let g:neocomplete#keyword_patterns['default'] = '\h\w*' | |
"}}} | |
NeoBundle 'SirVer/ultisnips' "{{{ | |
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. | |
let g:UltiSnipsExpandTrigger="<tab>" | |
let g:UltiSnipsJumpForwardTrigger="<c-j>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-k>" | |
let g:UltiSnipsListSnippets="<c-tab>" | |
" let g:UltiSnipsSnippetsDir="~/.vim/snippets" | |
" let g:UltiSnipsUsePythonVersion = 2 | |
" If you want :UltiSnipsEdit to split your window. | |
let g:UltiSnipsEditSplit="vertical" | |
"}}} | |
NeoBundle "justinj/vim-react-snippets" | |
endif "}}} | |
if count(s:settings.plugin_groups, 'navigation') "{{{ | |
NeoBundle 'mhinz/vim-signify' | |
NeoBundle 'rking/ag.vim' "{{{ | |
"map Silver Searcher | |
noremap <leader>ag :Ag!<space> | |
"search for word under cursor with Silver Searcher | |
noremap <leader>Ag :Ag! "<C-r>=expand('<cword>')<CR>" | |
"}}} | |
NeoBundle 'Lokaltog/vim-easymotion' "{{{ | |
"change leader leader defaults to just leader | |
map <Leader> <Plug>(easymotion-prefix) | |
"use s to activate easymotion | |
nmap s <Plug>(easymotion-s2) | |
"}}} | |
NeoBundle 'jistr/vim-nerdtree-tabs', { 'depends': 'scrooloose/nerdtree' } "{{{ | |
nmap <Leader>f <plug>NERDTreeTabsToggle<CR> | |
- "collapse Nerdtree | |
let g:nerdtree_tabs_startup_cd = 0 | |
let g:NERDTreeWinSize = 50 | |
let NERDTreeHijackNetrw=1 | |
"}}} | |
NeoBundleLazy 'danro/rename.vim' | |
NeoBundle 'airblade/vim-rooter' | |
endif "}}} | |
if count(s:settings.plugin_groups, '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#custom#profile('files','context.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_source_history_yank_enable=1 | |
let g:unite_source_rec_max_cache_files=5000 | |
" let g:unite_split_rule = 'botright' " make it look like Ctrl-P | |
let g:unite_prompt='» ' | |
if executable('ag') | |
let g:unite_source_rec_async_command= 'ag --nocolor --nogroup --hidden -g ""' | |
let g:unite_source_grep_command='ag' | |
let g:unite_source_grep_default_opts='--nocolor --nogroup -S -C4' | |
let g:unite_source_grep_recursive_opt='' | |
elseif executable('ack') | |
let g:unite_source_grep_command='ack' | |
let g:unite_source_grep_default_opts='--no-heading --no-color -a -C4' | |
let g:unite_source_grep_recursive_opt='' | |
endif | |
autocmd FileType unite call s:unite_settings() | |
nmap <space> [unite] | |
nnoremap [unite] <nop> | |
"unite mappings | |
nnoremap <silent> [unite]<space> :<C-u>Unite -no-split -toggle -buffer-name=files file_rec/async:! buffer file_mru<CR> | |
" call unite#custom#profile('caseInsensitive', 'ignorecase', 1) | |
nnoremap <silent> [unite]f :<C-u>Unite -no-split -toggle -buffer-name=files file_rec/async:!<cr> | |
nnoremap <silent> [unite]e :<C-u>Unite -no-split -buffer-name=recent file_mru<CR> | |
nnoremap <silent> [unite]y :<C-u>Unite -no-split -buffer-name=yanks history/yank<CR> | |
nnoremap <silent> [unite]t :<C-u>Unite -buffer-name=tabs tab<CR> | |
nnoremap <silent> [unite]w :<C-u>Unite -buffer-name=windows window<CR> | |
nnoremap <silent> [unite]b :<C-u>Unite -no-split -buffer-name=buffers buffer<CR> | |
nnoremap <silent> [unite]/ :<C-u>Unite -no-quit -buffer-name=search grep:.<CR> | |
nnoremap <silent> [unite]m :<C-u>Unite -auto-resize -buffer-name=mappings mapping<CR> | |
nnoremap <silent> [unite]s :<C-u>Unite -quick-match buffer<CR> | |
nnoremap <silent> [unite]r <Plug>(unite_redraw)<CR> | |
"}}} | |
NeoBundleLazy 'Shougo/neomru.vim', {'autoload':{'unite_sources':'file_mru'}} | |
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 'Shougo/unite-outline', {'autoload':{'unite_sources':'outline'}} "{{{ | |
nnoremap <silent> [unite]go :<C-u>Unite -no-split -auto-preview -auto-resize -buffer-name=outline outline<CR> | |
"}}} | |
NeoBundleLazy 'Shougo/unite-help', {'autoload':{'unite_sources':'help'}} "{{{ | |
nnoremap <silent> [unite]h :<C-u>Unite -auto-resize -buffer-name=help help<CR> | |
"}}} | |
NeoBundleLazy 'Shougo/unite-session', {'autoload':{'unite_sources':'session'}} "{{{ | |
nnoremap <silent> [unite]s :<C-u>Unite -auto-resize -buffer-name=session session<CR> | |
"}}} | |
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', | |
\ }, | |
\ } | |
endif "}}} | |
if count(s:settings.plugin_groups, 'gruvbox') "{{{ | |
NeoBundle 'morhetz/gruvbox' | |
let g:airline_theme = 'gruvbox' | |
endif "}}} | |
if count(s:settings.plugin_groups, 'solarized') "{{{ | |
NeoBundle 'BlackIkeEagle/vim-colors-solarized' | |
" NeoBundle 'altercation/vim-colors-solarized' | |
if has("gui_running") | |
let g:solarized_visibility = "high" | |
let g:solarized_contrast = "high" | |
let g:solarized_termtrans = 1 | |
hi! link txtBold Identifier | |
hi! link zshVariableDef Identifier | |
hi! link zshFunction Function | |
hi! link rubyControl Statement | |
hi! link rspecGroupMethods rubyControl | |
hi! link rspecMocks Identifier | |
hi! link rspecKeywords Identifier | |
hi! link rubyLocalVariableOrMethod Normal | |
hi! link rubyStringDelimiter Constant | |
hi! link rubyString Constant | |
hi! link rubyAccess Todo | |
hi! link rubySymbol Identifier | |
hi! link rubyPseudoVariable Type | |
hi! link rubyRailsARAssociationMethod Title | |
hi! link rubyRailsARValidationMethod Title | |
hi! link rubyRailsMethod Title | |
hi! link rubyDoBlock Normal | |
hi! link MatchParen DiffText | |
hi! link CTagsModule Type | |
hi! link CTagsClass Type | |
hi! link CTagsMethod Identifier | |
hi! link CTagsSingleton Identifier | |
hi! link javascriptFuncName Type | |
hi! link jsFuncCall jsFuncName | |
hi! link javascriptFunction Statement | |
hi! link javascriptThis Statement | |
hi! link javascriptParens Normal | |
hi! link jOperators javascriptStringD | |
hi! link jId Title | |
hi! link jClass Title | |
hi! link sassMixinName Function | |
hi! link sassDefinition Function | |
hi! link sassProperty Type | |
hi! link htmlTagName Type | |
hi! PreProc gui=bold | |
let g:airline_theme = 'solarized' | |
let hour = strftime("%H") " Set the background light from 7am to 7pm | |
if 7 <= hour && hour < 17 | |
set background=light | |
exec ':AirlineRefresh' | |
else " Set to dark from 7pm to 7am | |
set background=dark | |
exec ':AirlineRefresh' | |
endif | |
endif | |
exec ':highlight clear SignColumn' | |
exec ':highlight link SignColumn CursorColumn' | |
endif "}}} | |
if count(s:settings.plugin_groups, 'web') "{{{ | |
NeoBundle 'tpope/vim-haml' | |
NeoBundle 'hail2u/vim-css3-syntax' | |
endif "}}} | |
if count(s:settings.plugin_groups, 'javascript') "{{{ | |
NeoBundle 'jelera/vim-javascript-syntax' | |
NeoBundle 'othree/javascript-libraries-syntax.vim' | |
NeoBundle 'mklabs/grunt.vim' | |
NeoBundle 'Raimondi/delimitMate' | |
NeoBundle 'scrooloose/syntastic' "{{{ | |
" configure syntastic syntax checking to check on open as well as save | |
let g:syntastic_check_on_open=1 | |
let g:syntastic_check_on_save=1 | |
let g:syntastic_enable_signs = 1 | |
let g:syntastic_error_symbol = '✗' | |
let g:syntastic_style_error_symbol = '✠' | |
let g:syntastic_warning_symbol = '∆' | |
let g:syntastic_style_warning_symbol = '≈' | |
let g:syntastic_javascript_checkers = ['jsxhint'] | |
" let g:syntastic_javascript_jshint_conf = '~/.vim/.jshintrc' | |
let g:syntastic_ruby_checkers = ['mri', 'rubocop'] | |
"}}} | |
NeoBundle 'maksimr/vim-jsbeautify' "{{{ | |
autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<CR> | |
"for javascript embedded in .erb | |
autocmd FileType eruby.javascript noremap <buffer> <c-f> :call JsBeautify()<CR> | |
" for html | |
autocmd FileType html.javascript noremap <buffer> <c-f> :call HtmlBeautify()<CR> | |
" for rails views | |
autocmd FileType eruby.html noremap <buffer> <c-f> :call HtmlBeautify()<CR> | |
" for css or scss | |
autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<CR> | |
autocmd FileType scss noremap <buffer> <c-f> :call CSSBeautify()<CR> | |
"}}} | |
"dependency for vim-jsbeautify | |
NeoBundle 'einars/js-beautify' | |
"coffeescript support | |
NeoBundle 'kchmck/vim-coffee-script' | |
NeoBundle 'burnettk/vim-angular' | |
NeoBundle 'mxw/vim-jsx', {'depends': 'pangloss/vim-javascript'} | |
endif "}}} | |
if count(s:settings.plugin_groups, 'ruby') "{{{ | |
NeoBundle 'subbarao/vim-rubybeautifier' | |
NeoBundle 'tpope/vim-rails' "{{{ | |
"run rspec | |
nnoremap <c-t> :Rrunner<CR> | |
"}}} | |
NeoBundle 'ngmy/vim-rubocop' "{{{ | |
let g:vimrubocop_keymap = 0 | |
nmap <Leader>r :RuboCop<CR> | |
"}}} | |
NeoBundle 'thoughtbot/vim-rspec' | |
NeoBundle 'tpope/vim-bundler' | |
NeoBundle 'tpope/vim-cucumber' | |
endif "}}} | |
if count(s:settings.plugin_groups, 'markdown') "{{{ | |
NeoBundle 'tpope/vim-markdown' | |
endif "}}} | |
if count(s:settings.plugin_groups, 'misc') "{{{ | |
" NeoBundle 'rizzatti/funcoo.vim' | |
NeoBundle 'MarcWeber/vim-addon-local-vimrc' | |
endif "}}} | |
"endplug | |
" 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 | |
if &diff | |
set wrap | |
let g:solarized_diffmode='normal' | |
endif | |
" _____ _ _ | |
" _____ _____ _____ _____ _____ | ___| _ _ __ ___| |_(_) ___ _ __ ___ _____ _____ _____ _____ _____ | |
" |_____|_____|_____|_____|_____| | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __| |_____|_____|_____|_____|_____| | |
" |_____|_____|_____|_____|_____| | _|| |_| | | | | (__| |_| | (_) | | | \__ \ |_____|_____|_____|_____|_____| | |
" |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ | |
" | |
"section:functions | |
" rename current file, via Gary Bernhardt | |
function! RenameFile() | |
let old_name = expand('%') | |
let new_name = input('New file name: ', expand('%')) | |
if new_name != '' && new_name != old_name | |
exec ':saveas ' . new_name | |
exec ':silent !rm ' . old_name | |
redraw! | |
endif | |
endfunction | |
function! InsertTabWrapper() | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
else | |
return "\<c-e>" | |
endif | |
endfunction | |
function! s:unite_settings() | |
imap <buffer> <space><space> <plug>(unite_exit) | |
imap <buffer> <C-j> <Plug>(unite_select_next_line) | |
imap <buffer> <C-k> <Plug>(unite_select_previous_line) | |
nmap <buffer><expr> <C-h> unite#do_action('split') | |
imap <buffer><expr> <C-h> unite#do_action('split') | |
nmap <buffer><expr> <C-v> unite#do_action('vsplit') | |
imap <buffer><expr> <C-v> unite#do_action('vsplit') | |
nmap <buffer><expr> <C-t> unite#do_action('tabopen') | |
imap <buffer><expr> <C-t> unite#do_action('tabopen') | |
nmap <buffer> <esc> <plug>(unite_exit) | |
imap <buffer> <esc> <plug>(unite_exit) | |
endfunction | |
" Set tabstop, softtabstop and shiftwidth to the same value | |
command! -nargs=* Stab call Stab() | |
function! Stab() | |
let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') | |
if l:tabstop > 0 | |
let &l:sts = l:tabstop | |
let &l:ts = l:tabstop | |
let &l:sw = l:tabstop | |
endif | |
call SummarizeTabs() | |
endfunction | |
function! SummarizeTabs() | |
try | |
echohl ModeMsg | |
echon 'tabstop='.&l:ts | |
echon ' shiftwidth='.&l:sw | |
echon ' softtabstop='.&l:sts | |
if &l:et | |
echon ' expandtab' | |
else | |
echon ' noexpandtab' | |
endif | |
finally | |
echohl None | |
endtry | |
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 | |
" save session | |
fun! WriteSession() | |
let cwd = fnamemodify('.', ':p:h:t') | |
let dateStamp = strftime("%d-%m-%Y_%H:%M") | |
let extension = ".session" | |
let fname = cwd . "_" . dateStamp . extension | |
silent exe ":UniteSessionSave " . fname | |
echo "Wrote " . fname | |
endfun | |
" Use ranger as vim file manager | |
fun! Ranger() | |
let tmpfile = tempname() | |
if a:0 > 0 && a:1 != "" | |
let dir = a:1 | |
elseif expand("%") | |
let dir = "." | |
else | |
let dir = expand("%:p:h") | |
endif | |
exe 'silent !ranger --choosefile='.tmpfile dir | |
if filereadable(tmpfile) | |
exe 'edit' readfile(tmpfile)[0] | |
call delete(tmpfile) | |
endif | |
redraw! | |
endfun | |
function! Multiple_cursors_before() | |
exe 'NeoCompleteLock' | |
echo 'Disabled autocomplete' | |
endfunction | |
function! Multiple_cursors_after() | |
exe 'NeoCompleteUnlock' | |
echo 'Enabled autocomplete' | |
endfunction | |
function! ToggleBG() | |
if &background == "dark" | |
echom 'switching to light' | |
set background=light | |
else | |
echom 'switching to dark' | |
set background=dark | |
endif | |
exec ':highlight clear SignColumn' | |
exec ':highlight link SignColumn CursorColumn' | |
endfunction | |
" _ | |
" _____ _____ _____ _____ _____ _ __ ___ __ _ _ __ _ __ (_)_ __ __ _ ___ _____ _____ _____ _____ _____ | |
" |_____|_____|_____|_____|_____| | '_ ` _ \ / _` | '_ \| '_ \| | '_ \ / _` / __| |_____|_____|_____|_____|_____| | |
" |_____|_____|_____|_____|_____| | | | | | | (_| | |_) | |_) | | | | | (_| \__ \ |_____|_____|_____|_____|_____| | |
" |_| |_| |_|\__,_| .__/| .__/|_|_| |_|\__, |___/ | |
" |_| |_| |___/ | |
"section:mappings | |
" Unnoremap the arrow keys | |
no <down> <Nop> | |
no <left> <Nop> | |
no <right> <Nop> | |
no <up> <Nop> | |
ino <down> <Nop> | |
ino <left> <Nop> | |
ino <right> <Nop> | |
ino <up> <Nop> | |
vno <down> <Nop> | |
vno <left> <Nop> | |
vno <right> <Nop> | |
vno <up> <Nop> | |
" Fix annoying typo's of WQ, QA and Q | |
command! WQ wq | |
command! Wq wq | |
command! W w | |
command! Q q | |
command! QA qa | |
command! Qa qa | |
" Wrapped lines goes down/up to next row, rather than next line in file. | |
noremap j gj | |
noremap k gk | |
"use up and dow arrow to move line | |
noremap <up> ddkP | |
noremap <down> ddp | |
" Code folding options | |
nnoremap <leader>f0 :set foldlevel=0<CR> | |
nnoremap <leader>f1 :set foldlevel=1<CR> | |
nnoremap <leader>f2 :set foldlevel=2<CR> | |
nnoremap <leader>f3 :set foldlevel=3<CR> | |
nnoremap <leader>f4 :set foldlevel=4<CR> | |
nnoremap <leader>f5 :set foldlevel=5<CR> | |
nnoremap <leader>f6 :set foldlevel=6<CR> | |
nnoremap <leader>f7 :set foldlevel=7<CR> | |
nnoremap <leader>f8 :set foldlevel=8<CR> | |
nnoremap <leader>f9 :set foldlevel=9<CR> | |
" Find merge conflict markers | |
noremap <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR> | |
" | |
"Spelling mapping | |
inoremap <c-l> <c-g>u<Esc>[s1z=`]a<c-g>u | |
" Map <Leader>ff to display all lines with keyword under cursor | |
" and ask which one to jump to | |
nnoremap <Leader>ff [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>" | |
"open current buffer in chrome or safari | |
" nnoremap <F5> :!open -a Safari %<CR><CR> | |
nnoremap <c-p> :!open -a Google\ Chrome %<CR><CR> | |
"Vimdiff mappings | |
nnoremap <leader>d :Gdiff<CR> | |
nnoremap <leader>dh :diffget //2 <CR>:diffupdate<CR> | |
nnoremap <leader>dt :diffget //3 <CR>:diffupdate<CR> | |
nnoremap <leader>dw :only <CR>:Gwrite<CR> | |
" tabpage mappings | |
noremap <Leader>tn :tabnext<CR> | |
noremap <Leader>t :tabnew<CR> | |
noremap <leader>m :call WriteSession()<CR> | |
noremap <leader>cm :!rm -f ~/.vim/session/*.*<CR> | |
"custom comma motion mapping | |
nnoremap di, f,dT, | |
nnoremap ci, f,cT, | |
nnoremap da, f,ld2F,i,<ESC>l "delete argument | |
nnoremap ca, f,ld7F,i,<ESC>a "delete arg and insert | |
"Ranger mapping | |
"Replace mappings | |
nnoremap <leader>rl 0:s/ | |
nnoremap <leader>rp {ma}mb:'a,'bs/ | |
"awesomeness make jj in insertmode escape to normal. never press <esc> again! | |
inoremap jj <Esc> | |
" upper or lowercase the current word | |
nnoremap g^ gUiW | |
nnoremap gv guiW | |
" diff | |
nnoremap >c ]czz | |
nnoremap <c [czz | |
" default to very magic | |
no / /\v | |
" gO to create a new line below cursor in normal mode | |
nnoremap go o<ESC>k | |
" go to create a new line above cursor | |
nnoremap gO O<ESC>j | |
"I really hate that things don't auto-center | |
nnoremap G Gzz | |
nnoremap n nzz | |
nnoremap N Nzz | |
nnoremap } }zz | |
nnoremap { {zz | |
"open tag in new tab | |
noremap <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR> | |
"quick pairs | |
inoremap <leader>' ''<ESC>i | |
inoremap <leader>" ""<ESC>i | |
inoremap <leader>( ()<ESC>i | |
inoremap <leader>[ []<ESC>i | |
" Make Y behave like other capital commands. | |
" Hat-tip http://vimbits.com/bits/11 | |
nnoremap Y y$ | |
" Just to beginning and end of lines easier. From http://vimbits.com/bits/16 | |
noremap H ^ | |
noremap L $ | |
" Use ; for : in normal and visual mode, less keystrokes | |
" nnoremap ; : | |
" vnoremap ; : | |
" Open vimrc with leader->v | |
nnoremap <leader>v :vsplit $MYVIMRC<CR> | |
nnoremap <leader>gv :vsplit $MYGVIMRC<CR> | |
nnoremap <leader>vr :source $MYVIMRC<CR> | |
noremap <leader>n :call RenameFile()<CR> | |
" nnoremap <C-m> :MaximizerToggle<CR> | |
nnoremap <leader>hl :set hlsearch!<CR> | |
" toggle background mapping | |
nnoremap <F5> :call ToggleBG()<CR> | |
" Change to Directory of Current file | |
nnoremap ,cd :cd %:p:h<CR>:pwd<CR> | |
call neobundle#end() | |
" Required: set filetype | |
filetype plugin indent on | |
if count(s:settings.plugin_groups, 'gruvbox') "{{{ | |
colorscheme gruvbox | |
endif "}}}" | |
" If there are uninstalled bundles found on startup, | |
" this will conveniently prompt you to install them. | |
NeoBundleCheck | |
"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment