set nocompatible " Disable vi compatibility " Getter/Setter generation let g:phpgetset_getterTemplate = \ " \n" . \ " /**\n" . \ " * Get %varname%.\n" . \ " *\n" . \ " * @return \n" . \ " */\n" . \ " public function %funcname%()\n" . \ " {\n" . \ " return $this->%varname%;\n" . \ " }" let g:phpgetset_setterTemplate = \ " \n" . \ " /**\n" . \ " * Set %varname%.\n" . \ " *\n" . \ " * @param $%varname%\n" . \ " * @return fluent\n" . \ " */\n" . \ " public function %funcname%($%varname%)\n" . \ " {\n" . \ " $this->%varname% = $%varname%;\n" . \ " return $this;\n" . \ " }" let g:UltiSnipsUsePythonVersion = 2 set nofoldenable " disable code folding let g:DisableAutoPHPFolding = 1 " disable autofolding for PHP let g:PIVCreateDefaultMappings = 0 " disable creation of default mapping let g:pdv_cfg_foldmarke = 0 " disable generation of fold marker for docblocks " PIV PHP shortcuts - create single docblock in PHP nmap cd PIVphpDocSingle vmap cd PIVphpDocRange " Pathogen plugin management filetype off call pathogen#infect() " Load plugin call pathogen#helptags() " Load plugin help files syntax on " Syntax highlighting on filetype plugin indent on " Enable filetype-specific indenting and plugins " powerline set rtp+=~/dotfiles/powerline/powerline/bindings/vim " ======================================================================== " General settings " ======================================================================== set showcmd " show commands in the status bar set noshowmode " don't show the current vim mode, powerline does it " by default we go with 4 space indent and spaces set expandtab set softtabstop=4 set shiftwidth=4 set tabstop=4 set showtabline=1 set encoding=utf-8 " Utf-8 everything set fileencodings=utf-8 set termencoding=utf-8 set laststatus=2 " Always show two line status set ff=unix " Set file format to Unix set history=1000 " Change history to 200 items set wildmenu " use menu that looks like zsh set wildmode=list:longest,full " Color scheme set t_Co=256 set background=dark let g:solarized_contrast="normal" let g:solarized_visibility="high" colorscheme solarized set autoread " Reload files that have not been modified set autowrite " Automatically :write before running commands set list " Show hidden characters set listchars=tab:›\ ,eol:¬,trail:⋅ " Set the characters for the invisibles set number set relativenumber " Show relative line numbers set scrolloff=999 " Keep the cursor centered in the screen set showmatch " Highlight matching braces set splitbelow " Splits show up below by default set splitright " Splits go to the right by default set textwidth=80 set colorcolumn=+1 set numberwidth=5 set showbreak=… " Search settings set hlsearch " Highlight results set ignorecase " Ignore casing of searches set incsearch " Start showing results as you type set smartcase " Be smart about case sensitivity when searching if ! has('gui_running') set term=xterm-256color endif " performance improvements? set nocursorline " Don't paint cursor line set nocursorcolumn " Don't paint cursor column " set cursorline set lazyredraw " Wait to redraw set ttyfast " Fast tty " History undo set history=1000 " remember more commands and search history " GIT is there for this set nobackup " no backup files set nowritebackup " only in case you don't want a backup file while editing set noswapfile " no swap files " Misc set modelines=5 " Enable mode line to tell vim what to do of odd files set viminfo+=! set smarttab set gdefault " assume the /g flag is used for replace set autoindent set ignorecase smartcase set grepprg=ack-grep " (Hopefully) removes the delay when hitting esc in insert mode set noesckeys set ttimeout set ttimeoutlen=1 " Don't add the comment prefix when I hit enter or o/O on a comment line. "set formatoptions-=or set formatoptions=qrn1 " Undo everything set undodir=~/.vim/undo set undofile set undolevels=1000 " maximum number of changes that can be undone set undoreload=10000 " maximum number lines to save for undo on a buffer reload set shiftround " When at 3 spaces and I hit >>, go to 4, not 5. " Don't wait so long for the next keypress (particularly in ambigious Leader " situations. "set timeoutlen=500 " ======================================================================== " Plugin settings " ======================================================================== " vim-hardtime let g:hardtime_maxcount = 2 let g:hardtime_allow_different_key = 1 let g:hardtime_ignore_buffer_patterns = [ "\.git/" ] " easymotion let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyz' let g:EasyMotion_leader_key='t' let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion let g:EasyMotion_use_upper = 1 "python import sys; sys.path.append("/Library/Python/2.7/site-packages") "python from powerline.vim import setup as powerline_setup "python powerline_setup() "python del powerline_setup " python from powerline.ext.vim import source_plugin; source_plugin() let g:Powerline_symbols = 'fancy' " Neocomplete let g:neocomplete#enable_at_startup = 1 " Start it let g:neocomplete#enable_auto_select = 0 " Disable autoselect let g:neocomplete#max_list = 25 " show 25 results in popup autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags " customize omni completion inoremap pumvisible() ? "\" : "\" " make tab select entry " Ultisnip if (has('gui_running')) let g:UltiSnipsExpandTrigger="" else let g:UltiSnipsExpandTrigger="" endif " Tweak some things for CtrlP let g:ctrlp_map = '' let g:ctrlp_cmd = 'CtrlP' set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/* let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' let g:ctrlp_user_command = { \ 'types' : { \ 1: ['.git', 'cd %s && git ls-files'], \ }, \ 'fallback': 'find %s -type f' \ } " ======================================================================== " Key mappings " ======================================================================== " Disable Ex mode map Q " Disable K looking stuff up map K " Leader key let mapleader = "\" " space as leader key " easymotion "map l (easymotion-lineforward) "map j (easymotion-j) "map k (easymotion-k) "map h (easymotion-linebackward) "map f (easymotion-bd-f) "map t (easymotion-bd-t) " clear out search buffer easier nmap ,/ :let @/="" " Switch between the last two files nnoremap " easily switch between vsplit windows map j map k map h map l " save yourself if you forgot to use sudo to save something cmap w!! w !sudo tee % >/dev/null " tabularize shortcut vmap t= :Tabularize /=> vmap t" :Tabularize /" nnoremap t= :Tabularize /=> " Nerdtree support map :NERDTreeToggle " Training wheels, disable arrows inoremap inoremap inoremap inoremap noremap noremap noremap noremap " Shortcut to yanking to the system clipboard map y "+y map p "+p " Let's be reasonable, shall we? nmap k gk nmap j gj map P :call PasteFromTmux() " Expand in command mode to the path of the currently open file cnoremap %% =expand('%:h').'/' " Buffer management nnoremap d :bd " Toogle relative line number nnoremap n :set relativenumber! " disable HL search nmap / :nohlsearch " Fugitive and GIT goodness nnoremap gs :Gstatus nnoremap gd :Gdiff nnoremap gc :Gcommit nnoremap gb :Gblame nnoremap gl :Glog nnoremap gp :Git push "nnoremap gr :Gread nnoremap gw :Gwrite nnoremap ge :Gedit " GIT workflow " gm = git checkout master nnoremap gm :Git checkout master " push my current work to live only works from master nnoremap gli :Git pull --rebase:Git checkout live:Git pull --rebase origin live:Git merge master:Git push origin live:Git checkout master " Remap a key sequence in insert mode to kick me out to normal " mode. This makes it so this key sequence can never be typed " again in insert mode, so it has to be unique. inoremap jj inoremap jJ inoremap Jj inoremap JJ inoremap jk inoremap jK inoremap Jk inoremap JK " test tmux let &t_ti = &t_ti . "\e[?2004h" let &t_te = "\e[?2004l" . &t_te let &pastetoggle = "\e[201~" map [201~ imap [201~ map [200~ XTermPasteBegin("i") imap [200~ XTermPasteBegin("") cmap [200~ cmap [201~ " Ctrl s save " Note that remapping C-s requires flow control to be disabled " (e.g. in .bashrc or .zshrc) map :w imap :w map :tabnew map c " Emacs-like beginning and end of line. imap $ imap ^ map vi :tabe ~/.vimrc :inoremap =expand("%:t:r") " Disable esc and try to use Ctrl + [ or jj " disabled for now because it breaks Ctrl + s " inoremap " ============================================================================ " Gvim " ============================================================================ if has("gui_running") " Disable any visual or audible bell au GUIEnter * set vb t_vb= " Set font set guifont=Inconsolata\ for\ Powerline\ Bold\ 13 " remove superfluous chrome set guioptions-=m set guioptions-=l set guioptions-=L set guioptions-=t set guioptions-=T set guioptions+=c set guioptions-=l set guioptions-=r set guioptions-=b endif " ============================================================================ " Functions/Macro " ============================================================================ " this should be included by vim snippet but does not work somehow fun! vim_snippets#Filename(...) let template = get(a:000, 0, "$1") let arg2 = get(a:000, 1, "") let basename = expand('%:t:r') if basename == '' return arg2 else return substitute(template, '$1', basename, 'g') endif endf " Remove trailling spaces fun! ReplaceTabs() let l = line(".") let c = col(".") %s/\t/ /e call cursor(l, c) endfun " Strip trailing whitespaces function! StripTrailingWhitespaces() " Preparation: save last search, and cursor position. let _s=@/ let l = line(".") let c = col(".") " Do the business: %s/\s\+$//e " Clean up: restore previous search history, and cursor position let @/=_s call cursor(l, c) endfunction " Handle paste in vim from tmux fun! PasteFromTmux() set paste startinsert !tmux paste-buffer -p !tmux send-keys Escape ":set nopaste" Enter endfun " used to paste from tmux function! XTermPasteBegin(ret) set paste return a:ret endfunction " create directory for current buffer function! MkdirsIfNotExists(directory) if(!isdirectory(a:directory)) call system('mkdir -p '.shellescape(a:directory)) endif endfunction " ======================================================================== " File type related settings " ======================================================================== if has('autocmd') augroup GeneralConfig au FocusLost silent! :wa au FileType helpfile setlocal nonumber augroup END augroup FileTypes autocmd! au BufRead,BufNewFile *.php setlocal filetype=php iskeyword-=$ au BufRead,BufNewFile *.twig setlocal filetype=jinja au BufRead,BufNewFile *.html.twig setlocal filetype=htmljinja au BufRead,BufNewFile *.js.twig setlocal filetype=javascript au BufRead,BufNewFile *.ejs setlocal filetype=html au BufRead,BufNewFile *.json setlocal filetype=javascript au BufRead,BufNewFile *.pp setlocal filetype=ruby augroup END augroup TabsConfig autocmd! au BufRead,BufNewFile *.feature setlocal tabstop=2 shiftwidth=2 softtabstop=2 au BufRead,BufNewFile *.css setlocal tabstop=2 shiftwidth=2 softtabstop=2 au BufRead,BufNewFile *.scss setlocal tabstop=2 shiftwidth=2 softtabstop=2 au BufRead,BufNewFile *.less setlocal tabstop=2 shiftwidth=2 softtabstop=2 au BufRead,BufNewFile *.ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 au BufRead,BufNewFile *.js setlocal tabstop=2 shiftwidth=2 softtabstop=2 au BufRead,BufNewFile *.coffee setlocal tabstop=2 shiftwidth=2 softtabstop=2 au BufRead,BufNewFile vim setlocal tabstop=8 shiftwidth=2 softtabstop=2 au Filetype gitcommit setlocal spell textwidth=72 augroup END " activate vim-hardtime augroup HardTime autocmd! au BufRead,BufNewFile *.php,*.html,*.phtml HardTimeOn augroup END " reload vimrc automatically augroup Vim autocmd! au bufwritepost .vimrc source % au bufwritepost vimrc source % augroup END augroup Commands autocmd! au BufWrite *.php,*.js,*.feature,*.json :call StripTrailingWhitespaces() au BufWrite * :call MkdirsIfNotExists(expand(':h')) augroup END endif