This repository was archived by the owner on Mar 24, 2022. It is now read-only.
forked from edgecase/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathRakefile
74 lines (63 loc) · 1.64 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'rake'
require './lib/installer'
require './lib/translation'
NIX_FILES = [
[ 'nvim', '~/.config/nvim'],
[ 'nvim', '~/.vim'],
[ 'nvim/init.vim', '~/.vimrc'],
[ '.gvimrc', '~/.gvimrc'],
]
desc "Install vim configuration and plugin files"
task :default do
installer = Installer.new(platform_files)
installer.files.each do |f|
case
when f.identical? then skip_file(f)
when replace_all? then auto_link_files(f)
when f.safe_to_link? then auto_link_files(f)
else prompt_to_link_files(f)
end
end
Rake::Task['nebundle'].execute
end
desc "Install neobundle for vim plugins"
task :nebundle do
target = "#{platform_files[0][1]}/bundle/neobundle.vim"
Installer.git_clone('https://github.com/Shougo/neobundle.vim', target)
puts "Running BundleInstall to install plugins...this will take a couple minutes."
`vim -e +NeoBundleInstall +qall`
puts "vim plugins installed."
end
def platform_files
NIX_FILES
end
def prompt_to_link_files(file)
print "overwrite? #{file.target} [ynaq] "
case $stdin.gets.chomp
when 'y' then replace(file)
when 'a' then replace_all(file)
when 'q' then exit
else skip_file(file)
end
end
def link_files(file)
puts " => symlinking #{file.source} to #{file.target}"
file.link
end
def replace(file)
puts " => replacing #{file.source} with #{file.target}"
file.force_link
end
def replace_all(file)
@replace_all = true
replace(file)
end
def replace_all?
@replace_all == true
end
def skip_file(file)
puts " => skipping #{file.target}"
end
def auto_link_files(file)
file.safe_to_link? ? link_files(file) : replace(file)
end