├── .gitignore ├── install.sh ├── gvimrc ├── plugins.yml ├── Rakefile ├── README.md └── vimrc /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | .hg* 4 | .DS_Store 5 | .rvmrc 6 | plugins/ 7 | .rbenv-version 8 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cp -r ~/.vim ~/.vim.old 2>/dev/null 3 | rm -fr ~/.vim 2>/dev/null 4 | rm -f ~/.vimrc 2>/dev/null 5 | git clone https://github.com/srushti/vim-get.git ~/.vim && cd ~/.vim && rake update 6 | -------------------------------------------------------------------------------- /gvimrc: -------------------------------------------------------------------------------- 1 | " ----------------------------------------------------------------------------- 2 | " | VIM Settings | 3 | " | GUI stuff | 4 | " ----------------------------------------------------------------------------- 5 | 6 | 7 | " OS Specific ***************************************************************** 8 | if has("gui_macvim") 9 | 10 | set fuoptions=maxvert,maxhorz " fullscreen options (MacVim only), resized window when changed to fullscreen 11 | "set fullscreen 12 | set guifont=Monaco:h11 13 | set transparency=10 14 | macmenu &File.New\ Tab key= 15 | map :CtrlP 16 | 17 | elseif has("gui_gtk2") 18 | 19 | set guifont=Courier\ 10\ pitch 20 | 21 | set noerrorbells 22 | set visualbell 23 | set t_vb= 24 | 25 | elseif has("x11") 26 | elseif has("gui_win32") 27 | end 28 | 29 | colorscheme camouflage 30 | let g:airline_theme="solarized" 31 | 32 | set guioptions-=T " remove toolbar 33 | 34 | " General ********************************************************************* 35 | set anti " Antialias font 36 | 37 | "set transparency=0 38 | 39 | " Default size of window 40 | set columns=120 41 | set lines=45 42 | 43 | " Tab headings 44 | set gtl=%t gtt=%F 45 | -------------------------------------------------------------------------------- /plugins.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | vim-rails: 3 | git: git://github.com/tpope/vim-rails.git 4 | vim-cucumber: 5 | git: git://github.com/tpope/vim-cucumber.git 6 | vim-haml: 7 | git: git://github.com/tpope/vim-haml.git 8 | nerdtree: 9 | git: git://github.com/scrooloose/nerdtree.git 10 | ack.vim: 11 | git: git://github.com/mileszs/ack.vim.git 12 | tabular: 13 | git: git://github.com/godlygeek/tabular.git 14 | vim-fugitive: 15 | git: git://github.com/tpope/vim-fugitive.git 16 | ultisnips: 17 | git: git://github.com/sirver/UltiSnips.git 18 | snippets: 19 | git: git://github.com/srushti/vim-snippets.git 20 | nerdcommenter: 21 | git: git://github.com/scrooloose/nerdcommenter.git 22 | vim-bufonly: 23 | git: git://github.com/duff/vim-bufonly.git 24 | vim-endwise: 25 | git: git://github.com/tpope/vim-endwise.git 26 | vim-surround: 27 | git: git://github.com/tpope/vim-surround.git 28 | ctrlp: 29 | git: git://github.com/ctrlpvim/ctrlp.vim.git 30 | supertab: 31 | git: git://github.com/ervandew/supertab.git 32 | rvm.vim: 33 | git: git://github.com/tpope/vim-rvm.git 34 | vim-unimpaired: 35 | git: git://github.com/tpope/vim-unimpaired.git 36 | vim-rake: 37 | git: git://github.com/tpope/vim-rake.git 38 | yankring: 39 | git: git://github.com/vim-scripts/YankRing.vim.git 40 | vim-javascript: 41 | git: git://github.com/pangloss/vim-javascript.git 42 | vim-ruby-refactoring: 43 | git: git://github.com/ecomba/vim-ruby-refactoring.git 44 | mundo: 45 | git: git://github.com/simnalamburt/vim-mundo 46 | delimitMate: 47 | git: git://github.com/Raimondi/delimitMate.git 48 | tagbar: 49 | git: git://github.com/majutsushi/tagbar.git 50 | coffee-script: 51 | git: git://github.com/kchmck/vim-coffee-script.git 52 | coffeetags: 53 | git: https://github.com/lukaszkorecki/CoffeeTags.git 54 | repeat: 55 | git: git://github.com/tpope/vim-repeat.git 56 | easy-motion: 57 | git: git://github.com/Lokaltog/vim-easymotion.git 58 | textobj-rubyblock: 59 | git: git://github.com/nelstrom/vim-textobj-rubyblock.git 60 | textobj-user: 61 | git: git://github.com/kana/vim-textobj-user.git 62 | mustache: 63 | git: git://github.com/juvenn/mustache.vim.git 64 | gitgutter: 65 | git: git://github.com/airblade/vim-gitgutter.git 66 | airline: 67 | git: git://github.com/bling/vim-airline.git 68 | airline-themes: 69 | git: git://github.com/vim-airline/vim-airline-themes.git 70 | matchit: 71 | git: git://github.com/vim-scripts/matchit.zip.git 72 | zeus-spec: 73 | git: git://github.com/srushti/zeus-spec.vim.git 74 | my.vim: 75 | git: git://github.com/srushti/my.vim.git 76 | ag.vim: 77 | git: git://github.com/rking/ag.vim.git 78 | node: 79 | git: git://github.com/moll/vim-node.git 80 | vimux: 81 | git: git://github.com/benmills/vimux.git 82 | editorconfig: 83 | git: git://github.com/editorconfig/editorconfig-vim.git 84 | go: 85 | git: git://github.com/fatih/vim-go.git 86 | json: 87 | git: git://github.com/elzr/vim-json.git 88 | syntastic: 89 | git: git://github.com/scrooloose/syntastic.git 90 | elixir: 91 | git: git://github.com/elixir-lang/vim-elixir.git 92 | julia: 93 | git: git://github.com/JuliaLang/julia-vim.git 94 | nginx: 95 | git: git://github.com/nginx/nginx.git 96 | directory: contrib/vim 97 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'yaml' 3 | 4 | def load_plugin_urls 5 | yaml_file = File.open(File.join(File.dirname(__FILE__), 'plugins.yml')) 6 | yaml = YAML.load(yaml_file) 7 | yaml['plugins'] 8 | end 9 | 10 | def plugin_urls 11 | @plugins ||= load_plugin_urls 12 | end 13 | 14 | PLUGINS_WITH_MAKE = {} 15 | PLUGINS_WITH_RAKE = {} 16 | FOLDERS = %w(after autoload colors compiler doc ftdetect ftplugin indent lib macros nerdtree_plugin plugin pythonx rplugin ruby snippets UltiSnips syntax syntax_checkers utils) 17 | PLUGINS_WITHOUT_RAKE = plugin_urls.keys 18 | PLUGINS = PLUGINS_WITHOUT_RAKE + PLUGINS_WITH_RAKE.keys + PLUGINS_WITH_MAKE.keys 19 | if ENV['NEO'] == 'true' 20 | DOTVIM = "#{ENV['HOME']}/.config/nvim" 21 | else 22 | DOTVIM = "#{ENV['HOME']}/.vim" 23 | end 24 | 25 | desc "Get latest on all plugins" 26 | task :preinstall do 27 | FileUtils.mkdir_p('plugins') 28 | in_directory('plugins') do 29 | if ENV['PLUGIN'].nil? 30 | PLUGINS.each do |plugin| 31 | get_latest(plugin) 32 | end 33 | else 34 | get_latest(ENV['PLUGIN']) 35 | end 36 | end 37 | end 38 | 39 | def get_latest(plugin) 40 | if File.directory?(plugin) 41 | in_directory(plugin) { update_current_dir } 42 | elsif plugin_urls[plugin] 43 | clone_project(plugin, plugin_urls[plugin]) 44 | end 45 | end 46 | 47 | def clone_project(name, script_url_yaml) 48 | system("git clone #{plugin_urls[name]['git']} #{name} && git submodule update --init --recursive") if script_url_yaml['git'] 49 | system("hg clone #{plugin_urls[name]['hg']} #{name}") if script_url_yaml['hg'] 50 | system("svn checkout #{plugin_urls[name]['svn']} #{name}") if script_url_yaml['svn'] 51 | end 52 | 53 | def update_current_dir 54 | system('git pull origin master && git submodule update --init --recursive') if File.directory?('.git') 55 | system('hg pull && hg update') if File.directory?('.hg') 56 | system('svn up') if File.directory?('.svn') 57 | end 58 | 59 | def in_directory(directory) 60 | original_dir = Dir.pwd 61 | Dir.chdir directory 62 | yield 63 | Dir.chdir original_dir 64 | end 65 | 66 | desc "Install the files into ~/.vim" 67 | task :install do 68 | FileUtils.mkdir_p FOLDERS.map{|f| "#{DOTVIM}/#{f}" } 69 | FileUtils.mkdir_p "#{DOTVIM}/tmp" 70 | 71 | in_directory('plugins') do 72 | install_plugins(PLUGINS_WITH_RAKE, 'rake') 73 | install_plugins(PLUGINS_WITH_MAKE, 'make') 74 | end 75 | copy_dot_files 76 | in_directory('plugins') do 77 | PLUGINS_WITHOUT_RAKE.each do |plugin| 78 | if !File.directory?(plugin) 79 | puts "#{plugin} doesn't exist. Please run 'rake preinstall'" 80 | else 81 | if File.directory?("#{plugin}/.svn") 82 | in_directory(plugin) { system("svn export . --force #{DOTVIM}") } 83 | else 84 | puts "installing #{plugin}" 85 | directory = plugin_urls[plugin]['directory'] || '.' 86 | FOLDERS.each do |f| 87 | in_directory("#{plugin}/#{directory}") { FileUtils.cp_r Dir["#{f}/*"], "#{DOTVIM}/#{f}" } 88 | end 89 | end 90 | end 91 | system(plugin_urls[plugin]['post_install']) if plugin_urls[plugin] && plugin_urls[plugin]['post_install'] 92 | end 93 | end 94 | end 95 | 96 | def install_plugins(plugins, command) 97 | plugins.each do |plugin, task| 98 | if !File.directory?(plugin) 99 | puts "#{plugin} doesn't exist. Please run 'rake preinstall'" 100 | else 101 | puts "making #{plugin}" 102 | in_directory(plugin) { system "#{command} #{task}" } 103 | end 104 | end 105 | end 106 | 107 | def copy_dot_files 108 | link_if_it_doesnt_exist('vimrc') 109 | link_if_it_doesnt_exist('gvimrc') 110 | end 111 | 112 | def link_if_it_doesnt_exist(file, condition = 'f') 113 | system(<<-EOSCRIPT 114 | if [ ! -#{condition} $HOME/.#{file} ]; then 115 | ln -s $PWD/#{file} $HOME/.#{file} 116 | echo "Linking .#{file}" 117 | else 118 | echo "Skipping .#{file}, it already exists" 119 | fi 120 | EOSCRIPT 121 | ) 122 | end 123 | 124 | task :default => :install 125 | 126 | desc "Remove everything in ~/.vim" 127 | task :uninstall do 128 | FileUtils.rm_rf DOTVIM 129 | end 130 | 131 | desc "Blow everything out and try again." 132 | task :reinstall => [:uninstall, :preinstall, :install] 133 | 134 | desc "Get latest on all plugins" 135 | task :update => [:preinstall, :install] 136 | 137 | desc "Get latest on all plugins and reinstall from scratch" 138 | task :clean_update => [:preinstall, :reinstall] 139 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ruby/Rails based vimfiles and installer 2 | 3 | With the support for ruby, git, rvm, rails, rspec and so on. 4 | 5 | ## Requirements 6 | 7 | Vim 7.3 or better 8 | Tested on MacOS and Linux 9 | 10 | Introduction to Vim: http://blog.interlinked.org/tutorials/vim_tutorial.html 11 | 12 | ## Quick Install 13 | 14 | curl https://raw.github.com/srushti/vim-get/master/install.sh -o - | sh 15 | 16 | If you want to add another plugin, just edit the plugins.yml file and add the name & url of the source control of the plugin. 17 | 18 | ## Basic Mappings 19 | 20 | The leader is mapped to `,` 21 | 22 | **`Esc` is mapped to `jj`** 23 | 24 | ### In Normal mode (`Esc` or `jj`) 25 | 26 | `,w` - Save all buffers and place the cursor back to sameplace. 27 | 28 | `,W` - Save all buffers and place the cursor back to sameplace. 29 | 30 | `,n` - File browser (NerdTree Toggle) 31 | 32 | `,/` - File browser (NERDTree Find) 33 | 34 | `Space` - Page Down 35 | 36 | `Shift + Space` - Page Down 37 | 38 | `Ctrl + Shift + Right` - Goto Next buffer 39 | 40 | `Ctrl + Shift + Left` - Goto Previous buffer 41 | 42 | `,a` - Search in files (Ack) 43 | 44 | `,f` - Search open buffers (Fuzzy Finder like Textmate) 45 | 46 | `,d` - close buffer 47 | 48 | `,D` - close all buffers 49 | 50 | `,u` - GUI Undo history (GUndo) (Needs Python version more than 2.4v) 51 | 52 | `,,` - Toggle between last two buffers 53 | 54 | 55 | ### Open/Edit files 56 | 57 | `,ew` - Open/Edit file in the current directory 58 | 59 | `,es` - Open/Edit file in **HORIZONTAL SPLIT** 60 | 61 | `,ev` - Open/Edit file in **VERTICAL SPLIT** 62 | 63 | `,et` - Open/Edit file in **NEW TAB** 64 | 65 | ### Execute Ruby Specs 66 | 67 | `,s` - Run one spec under the cursor 68 | 69 | `,S` - Run all specs in the current file 70 | 71 | `,-` - Rerun last rake command (most likely the last run spec) 72 | 73 | ### In Insert mode (`i`) 74 | 75 | `jj` - Back to normal mode(or ESC) # 76 | 77 | `uu` - Replaces with the charecter `-` 78 | 79 | `hh` - Replaces with the charecter `=>` 80 | 81 | `aa` - Replaces with the charecter `@` 82 | 83 | `` - auto complete or expand snippet 84 | 85 | See `.vimrc` for more. 86 | 87 | ## Plugins 88 | 89 | ### ruby (`F5`) 90 | 91 | `F5` Executes the current file. 92 | 93 | ### rails 94 | 95 | *So many* good stuff - get to know this plugin! 96 | 97 | `,m` - Jump to model 98 | 99 | `,v` - Jump to view 100 | 101 | `,c` - Jump to controller 102 | 103 | #### Test Ruby Specs 104 | 105 | `,s` - Performs `.Rake` from rails plugin => normal `.rake` 106 | 107 | `,S` - Performs `Rake` from rails plugin => normal `rake` 108 | 109 | `,-` - Perform `Rake -` from rails plugin => normal `rake -` 110 | 111 | `:help rails` 112 | 113 | ### coffee-script 114 | 115 | CoffeeScript support 116 | 117 | `:CoffeeCompile watch` show compiled js in split 118 | 119 | https://github.com/kchmck/vim-coffee-script 120 | 121 | ### ruby-block 122 | 123 | Provides text-objects for Ruby blocks 124 | 125 | `var` (visual around Ruby) 126 | 127 | `vir` (visual inner Ruby) 128 | 129 | `ar` / `ir` (expand/contract selection) 130 | 131 | `cir` (change inner Ruby) 132 | 133 | `dar` (delete around Ruby) 134 | 135 | http://vimcasts.org/blog/2010/12/a-text-object-for-ruby-blocks/ 136 | 137 | ### sparkup (`ctrl+e`) 138 | 139 | Expand CSS selectors `div.event` in to markup `
` 140 | 141 | http://net.tutsplus.com/articles/general/quick-tip-even-quicker-markup-with-sparkup/ 142 | 143 | ### fugitive 144 | 145 | Git integration 146 | 147 | `,gd` - Git diff 148 | 149 | `,gs` - Git status press `-` to stage file 150 | 151 | `,gw` - Git write 152 | 153 | `,ga` - Git add 154 | 155 | `,gb` - Git blame 156 | 157 | `,gco` - Git checkout 158 | 159 | `,gci` - Git commit 160 | 161 | `,gm` - Git move 162 | 163 | `,gr` - Git remove 164 | 165 | `:help fugitive` 166 | 167 | http://vimcasts.org/episodes/fugitive-vim---a-complement-to-command-line-git/ 168 | 169 | ### snippets usage (`TAB`) 170 | 171 | Snippets, press `TAB` to expand 172 | 173 | Examples (in a Ruby file): 174 | 175 | `def` 176 | 177 | `.each` 178 | 179 | `.eado` 180 | 181 | `ife` 182 | 183 | ### gundo (`,u`) 184 | 185 | Navigate changes history tree 186 | 187 | http://vimcasts.org/episodes/undo-branching-and-gundo-vim/ 188 | 189 | ### conque 190 | 191 | Terminal/Interactive programs 192 | 193 | `:Conque zsh` 194 | 195 | `:Conque ls` 196 | 197 | Note you can also drop back to the terminal using Ctrl+Z, to get 198 | back to Vim with `%1`. This is not a feature of Conque. 199 | 200 | ### yankring 201 | 202 | Shows history of yanked (copied) text 203 | 204 | Pressing `ctrl + p` will also cycle through paste history 205 | 206 | ### ack (`,a`) 207 | 208 | Search project for text (aka find in files) 209 | 210 | `,a word` 211 | 212 | `,a "some words"` 213 | 214 | ### nerdtree (`,n`) 215 | 216 | Project file browser 217 | 218 | `,n` opens file browser 219 | 220 | `o` / `x` open and close files/folders 221 | 222 | `m` menu to move/delete/copy files/folders 223 | 224 | `?` Help 225 | 226 | I use nerdtree for creating or moving files, but find command-t quicker for 227 | opening files. 228 | 229 | ### surround (`ys`/`cs`/`ds`) 230 | 231 | Allows adding/removing/changing of surroundings 232 | 233 | I would highly recommend getting to know this plugin, it is very useful. 234 | Especially when you grok text objects. 235 | 236 | *Characters* 237 | 238 | `ysiw)` - surround inner word with `()` 239 | 240 | `ysiw(` - surround inner word with `( )` 241 | 242 | In the above example `iw` can be replaced with any text object or motion. 243 | 244 | If you find yourself manually adding surroundings, stop and work out the 245 | correct text object or motion. 246 | 247 | `cs"'` - change surrounding from `"` to `'` 248 | 249 | `ds` - delete surrounding 250 | 251 | ### Install these vimfiles manually 252 | 253 | Note: You will already have a `~/.vim` folder, either delete or move it. 254 | 255 | cp -r ~/.vim ~/.vim.old 2>/dev/null 256 | rm -fr ~/.vim 2>/dev/null 257 | rm -f ~/.vimrc 2>/dev/null 258 | git clone https://github.com/srushti/vim-get.git ~/.vim && cd ~/.vim && rake update 259 | 260 | or run: 261 | 262 | curl https://raw.github.com/ravidsrk/vim-get/master/install.sh -o - | sh 263 | 264 | #### To update to the latest vimfiles 265 | 266 | cd ~/.vim 267 | rake preinstall 268 | 269 | #### Install Dependacies 270 | 271 | *MacOS* 272 | 273 | brew install ack 274 | brew install ctags 275 | 276 | Note: MacOS comes with the BSD version of ctags which is not compatible. 277 | 278 | *Ubuntu* 279 | 280 | sudo apt-get install exuberant-ctags 281 | sudo apt-get install ack-grep 282 | sudo ln -s /usr/bin/ack-grep /usr/local/bin/ack 283 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " ----------------------------------------------------------------------------- 2 | " | VIM Settings | 3 | " | (see gvimrc for gui vim settings) | 4 | " ----------------------------------------------------------------------------- 5 | 6 | set nocompatible " We don't want vi compatibility. 7 | 8 | let mapleader = "," 9 | let maplocalleader = "\\" 10 | set wildmenu 11 | set wildmode=list:longest,full 12 | set lazyredraw 13 | set autowriteall 14 | set autoread 15 | 16 | if has("nvim") 17 | set termguicolors 18 | endif 19 | 20 | " Show syntax highlighting groups for word under cursor 21 | nmap :call SynStack() 22 | function! SynStack() 23 | if !exists("*synstack") 24 | return 25 | endif 26 | echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') 27 | endfunc 28 | 29 | function! StripTrailingWhitespaces() 30 | if mode() == 'n' 31 | " Preparation: save last search, and cursor position. 32 | let _s=@/ 33 | let l = line(".") 34 | let c = col(".") 35 | " Do the business: 36 | %s/\s\+$//e 37 | " Clean up: restore previous search history, and cursor position 38 | let @/=_s 39 | call cursor(l, c) 40 | endif 41 | endfunction 42 | 43 | if has('autocmd') 44 | augroup buffer_filetype_autocmds 45 | au! 46 | autocmd FileType html let g:html_indent_strict=1 47 | autocmd BufEnter {Gemfile,Rakefile,Guardfile,Capfile,Vagrantfile,Thorfile,config.ru,*.rabl} setfiletype ruby 48 | autocmd BufEnter *.template setfiletype json 49 | autocmd BufEnter *.j setfiletype objc 50 | autocmd BufEnter *.md setfiletype markdown 51 | autocmd BufWritePre ?* :call StripTrailingWhitespaces() 52 | autocmd BufEnter *.yml.sample setfiletype yaml 53 | autocmd BufLeave,FocusLost ?* nested :wa 54 | autocmd BufReadPost #* set bufhidden=delete 55 | autocmd BufEnter *nginx.conf setfiletype nginx 56 | augroup END 57 | endif 58 | 59 | command! -nargs=0 -bar Qargs execute 'args ' . QuickfixFilenames() 60 | function! QuickfixFilenames() 61 | " Building a hash ensures we get each buffer only once 62 | let buffer_numbers = {} 63 | for quickfix_item in getqflist() 64 | let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr']) 65 | endfor 66 | return join(values(buffer_numbers)) 67 | endfunction 68 | 69 | " explicitly implementing suspend to force reloading changed files 70 | noremap :suspend:silent! checktime 71 | 72 | " Shortcuts******************************************************************** 73 | nmap w :w 74 | nmap W :wa 75 | nmap p "*p 76 | nmap :A 77 | nmap 78 | nmap 79 | nmap 80 | nmap 81 | cnoremap %% =expand('%:h').'/' 82 | nmap ew :e %% 83 | nmap es :sp %% 84 | nmap ev :vsp %% 85 | nmap et :tabe %% 86 | 87 | nnoremap h 88 | nnoremap j 89 | nnoremap k 90 | nnoremap l 91 | nnoremap w 92 | nnoremap W 93 | 94 | nnoremap 95 | 96 | inoremap A 97 | nnoremap Y y$ 98 | 99 | " Help 100 | autocmd FileType help :nnoremap q :q 101 | 102 | " Emacs style ctrl-a & ctrl-e in insert mode 103 | inoremap =InsCtrlE() 104 | function! InsCtrlE() 105 | try 106 | norm! i 107 | return "\A" 108 | catch 109 | return "\" 110 | endtry 111 | endfunction 112 | imap I 113 | 114 | " Tabs ************************************************************************ 115 | "set sta " a in an indent inserts 'shiftwidth' spaces 116 | 117 | " Files, backups and undo****************************************************** 118 | " Turn backup off, since most stuff is in SVN, git anyway... 119 | set nobackup 120 | set nowb 121 | set noswapfile 122 | 123 | "Persistent undo 124 | try 125 | if MySys() == "windows" 126 | set undodir=C:\Windows\Temp 127 | else 128 | set undodir=~expand('$HOME/.vim/tmp') 129 | endif 130 | 131 | set undofile 132 | catch 133 | endtry 134 | 135 | " Highlight VCS conflict markers 136 | match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' 137 | 138 | " Easy buffer navigation 139 | noremap h 140 | noremap j 141 | noremap k 142 | noremap l 143 | 144 | nnoremap gUiw 145 | inoremap gUiwea 146 | 147 | " Split line (sister to [J]oin lines) 148 | " The normal use of S is covered by cc, so don't worry about shadowing it. 149 | nnoremap S i 150 | 151 | " Better Completion 152 | set completeopt=menu,longest,preview 153 | 154 | " Toggle paste 155 | set pastetoggle= 156 | 157 | function! Tabstyle_tabs() 158 | " Using 4 column tabs 159 | set softtabstop=4 160 | set shiftwidth=4 161 | set tabstop=4 162 | set noexpandtab 163 | autocmd User Rails set softtabstop=4 164 | autocmd User Rails set shiftwidth=4 165 | autocmd User Rails set tabstop=4 166 | autocmd User Rails set noexpandtab 167 | endfunction 168 | 169 | function! Tabstyle_spaces() 170 | " Use 2 spaces 171 | set softtabstop=2 172 | set shiftwidth=2 173 | set tabstop=2 174 | set expandtab 175 | endfunction 176 | 177 | if hostname() == "Laptop.local" 178 | call Tabstyle_tabs() 179 | else 180 | call Tabstyle_spaces() 181 | endif 182 | 183 | " Indenting ******************************************************************* 184 | set autoindent " Automatically set the indent of a new line (local to buffer) 185 | set smartindent " smartindent (local to buffer) 186 | 187 | " Scrollbars ****************************************************************** 188 | set sidescrolloff=2 189 | set numberwidth=4 190 | 191 | " Spaces while joining ******************************************************** 192 | set nojoinspaces 193 | 194 | " Windows ********************************************************************* 195 | set equalalways " Multiple windows, when created, are equal in size 196 | set splitbelow splitright 197 | 198 | "Vertical split then hop to new buffer 199 | noremap v :vsp 200 | noremap h :split 201 | 202 | " Cursor highlights *********************************************************** 203 | au WinLeave * set nocursorline nocursorcolumn 204 | au WinEnter,BufEnter * set cursorline cursorcolumn 205 | set cursorline cursorcolumn 206 | set colorcolumn=120 207 | 208 | " Searching ******************************************************************* 209 | set hlsearch " highlight search 210 | nmap ? :nohlsearch 211 | set incsearch " incremental search, search as you type 212 | set ignorecase " Ignore case when searching 213 | set smartcase " Ignore case when searching lowercase 214 | 215 | " Colors ********************************************************************** 216 | "set t_Co=256 " 256 colors 217 | syntax on " syntax highlighting 218 | colorscheme camouflage 219 | 220 | if !has('gui_running') 221 | let g:airline_theme="solarized" 222 | endif 223 | 224 | " Status Line ***************************************************************** 225 | set showcmd 226 | set ruler " Show ruler 227 | "set ch=2 " Make command line two lines high 228 | set statusline=%<%F%h%m%r%h%w%y\ %{&ff}\ %{strftime(\"%d/%m/%Y-%H:%M\")}\ %{exists('g:loaded_rvm')?rvm#statusline():''}%=\ %l:%c%V\ %L\ %P 229 | set laststatus=2 230 | 231 | " Line Wrapping *************************************************************** 232 | set nowrap 233 | set linebreak " Wrap at word 234 | set showbreak=… 235 | 236 | " Per-directory .vimrc files 237 | set exrc 238 | set secure 239 | 240 | " Mappings ******************************************************************** 241 | " Professor VIM says '87% of users prefer jj over esc', jj abrams strongly disagrees 242 | imap jj 243 | imap uu _ 244 | imap hh => 245 | imap -- -> 246 | imap aa @ 247 | 248 | " Directories ***************************************************************** 249 | " Setup backup location and enable 250 | "set backupdir=~/backup/vim 251 | "set backup 252 | 253 | " Set Swap directory 254 | "set directory=~/backup/vim/swap 255 | 256 | " Sets path to directory buffer was loaded from 257 | "autocmd BufEnter * lcd %:p:h 258 | 259 | " File Stuff ****************************************************************** 260 | filetype plugin indent on 261 | " To show current filetype use: set filetype 262 | 263 | " Remember last location in file 264 | if has("autocmd") 265 | au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") 266 | \| exe "normal g'\"" | endif 267 | endif 268 | 269 | autocmd FileType html set filetype=xhtml " we couldn't care less about html 270 | 271 | " Inser New Line ************************************************************** 272 | map O 273 | map o 274 | set fo-=r " do not insert a comment leader after an enter, (no work, fix!!) 275 | 276 | " Sessions ******************************************************************** 277 | " Sets what is saved when you save a session 278 | set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize 279 | 280 | " Misc ************************************************************************ 281 | set backspace=indent,eol,start 282 | set number " Show line numbers 283 | set matchpairs+=<:> 284 | set vb t_vb= " Turn off the bell, this could be more annoying, but I'm not sure how 285 | 286 | " Set list Chars - for showing characters that are not 287 | " normally displayed i.e. whitespace, tabs, EOL 288 | nmap l :set list! 289 | set listchars=tab:▸\ ,eol:¬ 290 | 291 | " Mouse *********************************************************************** 292 | "set mouse=a " Enable the mouse 293 | "behave xterm 294 | "set selectmode=mouse 295 | 296 | " " Cursor Movement ************************************************************* 297 | " " Make cursor move by visual lines instead of file lines (when wrapping) 298 | map gk 299 | map k gk 300 | " imap gk # uncomment at your own risk. it interferes with Fuf. 301 | map gj 302 | map j gj 303 | " imap gj # same warning as the imap above. 304 | " map E ge 305 | 306 | " Ruby stuff ****************************************************************** 307 | compiler ruby " Enable compiler support for ruby 308 | map :!ruby % 309 | 310 | " Omni Completion ************************************************************* 311 | if has('autocmd') 312 | autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags 313 | autocmd FileType python set omnifunc=pythoncomplete#Complete 314 | autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS 315 | autocmd FileType css set omnifunc=csscomplete#CompleteCSS 316 | autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags 317 | autocmd FileType php set omnifunc=phpcomplete#CompletePHP 318 | autocmd FileType c set omnifunc=ccomplete#Complete 319 | autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete " may require ruby compiled in 320 | autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1 321 | autocmd FileType ruby,eruby let g:rubycomplete_rails = 1 322 | autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1 323 | endif 324 | 325 | " ----------------------------------------------------------------------------- 326 | " | Plugins | 327 | " ----------------------------------------------------------------------------- 328 | 329 | " Airline ********************************************************************* 330 | let g:airline_powerline_fonts = 1 331 | 332 | " NERDTree ******************************************************************** 333 | nmap n :NERDTreeToggle 334 | nmap / :NERDTreeFind 335 | 336 | " User instead of Netrw when doing an edit /foobar 337 | let NERDTreeHijackNetrw=1 338 | 339 | " Single click for everything 340 | let NERDTreeMouseMode=1 341 | 342 | " Ignoring java class files 343 | let NERDTreeIgnore=['.class$', '\~$', '^cscope', 'tags', 'node_modules', '.tmp'] 344 | 345 | " Rails.vim shortcuts ********************************************************* 346 | nmap s :.Rake 347 | nmap S :Rake 348 | nmap - :Rake - 349 | 350 | " Fugitive ******************************************************************** 351 | autocmd BufReadPost fugitive://* set bufhidden=delete 352 | autocmd BufReadPost *.fugitiveblame set bufhidden=delete 353 | autocmd BufReadPost .git/* set bufhidden=delete 354 | autocmd BufReadPost GoToFile set bufhidden=delete 355 | 356 | nnoremap gd :Gdiff 357 | nnoremap gs :Gstatus 358 | nnoremap gw :Gwrite 359 | nnoremap gb :Gblame 360 | nnoremap gci :Gcommit 361 | nnoremap gm :Gmove 362 | nnoremap gr :Gremove 363 | nnoremap gl :Glog 364 | 365 | augroup ft_fugitive 366 | au! 367 | 368 | au BufNewFile,BufRead .git/index setlocal nolist 369 | augroup END 370 | 371 | " yankring********************************************************************* 372 | let g:yankring_history_dir = expand('$HOME/.vim/tmp') 373 | nnoremap :YRShow 374 | 375 | " Ctrl-P ********************************************************************** 376 | let g:ctrlp_dont_split = 'NERD_tree_2' 377 | let g:ctrlp_jump_to_buffer = 0 378 | let g:ctrlp_working_path_mode = 0 379 | let g:ctrlp_match_window_reversed = 1 380 | let g:ctrlp_split_window = 0 381 | let g:ctrlp_max_height = 20 382 | let g:ctrlp_extensions = ['tag'] 383 | 384 | if filereadable("/usr/local/bin/fzf") && !has('gui_running') 385 | set rtp+=/usr/local/opt/fzf 386 | nnoremap f :FZF 387 | else 388 | let g:ctrlp_map = 'f' 389 | end 390 | 391 | let g:ctrlp_prompt_mappings = { 392 | \ 'PrtSelectMove("j")': ['', '', ''], 393 | \ 'PrtSelectMove("k")': ['', '', ''], 394 | \ 'PrtHistory(-1)': [''], 395 | \ 'PrtHistory(1)': [''], 396 | \ 'ToggleFocus()': [''], 397 | \ } 398 | 399 | let ctrlp_filter_greps = "". 400 | \ "egrep -iv '\\.(" . 401 | \ "swp|swo|log|so|o|pyc|jpe?g|png|gif|mo|po|class|jar|DS_Store" . 402 | \ ")$' | " . 403 | \ "egrep -v '^(\\./)?(" . 404 | \ "libs/|deploy/vendor/|.git/|.hg/|.svn/|tmp/|.tmp/|.idea/|node_modules/|.sass-cache/|bower_components/|_vendor/vendor/" . 405 | \ ")'" 406 | 407 | let my_ctrlp_user_command = "" . 408 | \ "find %s '(' -type f -or -type l ')' -maxdepth 15 -not -path '*/\\.*/*' | " . 409 | \ ctrlp_filter_greps 410 | 411 | let my_ctrlp_git_command = "" . 412 | \ "cd %s && git ls-files && git ls-files -o | " . 413 | \ ctrlp_filter_greps 414 | 415 | let g:ctrlp_user_command = ['.git/', my_ctrlp_git_command, my_ctrlp_user_command] 416 | 417 | nnoremap t :CtrlPTag 418 | nnoremap b :CtrlPBuffer 419 | 420 | " Mundo *********************************************************************** 421 | nmap u :MundoToggle 422 | "autocmd BufReadPost __Mundo_* set bufhidden=delete 423 | 424 | " Tagbar ********************************************************************** 425 | nmap c :TagbarToggle 426 | 427 | " Ack ************************************************************************* 428 | if has('linux') 429 | let g:ackprg="ack-grep -H --nocolor --nogroup --column" 430 | endif 431 | map a :Ack! 432 | 433 | " Turbux ********************************************************************** 434 | let g:no_turbux_mappings = 1 435 | 436 | " Git Gutter ****************************************************************** 437 | if has('autocmd') 438 | augroup gitgutter_cmds 439 | au! 440 | autocmd BufReadPost ?* GitGutterAll 441 | autocmd FocusLost ?* GitGutterAll 442 | augroup END 443 | endif 444 | 445 | let g:gitgutter_realtime = 0 446 | let g:gitgutter_eager = 0 447 | 448 | " Syntastic ******************************************************************* 449 | 450 | let g:syntastic_coffee_checkers = ['coffeelint'] 451 | let g:syntastic_coffee_coffeelint_args = "--reporter csv --file ~/.coffeelint.json" 452 | 453 | " autocomplpop **************************************************************** 454 | " complete option 455 | "set complete=.,w,b,u,t,k 456 | "let g:AutoComplPop_CompleteOption = '.,w,b,u,t,k' 457 | "set complete=. 458 | let g:AutoComplPop_IgnoreCaseOption = 0 459 | let g:AutoComplPop_BehaviorKeywordLength = 2 460 | 461 | let g:EasyMotion_smartcase = 1 462 | 463 | " Unimpaired configuration **************************************************** 464 | " Bubble single lines 465 | nmap [e== 466 | nmap [e== 467 | nmap ]e== 468 | nmap ]e== 469 | " Bubble multiple lines 470 | vmap [egv=gv 471 | vmap [egv=gv 472 | vmap ]egv=gv 473 | vmap ]egv=gv 474 | 475 | " UltiSnips ******************************************************************* 476 | 477 | " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. 478 | let g:UltiSnipsExpandTrigger="" 479 | let g:UltiSnipsJumpForwardTrigger="" 480 | let g:UltiSnipsJumpBackwardTrigger="" 481 | 482 | " If you want :UltiSnipsEdit to split your window. 483 | let g:UltiSnipsEditSplit="vertical" 484 | 485 | " Vimux *********************************************************************** 486 | nmap vpc :wa:VimuxPromptCommand 487 | nmap vrlc :wa:VimuxRunLastCommand 488 | nmap r :wa:VimuxRunLastCommand 489 | 490 | " Vim.go ********************************************************************** 491 | let g:syntastic_go_checkers = ['goimports', 'golint', 'govet', 'errcheck'] 492 | let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] } 493 | let g:go_fmt_command = 'goimports' 494 | 495 | " ----------------------------------------------------------------------------- 496 | " | OS Specific | 497 | " | (GUI stuff goes in gvimrc) | 498 | " ----------------------------------------------------------------------------- 499 | 500 | " Mac ************************************************************************* 501 | if has("mac") 502 | endif 503 | 504 | " Windows ********************************************************************* 505 | "if has("gui_win32") 506 | "" 507 | "endif 508 | 509 | " ----------------------------------------------------------------------------- 510 | " | Startup | 511 | " ----------------------------------------------------------------------------- 512 | " Open NERDTree on start 513 | "autocmd VimEnter * exe 'NERDTree' | wincmd l 514 | 515 | " Add recently accessed projects menu (project plugin) 516 | filetype on " Automatically detect file types. 517 | 518 | " Minibuffer Explorer Settings 519 | let g:miniBufExplMapWindowNavVim = 1 520 | let g:miniBufExplMapWindowNavArrows = 1 521 | let g:miniBufExplMapCTabSwitchBufs = 1 522 | let g:miniBufExplModSelTarget = 1 523 | 524 | set hid 525 | 526 | " alt+n or alt+p to navigate between entries in QuickFix 527 | map :cp 528 | map :cn 529 | 530 | " Change which file opens after executing :Rails command 531 | let g:rails_default_file='config/database.yml' 532 | 533 | syntax enable 534 | 535 | filetype plugin on 536 | set ofu=syntaxcomplete#Complete 537 | 538 | " Last but not least, allow for local overrides 539 | if filereadable(expand("~/.vimrc.local")) 540 | source ~/.vimrc.local 541 | endif 542 | --------------------------------------------------------------------------------