Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ vim/.netrwhist
vim/tmp
vim/spell
vim/after/.vimrc.after
vim/.vundles.local
vim/.vundles.local.bak
vim/bundle
vim/.local.bundles
vim/.local.bundles.bak
vim/plugged
vim/autoload/plug.vim
vim/sessions
.netrwhist
bin/subl
Expand Down
52 changes: 29 additions & 23 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rake'
require 'fileutils'
require File.join(File.dirname(__FILE__), 'bin', 'yadr', 'vundle')
require File.join(File.dirname(__FILE__), 'bin', 'yadr', 'vimplug')

desc "Hook our dotfiles into system-standard positions."
task :install => [:submodule_init, :submodules] do
Expand All @@ -22,7 +22,7 @@ task :install => [:submodule_init, :submodules] do
install_files(Dir.glob('vimify/*')) if want_to_install?('vimification of command line tools')
if want_to_install?('vim configuration (highly recommended)')
install_files(Dir.glob('{vim,vimrc}'))
Rake::Task["install_vundle"].execute
Rake::Task["install_plugins"].execute
end

Rake::Task["install_prezto"].execute
Expand All @@ -44,7 +44,7 @@ end

desc 'Updates the installation'
task :update do
Rake::Task["vundle_migration"].execute if needs_migration_to_vundle?
Rake::Task["plug_migration"].execute if needs_migration_to_plug?
Rake::Task["install"].execute
#TODO: for now, we do the same as install. But it would be nice
#not to clobber zsh files
Expand Down Expand Up @@ -72,43 +72,49 @@ task :submodules do
end
end

desc "Performs migration from pathogen to vundle"
task :vundle_migration do
desc "Performs migration from vundle to vim-plug"
task :plug_migration do
puts "======================================================"
puts "Migrating from pathogen to vundle vim plugin manager. "
puts "This will move the old .vim/bundle directory to"
puts "Migrating from vundle to vim-plug plugin manager. "
puts "This will move the old .vim/bundle directory to "
puts ".vim/bundle.old and replacing all your vim plugins with"
puts "the standard set of plugins. You will then be able to "
puts "manage your vim's plugin configuration by editing the "
puts "file .vim/vundles.vim"
puts "file .vim/plugins.d/main.vim"
puts "======================================================"

Dir.glob(File.join('vim', 'bundle','**')) do |sub_path|
run %{git config -f #{File.join('.git', 'config')} --remove-section submodule.#{sub_path}}
# `git rm --cached #{sub_path}`
FileUtils.rm_rf(File.join('.git', 'modules', sub_path))
end
FileUtils.mv(File.join('vim','bundle'), File.join('vim', 'bundle.old'))
# Rename local vundles file
vundle_path = File.join('vim','.vundles.local')
if File.exists?(vundle_path)
FileUtils.mv(vundle_path, File.join('vim', '.local.bundles'))
puts "Replace all Bundle started lines with Plug"
run %q{ ruby -pi.bak -e "gsub(/^Bundle/, 'Plug')" .local.bundles }
end
vundle_path_bak = File.join('vim','.vundles.local.bak')
if File.exists?(vundle_path_bak)
FileUtils.mv(vundle_path_bak, File.join('vim', '.local.bundles.bak'))
end
end

desc "Runs Vundle installer in a clean vim environment"
task :install_vundle do
desc "Runs Vim-Plug installer in a clean vim environment"
task :install_plugins do
puts "======================================================"
puts "Installing and updating vundles."
puts "The installer will now proceed to run PluginInstall to install vundles."
puts "Installing and updating bundles."
puts "The installer will now proceed to run PlugInstall to install bundles."
puts "======================================================"

puts ""

vundle_path = File.join('vim','bundle', 'vundle')
unless File.exists?(vundle_path)
plug_path = File.join('vim','autoload', 'plug.vim')
unless File.exists?(plug_path)
run %{
cd $HOME/.yadr
git clone https://github.com/gmarik/vundle.git #{vundle_path}
curl -fLo #{plug_path} --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
}
end

Vundle::update_vundle
VimPlug::update_bundles
end

task :default => 'install'
Expand Down Expand Up @@ -326,8 +332,8 @@ def install_files(files, method = :symlink)
end
end

def needs_migration_to_vundle?
File.exists? File.join('vim', 'bundle', 'tpope-vim-pathogen')
def needs_migration_to_plug?
File.exists?(File.join('vim', 'bundle', 'vundle')) || File.exists?(File.join('vim', 'bundle', 'Vundle.vim'))
end


Expand Down
50 changes: 50 additions & 0 deletions bin/yadr/vimplug.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require 'fileutils'

module VimPlug
@bundles_path = File.expand_path File.join(ENV['HOME'], '.vim', '.local.bundles')
def self.add_plugin_to_bundles(plugin_repo)
return if contains_bundle? plugin_repo

bundles = bundles_from_file
last_bundle_dir = bundles.rindex{ |line| line =~ /^Plug / }
last_bundle_dir = last_bundle_dir ? last_bundle_dir+1 : 0
bundles.insert last_bundle_dir, "Plug '#{plugin_repo}'"
write_bundles_to_file bundles
end

def self.remove_plugin_from_bundles(plugin_repo)
bundles = bundles_from_file
deleted_value = bundles.reject!{ |line| line =~ /Plug '#{plugin_repo}'/ }

write_bundles_to_file bundles

!deleted_value.nil?
end

def self.bundle_list
bundles_from_file.select{ |line| line =~ /^Plug .*/ }.map{ |line| line.gsub(/Plug "(.*)"/, '\1')}
end

def self.update_bundles
system "vim --noplugin -u #{ENV['HOME']}/.vim/plugins.d/main.vim -N \"+set hidden\" \"+syntax on\" \"+let g:session_autosave = 'no'\" +PlugClean +PlugInstall! +qall"
end


private
def self.contains_bundle?(bundle_name)
FileUtils.touch(@bundles_path) unless File.exists? @bundles_path
File.read(@bundles_path).include?(bundle_name)
end

def self.bundles_from_file
FileUtils.touch(@bundles_path) unless File.exists? @bundles_path
File.read(@bundles_path).split("\n")
end

def self.write_bundles_to_file(bundles)
FileUtils.cp(@bundles_path, "#{@bundles_path}.bak")
bundle_file = File.open(@bundles_path, "w")
bundle_file.write(bundles.join("\n"))
bundle_file.close
end
end
50 changes: 0 additions & 50 deletions bin/yadr/vundle.rb

This file was deleted.

8 changes: 4 additions & 4 deletions bin/yadr/yadr-vim-add-plugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
#
#
require File.join(File.dirname(__FILE__), 'default_libs')
require File.join(File.dirname(__FILE__), 'vundle')
require File.join(File.dirname(__FILE__), 'vimplug')

GitStyleBinary.command do
version "yadr-add-vim-plugin 1.0"
Expand All @@ -22,7 +22,7 @@ GitStyleBinary.command do
repo=command.opts[:url]
puts "Adding \"#{repo}\" to the plugin list"
bundle_path=repo.gsub(/http.?:\/\/github\.com\//, "")
Vundle::add_plugin_to_vundle repo
Vundle::update_vundle
VimPlug::add_plugin_to_bundles repo
VimPlug::update_bundles
end
end
6 changes: 3 additions & 3 deletions bin/yadr/yadr-vim-delete-plugin
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), 'default_libs')
require File.join(File.dirname(__FILE__), 'vundle')
require File.join(File.dirname(__FILE__), 'vimplug')

GitStyleBinary.command do
version "yadr-delete-vim-plugin 1.0"
Expand All @@ -19,9 +19,9 @@ GitStyleBinary.command do
repo=command.opts[:url]
puts "Removing \"#{repo}\" from the plugin list"
bundle_path=repo.gsub("https://github.com/", "")
removed=Vundle::remove_plugin_from_vundle repo
removed=VimPlug::remove_plugin_from_bundles repo
if removed
Vundle::update_vundle
VimPlug::update_bundles
puts "Successfully removed\"#{repo}\""
else
puts "Unable to find \"#{repo}\" among the installed plugins"
Expand Down
6 changes: 3 additions & 3 deletions bin/yadr/yadr-vim-list-plugin
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), 'default_libs')
require File.join(File.dirname(__FILE__), 'vundle')
require File.join(File.dirname(__FILE__), 'vimplug')

GitStyleBinary.command do
version "yadr-list-vim-plugin 1.0"
Expand All @@ -11,9 +11,9 @@ GitStyleBinary.command do
Usage: yadr-list-vim-plugin
EOS
run do |command|
puts "Currently configured plugins:"
puts "Currently configured plugins:"
i=1
Vundle::vundle_list.each do |plugin|
VimPlug::bundle_list.each do |plugin|
puts "#{i}. #{plugin}"
i=i+1
end
Expand Down
10 changes: 10 additions & 0 deletions vim/plugins.d/appearance.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Plug 'chrisbra/color_highlight'
Plug 'skwp/vim-colors-solarized'
Plug 'itchyny/lightline.vim'
Plug 'jby/tmux.vim'
Plug 'morhetz/gruvbox'
Plug 'xsunsmile/showmarks'
Plug 'chriskempson/base16-vim'

" Required for Gblame in terminal vim
Plug 'godlygeek/csapprox'
4 changes: 4 additions & 0 deletions vim/plugins.d/git.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Plug 'gregsexton/gitv', { 'on': 'Gitv' }
Plug 'mattn/gist-vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-git'
10 changes: 10 additions & 0 deletions vim/plugins.d/languages.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Plug 'sheerun/vim-polyglot'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
Plug 'jtratner/vim-flavored-markdown'
Plug 'vim-syntastic/syntastic'
Plug 'nelstrom/vim-markdown-preview'
Plug 'skwp/vim-html-escape'
Plug 'mxw/vim-jsx'
Plug 'jparise/vim-graphql'

40 changes: 40 additions & 0 deletions vim/plugins.d/main.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
" ========================================
" Vim plugin configuration
" ========================================
"
" This file contains the list of plugin installed using vim-plug plugin manager.
" Once you've updated the list of plugin, you can run plugin update by issuing
" the command :PlugInstall from within vim or directly invoking it from the
" command line with the following syntax:
" vim --noplugin -u vim/plugins.d/main.vim -N "+set hidden" "+syntax on" +PlugClean! +PlugInstall +qall

if empty(glob('~/.vim' . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source %
endif

set rtp+=~/.vim/plugins.d/ "Submodules

" Directory for plugins
call plug#begin('~/.vim/plugged')

" YADR's plugins are split up by category into smaller files
" This reduces churn and makes it easier to fork. See
" ~/.vim/plugged/ to edit them:
runtime ruby.bundles
runtime languages.bundles
runtime git.bundles
runtime appearance.bundles
runtime textobjects.bundles
runtime search.bundles
runtime project.bundles
runtime vim-improvements.bundles

" The plugins listed in ~/.vim/.local.bundles will be added here to
" allow the user to add vim plugins to yadr without the need for a fork.
if filereadable(expand("~/.yadr/vim/.local.bundles"))
source ~/.yadr/vim/.local.bundles
endif

" All of your Plugins must be added before the following line
call plug#end() " required
7 changes: 7 additions & 0 deletions vim/plugins.d/project.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Plug 'jistr/vim-nerdtree-tabs'
Plug 'preservim/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'JazzCore/ctrlp-cmatcher'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': { -> fzf#install() } }
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
10 changes: 10 additions & 0 deletions vim/plugins.d/ruby.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Plug 'ecomba/vim-ruby-refactoring'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rvm'
Plug 'vim-ruby/vim-ruby'
Plug 'keith/rspec.vim'
Plug 'skwp/vim-iterm-rspec'
Plug 'skwp/vim-spec-finder'
Plug 'ck3g/vim-change-hash-syntax'
Plug 'tpope/vim-bundler'
6 changes: 6 additions & 0 deletions vim/plugins.d/search.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Plug 'justinmk/vim-sneak'
Plug 'rking/ag.vim'
Plug 'henrik/vim-indexed-search'
Plug 'nelstrom/vim-visual-star-search'
Plug 'skwp/greplace.vim'
Plug 'Lokaltog/vim-easymotion'
15 changes: 15 additions & 0 deletions vim/plugins.d/textobjects.bundles
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
" These bundles introduce new textobjects into vim,
" For example the Ruby one introduces the 'r' text object
" such that 'var' gives you Visual Around Ruby
Plug 'austintaylor/vim-indentobject'
Plug 'bootleq/vim-textobj-rubysymbol'
Plug 'coderifous/textobj-word-column.vim'
Plug 'kana/vim-textobj-datetime'
Plug 'kana/vim-textobj-entire'
Plug 'kana/vim-textobj-function'
Plug 'kana/vim-textobj-user'
Plug 'lucapette/vim-textobj-underscore'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'nelstrom/vim-textobj-rubyblock'
Plug 'thinca/vim-textobj-function-javascript'
Plug 'wellle/targets.vim'
Loading