pvim 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a5a4c5354f472cc741b3c4a4d411d48a26e9530
4
+ data.tar.gz: 06974f86aa259968983a945e8ffdbe5a9dc5ee6e
5
+ SHA512:
6
+ metadata.gz: 4e113dc865bb84b6b64967b9487ef8501e5b6a38d0e2be145df80288bf4d130fb7c2b6a83d4a5f6126489502be08ba921faf10864fa2121a25c5fd683b8a7c3b
7
+ data.tar.gz: 3b834cf6210d0aa93780937dd40d8950b5743ae93116761436e4fd688a8c94aa905e202ef6201ca53c83277806c453ab29b038c645513c689e75afeaed27f298
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
19
+ .ruby-version
20
+ .ruby-gemset
21
+ .rbenv-gemsets
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pvim.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Phong Nguyen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Pvim
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pvim'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pvim
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'thor'
5
+ require 'pvim'
6
+
7
+ Pvim::CLI.start
@@ -0,0 +1,85 @@
1
+ set nocompatible " No Vi Compatibility
2
+ set noswapfile " Turn off swapfile
3
+
4
+ " tpope/vim-pathogen
5
+ execute pathogen#infect()
6
+ syntax on
7
+ filetype plugin indent on
8
+
9
+ set hidden " Hide buffer when not displayed
10
+
11
+ set gdefault " Substitute multiple times per line by default
12
+
13
+ set encoding=utf-8 " Default encoding
14
+
15
+ set fileformats=unix,dos,mac
16
+
17
+ set backspace=indent,eol,start " Allow backspacing over everything in insert mode
18
+
19
+ " Toggle spell checking
20
+ " nnoremap <F6> :set spell!<CR>
21
+
22
+ set noruler " Hide line and column number of the cursor position
23
+ set number " Show line numbers
24
+ set cursorline " Highlight current line
25
+
26
+ " Display tabs and trailing spaces
27
+ set list
28
+ set listchars=tab:▷⋅,trail:⋅,nbsp:⋅
29
+ set wrap " Don't wrap lines
30
+ set linebreak " Wrap lines at convenient point
31
+ " nnoremap <F9> :set wrap!<CR>
32
+
33
+ set linespace=4 " Add some line space for easy reading
34
+
35
+ " Default indent settings
36
+ set tabstop=4
37
+ set shiftwidth=4
38
+ set softtabstop=4
39
+ set expandtab
40
+ set smarttab
41
+ set autoindent
42
+ set smartindent
43
+
44
+ " Folding settings
45
+ set foldmethod=indent " Fold based on indent
46
+ set foldnestmax=3 " Deepest fold is 3 levels
47
+ set nofoldenable " Don't fold by default
48
+
49
+ set wildmode=list:longest " Make cmdline tab completion similar to bash
50
+ set wildmenu " Enable ctrl-n and ctrl-p to scroll thru matches
51
+ set wildignore=*.dll,*.o,*.obj,*~,*.pyc,*.bak,*.exe,*.jpg,*.jpeg,*.png,*.gif,*$py.class,*.class " Stuff to ignore when tab completing
52
+
53
+ " Disable Toolbar, Scrollbar
54
+ set guioptions-=T
55
+ set guioptions-=r
56
+
57
+ set formatoptions-=o " Don't continue comments when pushing o/O
58
+
59
+ " Vertical / Horizontal scroll off settings
60
+ set scrolloff=3
61
+ set sidescrolloff=7
62
+ set sidescroll=1
63
+
64
+ set showmatch
65
+ set incsearch " Find the next match as we type the search
66
+ set hlsearch " Highlight searches by default
67
+
68
+ set mouse=a " Enable mouse everywhere
69
+ set mousehide " Hide mouse pointer while typing
70
+ set mousemodel=popup
71
+
72
+ set ttymouse=xterm2
73
+ set ttyfast
74
+
75
+ set history=1000 " Store lots of :cmdline history
76
+ set showcmd " Show incomplete cms down the bottom
77
+ set showmode " Show current mode down the bottom
78
+ set cmdheight=2
79
+
80
+ set laststatus=2 " Status in two lines
81
+
82
+ set viminfo=!,'100,\"100,:20,<50,s10,h,n~/.vim/.viminfo " Remember where we are, support yankring
83
+
84
+ set t_Co=256 " Enable 256 colors
85
+
@@ -0,0 +1,2 @@
1
+ require "pvim/version"
2
+ require "pvim/cli"
@@ -0,0 +1,38 @@
1
+ require 'pvim/version'
2
+ require 'pvim/plugin'
3
+
4
+ module Pvim
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+
8
+ def self.source_root
9
+ File.expand_path File.join('..', '..', '..', 'config'), __FILE__
10
+ end
11
+
12
+ desc 'version', 'Prints version'
13
+ def version
14
+ puts Pvim::VERSION
15
+ end
16
+
17
+ desc 'pathogen [DIR]', "Copy Pathogen from https://github.com/tpope/vim-pathogen to a pvim directory. Default: #{Dir.pwd}"
18
+ def pathogen(dir=Dir.pwd)
19
+ get "https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim",
20
+ File.join(dir, 'autoload/pathogen.vim')
21
+ end
22
+
23
+ desc 'setup [DIR]', "Setup a pvim directory. Default: #{File.join(Dir.pwd, 'pvim')}"
24
+ def setup(dir=File.join(Dir.pwd, 'pvim'))
25
+ dir = empty_directory(dir)
26
+ inside dir do
27
+ empty_directory 'autoload'
28
+ empty_directory 'bundle'
29
+ pathogen dir
30
+ copy_file File.join(self.class.source_root, 'vimrc'), 'vimrc'
31
+ run "git init"
32
+ end
33
+ end
34
+
35
+ desc 'plugin SUBCOMMAND', 'Manage vim scripts'
36
+ subcommand 'plugin', Pvim::Plugin
37
+ end
38
+ end
@@ -0,0 +1,132 @@
1
+ module Pvim
2
+ class Plugin < Thor
3
+ include Thor::Actions
4
+
5
+ class_option :pvim,
6
+ :aliases => 'p',
7
+ :default => File.expand_path(Dir.pwd),
8
+ :desc => 'Your current pvim director'
9
+
10
+ option :sort, :aliases => '-s', :type => :boolean, :default => false, :desc => 'Sort installed plugins by name'
11
+ desc 'list', 'List all installed vim plugins'
12
+ def list
13
+ inside pvim do
14
+ plugins = load_plugins
15
+ plugins = plugins.values
16
+ if plugins.any?
17
+ plugins.sort_by!{ |(name, _, _)| name.downcase } if options[:sort]
18
+ say "Installed plugins:", Color::GREEN
19
+ say
20
+ plugins.unshift [ 'Name', 'Repository URL', 'Installed at' ]
21
+ print_table plugins
22
+ say
23
+ say "Total: #{plugins.size - 1}"
24
+ else
25
+ say "No installed plugins."
26
+ end
27
+ end
28
+ end
29
+
30
+ desc 'add URL', 'Add vim plugins'
31
+ def add(url)
32
+ check_url(url)
33
+ inside pvim do
34
+ empty_directory bundle_dir
35
+ run "git submodule add #{url.inspect} #{installed_dir(url).inspect}"
36
+ end
37
+ end
38
+
39
+ desc 'remove URL', 'Remove vim plugins'
40
+ def remove(url)
41
+ check_url(url)
42
+ if plugin = find_plugin(url)
43
+ inside pvim do
44
+ empty_directory bundle_dir
45
+ path = plugin.last
46
+ submodule = ['submodule', path].join('.')
47
+ run "git submodule deinit -f #{path.inspect}"
48
+ run "git rm -rf #{path.inspect}"
49
+ run "git config -f .gitmodules --remove-section #{submodule.inspect}"
50
+ remove_file File.join('.git', 'modules', path)
51
+ end
52
+ else
53
+ say "#{url} is not installed", Color::RED
54
+ end
55
+ end
56
+
57
+ desc 'update', 'Update all vim plugins to latest versions'
58
+ def update
59
+ inside pvim do
60
+ empty_directory bundle_dir
61
+ run "git submodule update"
62
+ end
63
+ end
64
+
65
+ private
66
+ def pvim
67
+ @pvim ||= File.expand_path(options[:pvim] || Dir.pwd)
68
+ end
69
+
70
+ def bundle_dir
71
+ @bundle_dir ||= File.join(pvim, 'bundle')
72
+ end
73
+
74
+ def installed_dir(url)
75
+ repo = url.gsub(/^https?\:\/\/github\.com\//, '') # <user>/<project>
76
+ File.join(bundle_dir.gsub(pvim+'/', ''), repo.gsub('/', '-'))
77
+ end
78
+
79
+ def gitmodules
80
+ @gitmodules ||= File.join(pvim, '.gitmodules')
81
+ end
82
+
83
+ def git_config
84
+ @git_config ||= File.join(pvim, '.git', 'config')
85
+ end
86
+
87
+ def load_plugins
88
+ return @plugins if @plugins
89
+
90
+ unless File.exists?(gitmodules)
91
+ say ".gitmodules does not exist.", Color::RED
92
+ exit(1)
93
+ end
94
+
95
+ @plugins = {}
96
+ lines = File.readlines(gitmodules)
97
+ lines.map!(&:chomp)
98
+ lines.delete_if(&:empty?)
99
+ lines.each_slice(3) do |(_, path, url)|
100
+ path = value(path)
101
+ url = value(url)
102
+ name = repo_name(url)
103
+ @plugins[url] = [name, url, path]
104
+ end
105
+
106
+ @plugins
107
+ end
108
+
109
+ def check_url(url)
110
+ unless is_github_url?(url)
111
+ say "URL must be a valid github url"
112
+ exit(1)
113
+ end
114
+ end
115
+
116
+ def find_plugin(url)
117
+ load_plugins[url]
118
+ end
119
+
120
+ def is_github_url?(url)
121
+ !!url.match(/^https?\:\/\/github\.com\/[a-z0-9\-\._]+\/[a-z0-9\-\._]+$/)
122
+ end
123
+
124
+ def value(s)
125
+ s.gsub(/^\t/, '').split(' = ').last
126
+ end
127
+
128
+ def repo_name(url)
129
+ url.gsub(/^https?:\/\/github.com\//, '').split('/').last
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,3 @@
1
+ module Pvim
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pvim/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pvim"
8
+ spec.version = Pvim::VERSION
9
+ spec.authors = ["Phong Nguyen"]
10
+ spec.email = ["nhphong1406@gmail.com"]
11
+ spec.description = %q{Pvim is tool for managing vim plugins using Pathogen with Git Submodules}
12
+ spec.summary = spec.description
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency "thor", '~> 0.18'
25
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pvim
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Phong Nguyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.18'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.18'
55
+ description: Pvim is tool for managing vim plugins using Pathogen with Git Submodules
56
+ email:
57
+ - nhphong1406@gmail.com
58
+ executables:
59
+ - pvim
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/pvim
69
+ - config/vimrc
70
+ - lib/pvim.rb
71
+ - lib/pvim/cli.rb
72
+ - lib/pvim/plugin.rb
73
+ - lib/pvim/version.rb
74
+ - pvim.gemspec
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.0.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Pvim is tool for managing vim plugins using Pathogen with Git Submodules
99
+ test_files: []