]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - vim/Rakefile
Fix some skhdrc configs
[rbdr/dotfiles] / vim / Rakefile
... / ...
CommitLineData
1module VIM
2 Dirs = %w[ after autoload doc plugin ruby snippets syntax ftdetect ftplugin colors indent ]
3end
4
5directory "tmp"
6VIM::Dirs.each do |dir|
7 directory(dir)
8end
9
10def vim_plugin_task(name, repo=nil)
11 cwd = File.expand_path("../", __FILE__)
12 dir = File.expand_path("tmp/#{name}")
13 subdirs = VIM::Dirs
14
15 namespace(name) do
16 if repo
17 file dir => "tmp" do
18 if repo =~ /git$/
19 sh "git clone #{repo} #{dir}"
20
21 elsif repo =~ /download_script/
22 if filename = `curl --silent --head #{repo} | grep attachment`[/filename=(.+)/,1]
23 filename.strip!
24 sh "curl #{repo} > tmp/#{filename}"
25 else
26 raise ArgumentError, 'unable to determine script type'
27 end
28
29 elsif repo =~ /(tar|gz|vba|zip)$/
30 filename = File.basename(repo)
31 sh "curl #{repo} > tmp/#{filename}"
32
33 else
34 raise ArgumentError, 'unrecognized source url for plugin'
35 end
36
37 case filename
38 when /zip$/
39 sh "unzip -o tmp/#{filename} -d #{dir}"
40
41 when /tar\.gz$/
42 dirname = File.basename(filename, '.tar.gz')
43
44 sh "tar zxvf tmp/#{filename}"
45 sh "mv #{dirname} #{dir}"
46
47 when /vba(\.gz)?$/
48 if filename =~ /gz$/
49 sh "gunzip -f tmp/#{filename}"
50 filename = File.basename(filename, '.gz')
51 end
52
53 # TODO: move this into the install task
54 mkdir_p dir
55 lines = File.readlines("tmp/#{filename}")
56 current = lines.shift until current =~ /finish$/ # find finish line
57
58 while current = lines.shift
59 # first line is the filename (possibly followed by garbage)
60 # some vimballs use win32 style path separators
61 path = current[/^(.+?)(\t\[{3}\d)?$/, 1].gsub '\\', '/'
62
63 # then the size of the payload in lines
64 current = lines.shift
65 num_lines = current[/^(\d+)$/, 1].to_i
66
67 # the data itself
68 data = lines.slice!(0, num_lines).join
69
70 # install the data
71 Dir.chdir dir do
72 mkdir_p File.dirname(path)
73 File.open(path, 'w'){ |f| f.write(data) }
74 end
75 end
76 end
77 end
78
79 task :pull => dir do
80 if repo =~ /git$/
81 Dir.chdir dir do
82 sh "git pull"
83 end
84 end
85 end
86
87 task :install => [:pull] + subdirs do
88 Dir.chdir dir do
89 if File.exists?("Rakefile") and `rake -T` =~ /^rake install/
90 sh "rake install"
91 elsif File.exists?("install.sh")
92 sh "sh install.sh"
93 else
94 subdirs.each do |subdir|
95 if File.exists?(subdir)
96 sh "cp -RfL #{subdir}/* #{cwd}/#{subdir}/"
97 end
98 end
99 end
100 end
101
102 yield if block_given?
103 end
104 else
105 task :install => subdirs do
106 yield if block_given?
107 end
108 end
109 end
110
111 desc "Install #{name} plugin"
112 task name do
113 puts
114 puts "*" * 40
115 puts "*#{"Installing #{name}".center(38)}*"
116 puts "*" * 40
117 puts
118 Rake::Task["#{name}:install"].invoke
119 end
120 task :default => name
121end
122
123def skip_vim_plugin(name)
124 Rake::Task[:default].prerequisites.delete(name)
125end
126
127vim_plugin_task "ack.vim", "git://github.com/mileszs/ack.vim.git"
128vim_plugin_task "color-sampler", "git://github.com/vim-scripts/Color-Sampler-Pack.git"
129vim_plugin_task "conque", "http://conque.googlecode.com/files/conque_1.1.tar.gz"
130vim_plugin_task "fugitive", "git://github.com/tpope/vim-fugitive.git"
131vim_plugin_task "git", "git://github.com/tpope/vim-git.git"
132vim_plugin_task "haml", "git://github.com/tpope/vim-haml.git"
133vim_plugin_task "indent_object", "git://github.com/michaeljsmith/vim-indent-object.git"
134vim_plugin_task "javascript", "git://github.com/pangloss/vim-javascript.git"
135vim_plugin_task "nerdtree", "git://github.com/wycats/nerdtree.git"
136vim_plugin_task "nerdcommenter", "git://github.com/ddollar/nerdcommenter.git"
137vim_plugin_task "surround", "git://github.com/tpope/vim-surround.git"
138vim_plugin_task "taglist", "git://github.com/vim-scripts/taglist.vim.git"
139vim_plugin_task "vividchalk", "git://github.com/tpope/vim-vividchalk.git"
140vim_plugin_task "solarized", "git://github.com/altercation/vim-colors-solarized.git"
141vim_plugin_task "supertab", "git://github.com/ervandew/supertab.git"
142vim_plugin_task "cucumber", "git://github.com/tpope/vim-cucumber.git"
143vim_plugin_task "textile", "git://github.com/timcharper/textile.vim.git"
144vim_plugin_task "rails", "git://github.com/tpope/vim-rails.git"
145vim_plugin_task "rspec", "git://github.com/taq/vim-rspec.git"
146vim_plugin_task "zoomwin", "git://github.com/vim-scripts/ZoomWin.git"
147vim_plugin_task "snipmate", "git://github.com/msanders/snipmate.vim.git"
148vim_plugin_task "markdown", "git://github.com/tpope/vim-markdown.git"
149vim_plugin_task "align", "git://github.com/tsaleh/vim-align.git"
150vim_plugin_task "unimpaired", "git://github.com/tpope/vim-unimpaired.git"
151vim_plugin_task "searchfold", "git://github.com/vim-scripts/searchfold.vim.git"
152vim_plugin_task "endwise", "git://github.com/tpope/vim-endwise.git"
153vim_plugin_task "irblack", "git://github.com/wgibbs/vim-irblack.git"
154vim_plugin_task "vim-coffee-script","git://github.com/kchmck/vim-coffee-script.git"
155vim_plugin_task "syntastic", "git://github.com/scrooloose/syntastic.git"
156vim_plugin_task "puppet", "git://github.com/ajf/puppet-vim.git"
157vim_plugin_task "scala", "git://github.com/bdd/vim-scala.git"
158vim_plugin_task "gist-vim", "git://github.com/mattn/gist-vim.git"
159
160#vim_plugin_task "hammer", "git://github.com/robgleeson/hammer.vim.git" do
161# sh "gem install github-markup redcarpet"
162#end
163
164vim_plugin_task "janus_themes" do
165 # custom version of railscasts theme
166 File.open(File.expand_path("../colors/railscasts+.vim", __FILE__), "w") do |file|
167 file.puts <<-VIM.gsub(/^ +/, "").gsub("<SP>", " ")
168 runtime colors/railscasts.vim
169 let g:colors_name = "railscasts+"
170
171 set fillchars=vert:\\<SP>
172 set fillchars=stl:\\<SP>
173 set fillchars=stlnc:\\<SP>
174 hi StatusLine guibg=#cccccc guifg=#000000
175 hi VertSplit guibg=#dddddd
176 VIM
177 end
178
179 # custom version of jellybeans theme
180 File.open(File.expand_path("../colors/jellybeans+.vim", __FILE__), "w") do |file|
181 file.puts <<-VIM.gsub(/^ /, "")
182 runtime colors/jellybeans.vim
183 let g:colors_name = "jellybeans+"
184
185 hi VertSplit guibg=#888888
186 hi StatusLine guibg=#cccccc guifg=#000000
187 hi StatusLineNC guibg=#888888 guifg=#000000
188 VIM
189 end
190end
191
192vim_plugin_task "molokai" do
193 sh "curl https://raw.github.com/mrtazz/molokai.vim/master/colors/molokai.vim > colors/molokai.vim"
194end
195vim_plugin_task "mustache" do
196 sh "curl https://raw.github.com/defunkt/mustache/master/contrib/mustache.vim > syntax/mustache.vim"
197 File.open(File.expand_path('../ftdetect/mustache.vim', __FILE__), 'w') do |file|
198 file << "au BufNewFile,BufRead *.mustache setf mustache"
199 end
200end
201vim_plugin_task "arduino","git://github.com/vim-scripts/Arduino-syntax-file.git" do
202 File.open(File.expand_path('../ftdetect/arduino.vim', __FILE__), 'w') do |file|
203 file << "au BufNewFile,BufRead *.pde setf arduino"
204 end
205end
206vim_plugin_task "vwilight" do
207 sh "curl https://raw.github.com/gist/796172/724c7ca237a7f6b8d857c4ac2991cfe5ffb18087 > colors/vwilight.vim"
208end
209
210if File.exists?(janus = File.expand_path("~/.janus.rake"))
211 puts "Loading your custom rake file"
212 import(janus)
213end
214
215desc "Update the documentation"
216task :update_docs do
217 puts "Updating VIM Documentation..."
218 system "vim -e -s <<-EOF\n:helptags ~/.vim/doc\n:quit\nEOF"
219end
220
221desc "link vimrc to ~/.vimrc"
222task :link_vimrc do
223 %w[ vimrc gvimrc ].each do |file|
224 dest = File.expand_path("~/.#{file}")
225 unless File.exist?(dest)
226 ln_s(File.expand_path("../#{file}", __FILE__), dest)
227 end
228 end
229end
230
231task :clean do
232 system "git clean -dfx"
233end
234
235desc "Pull the latest"
236task :pull do
237 system "git pull"
238end
239
240task :default => [
241 :update_docs,
242 :link_vimrc
243]
244
245desc "Clear out all build artifacts and rebuild the latest Janus"
246task :upgrade => [:clean, :pull, :default]
247