vimmy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in vimmy.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vimmy (0.0.1)
5
+ mechanize (~> 1.0.0)
6
+ thor (~> 0.14.6)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ mechanize (1.0.0)
12
+ nokogiri (>= 1.2.1)
13
+ nokogiri (1.4.4)
14
+ thor (0.14.6)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ mechanize (~> 1.0.0)
21
+ thor (~> 0.14.6)
22
+ vimmy!
@@ -0,0 +1,20 @@
1
+ # vimmy
2
+
3
+ ## Installation
4
+
5
+ gem install vimmy
6
+
7
+ ## Usage
8
+
9
+ # prepare your ~/.vim and ~/.vimrc
10
+ $ vimmy init
11
+
12
+ # search for a vim plugin
13
+ $ vimmy search jquery
14
+
15
+ # install a vim plugin
16
+ $ vimmy install jquery
17
+
18
+ ## License
19
+
20
+ MIT
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "vimmy/cli"
6
+
7
+ Vimmy::CLI.start
@@ -0,0 +1,139 @@
1
+ " pathogen.vim - path option manipulation
2
+ " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
3
+ " Version: 1.2
4
+
5
+ " Install in ~/.vim/autoload (or ~\vimfiles\autoload).
6
+ "
7
+ " API is documented below.
8
+
9
+ if exists("g:loaded_pathogen") || &cp
10
+ finish
11
+ endif
12
+ let g:loaded_pathogen = 1
13
+
14
+ " Split a path into a list.
15
+ function! pathogen#split(path) abort " {{{1
16
+ if type(a:path) == type([]) | return a:path | endif
17
+ let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
18
+ return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
19
+ endfunction " }}}1
20
+
21
+ " Convert a list to a path.
22
+ function! pathogen#join(...) abort " {{{1
23
+ if type(a:1) == type(1) && a:1
24
+ let i = 1
25
+ let space = ' '
26
+ else
27
+ let i = 0
28
+ let space = ''
29
+ endif
30
+ let path = ""
31
+ while i < a:0
32
+ if type(a:000[i]) == type([])
33
+ let list = a:000[i]
34
+ let j = 0
35
+ while j < len(list)
36
+ let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
37
+ let path .= ',' . escaped
38
+ let j += 1
39
+ endwhile
40
+ else
41
+ let path .= "," . a:000[i]
42
+ endif
43
+ let i += 1
44
+ endwhile
45
+ return substitute(path,'^,','','')
46
+ endfunction " }}}1
47
+
48
+ " Convert a list to a path with escaped spaces for 'path', 'tag', etc.
49
+ function! pathogen#legacyjoin(...) abort " {{{1
50
+ return call('pathogen#join',[1] + a:000)
51
+ endfunction " }}}1
52
+
53
+ " Remove duplicates from a list.
54
+ function! pathogen#uniq(list) abort " {{{1
55
+ let i = 0
56
+ let seen = {}
57
+ while i < len(a:list)
58
+ if has_key(seen,a:list[i])
59
+ call remove(a:list,i)
60
+ else
61
+ let seen[a:list[i]] = 1
62
+ let i += 1
63
+ endif
64
+ endwhile
65
+ return a:list
66
+ endfunction " }}}1
67
+
68
+ " Returns a hash indicating which filetype features are enabled.
69
+ function! pathogen#filetype() abort " {{{1
70
+ redir => output
71
+ silent filetype
72
+ redir END
73
+ let result = {}
74
+ let result.detection = match(output,'detection:ON') >= 0
75
+ let result.indent = match(output,'indent:ON') >= 0
76
+ let result.plugin = match(output,'plugin:ON') >= 0
77
+ return result
78
+ endfunction " }}}1
79
+
80
+ " \ on Windows unless shellslash is set, / everywhere else.
81
+ function! pathogen#separator() abort " {{{1
82
+ return !exists("+shellslash") || &shellslash ? '/' : '\'
83
+ endfunction " }}}1
84
+
85
+ " Convenience wrapper around glob() which returns a list.
86
+ function! pathogen#glob(pattern) abort " {{{1
87
+ let files = split(glob(a:pattern),"\n")
88
+ return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
89
+ endfunction "}}}1
90
+
91
+ " Like pathogen#glob(), only limit the results to directories.
92
+ function! pathogen#glob_directories(pattern) abort " {{{1
93
+ return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
94
+ endfunction "}}}1
95
+
96
+ " Prepend all subdirectories of path to the rtp, and append all after
97
+ " directories in those subdirectories.
98
+ function! pathogen#runtime_prepend_subdirectories(path) " {{{1
99
+ let sep = pathogen#separator()
100
+ let before = pathogen#glob_directories(a:path.sep."*[^~]")
101
+ let after = pathogen#glob_directories(a:path.sep."*[^~]".sep."after")
102
+ let rtp = pathogen#split(&rtp)
103
+ let path = expand(a:path)
104
+ call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
105
+ let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
106
+ return &rtp
107
+ endfunction " }}}1
108
+
109
+ " For each directory in rtp, check for a subdirectory named dir. If it
110
+ " exists, add all subdirectories of that subdirectory to the rtp, immediately
111
+ " after the original directory. If no argument is given, 'bundle' is used.
112
+ " Repeated calls with the same arguments are ignored.
113
+ function! pathogen#runtime_append_all_bundles(...) " {{{1
114
+ let sep = pathogen#separator()
115
+ let name = a:0 ? a:1 : 'bundle'
116
+ let list = []
117
+ for dir in pathogen#split(&rtp)
118
+ if dir =~# '\<after$'
119
+ let list += pathogen#glob_directories(substitute(dir,'after$',name.sep.'*[^~]'.sep.'after','')) + [dir]
120
+ else
121
+ let list += [dir] + pathogen#glob_directories(dir.sep.name.sep.'*[^~]')
122
+ endif
123
+ endfor
124
+ let &rtp = pathogen#join(pathogen#uniq(list))
125
+ return 1
126
+ endfunction
127
+
128
+ " }}}1
129
+
130
+ " Invoke :helptags on all non-$VIM doc directories in runtimepath.
131
+ function! pathogen#helptags() " {{{1
132
+ for dir in pathogen#split(&rtp)
133
+ if dir[0 : strlen($VIM)-1] !=# $VIM && isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
134
+ helptags `=dir.'/doc'`
135
+ endif
136
+ endfor
137
+ endfunction " }}}1
138
+
139
+ " vim:set ft=vim ts=8 sw=2 sts=2:
@@ -0,0 +1,3 @@
1
+ filetype off
2
+ call pathogen#helptags()
3
+ call pathogen#runtime_append_all_bundles()
@@ -0,0 +1,3 @@
1
+ module Vimmy
2
+ # Your code goes here...
3
+ end
@@ -0,0 +1,101 @@
1
+ require "fileutils"
2
+ require "mechanize"
3
+ require "thor"
4
+ require "vimmy"
5
+
6
+ class Vimmy::CLI < Thor
7
+
8
+ desc "init", "Initialize a local vim configuration"
9
+
10
+ def init
11
+ backup "~/.vimrc"
12
+ backup "~/.vim"
13
+ mkdir ".vim/autoload"
14
+ mkdir ".vim/bundle"
15
+ template ".vimrc"
16
+ template ".vim/autoload/pathogen.vim"
17
+ end
18
+
19
+ desc "search TERM", "Search for a vim plugin"
20
+
21
+ def search(term)
22
+ display matching(term)
23
+ end
24
+
25
+ desc "install TERM", "Install a vim plugin"
26
+
27
+ def install(term)
28
+ url = choose(matching(term), "Choose a plugin to install")
29
+ end
30
+
31
+ private ######################################################################
32
+
33
+ def backup(file)
34
+ expanded = File.expand_path(file)
35
+ if File.exists?(expanded)
36
+ print "#{file} already exists, move to #{file}.old? [y/N]: "
37
+ if STDIN.gets.strip.downcase == "y"
38
+ FileUtils.mv(expanded, "#{expanded}.old")
39
+ else
40
+ exit 1
41
+ end
42
+ end
43
+ end
44
+
45
+ def choose(plugins, prompt)
46
+ display plugins
47
+ print "#{prompt}: "
48
+
49
+ if (index = STDIN.gets.to_i) > 0
50
+ return unless plugin = sort(plugins)[index-1]
51
+ install_plugin plugin.first
52
+ end
53
+ end
54
+
55
+ def display(plugins)
56
+ sort(plugins).each_with_index do |(url, plugin), index|
57
+ puts "%d) %-28s %s" % [index+1, plugin[:name][0,28], plugin[:description][0,50]]
58
+ end
59
+ end
60
+
61
+ def header
62
+ puts "%-28s %s" % %w(Name Description)
63
+ puts "%-28s %s" % ["="*28, "="*50]
64
+ end
65
+
66
+ def install_plugin(url)
67
+ system %{ cd ~/.vim/bundle && git clone #{url}.git }
68
+ end
69
+
70
+ def matching(term)
71
+ plugins.select do |url, plugin|
72
+ [plugin[:name], plugin[:description]].join(" ") =~ /#{term}/i
73
+ end
74
+ end
75
+
76
+ def mkdir(dir)
77
+ FileUtils.mkdir_p(File.expand_path("~/#{dir}"))
78
+ end
79
+
80
+ def plugins
81
+ page = Mechanize.new.get('http://vim-scripts.org/vim/scripts.html')
82
+ page.search('//tr').inject({}) do |hash, row|
83
+ link = row.search('td/a').first
84
+ hash.update(link.attributes['href'] => {
85
+ :name => link.text,
86
+ :description => row.search('td')[3].text
87
+ })
88
+ end
89
+ end
90
+
91
+ def sort(plugins)
92
+ plugins.sort_by { |p| p.last[:name] }
93
+ end
94
+
95
+ def template(file)
96
+ source = File.expand_path("../../../data/template/#{file}", __FILE__)
97
+ target = File.expand_path("~/#{file}", __FILE__)
98
+ FileUtils.cp(source, target)
99
+ end
100
+
101
+ end
@@ -0,0 +1,3 @@
1
+ module Vimmy
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "vimmy/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "vimmy"
7
+ s.version = Vimmy::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = "David Dollar"
10
+ s.email = "ddollar@gmail.com"
11
+ s.homepage = "http://github.com/ddollar/vimmy"
12
+ s.summary = "Manage vim plugins"
13
+ s.description = s.summary
14
+
15
+ s.rubyforge_project = "vimmy"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency "mechanize", "~> 1.0.0"
23
+ s.add_dependency "thor", "~> 0.14.6"
24
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vimmy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - David Dollar
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-24 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: mechanize
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 0
34
+ version: 1.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: thor
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 43
46
+ segments:
47
+ - 0
48
+ - 14
49
+ - 6
50
+ version: 0.14.6
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Manage vim plugins
54
+ email: ddollar@gmail.com
55
+ executables:
56
+ - vimmy
57
+ extensions: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - README.md
66
+ - Rakefile
67
+ - bin/vimmy
68
+ - data/template/.vim/autoload/pathogen.vim
69
+ - data/template/.vimrc
70
+ - lib/vimmy.rb
71
+ - lib/vimmy/cli.rb
72
+ - lib/vimmy/version.rb
73
+ - vimmy.gemspec
74
+ has_rdoc: true
75
+ homepage: http://github.com/ddollar/vimmy
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options: []
80
+
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project: vimmy
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Manage vim plugins
108
+ test_files: []
109
+