-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
125 lines (108 loc) · 3.2 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# _ ___ _ __ ___
# | |/ (_) | | /\ \ \ / (_)
# | ' / _ ___| | __ / \ ___ ___ \ \ / / _ _ __ ___
# | < | |/ __| |/ / / /\ \ / __/ __| \ \/ / | | '_ ` _ \
# | . \| | (__| < / ____ \\__ \__ \ \ / | | | | | | |
# |_|\_\_|\___|_|\_\ /_/ \_\___/___/ \/ |_|_| |_| |_|
@cwd = File.expand_path("../", __FILE__)
@windows = (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
# Gem.win_platform?
desc "Install all plugins and dependencies and compile YouCompleteMe"
task :default =>
[
:config_files,
:vimplug,
:plugins,
:packages,
:ycm,
:print_complete
]
desc "print complete message"
task :print_complete do
print_output "Installation", "Complete!"
end
desc "create config files"
task:config_files do
if @windows
home_dir = Dir.home
vimrc = "#{home_dir}/vimfiles/vimrc"
gvimrc = "#{home_dir}/vimfiles/gvimrc"
sh "echo source #{vimrc} > #{home_dir}/_vimrc"
sh "echo source #{gvimrc} > #{home_dir}/_gvimrc"
else
sh "echo source ~/.vim/vimrc > ~/.vimrc"
sh "echo source ~/.vim/gvimrc > ~/.gvimrc"
end
end
desc "Install Vim plug."
task:vimplug do
print_output "Vim plug"
autoloaddir = File.expand_path "#{@cwd}/autoload"
FileUtils.mkdir_p(autoloaddir) unless File.exists?(autoloaddir)
pluginsdir = File.expand_path "#{@cwd}/plugins"
FileUtils.mkdir_p(pluginsdir) unless File.exists?(pluginsdir)
plug_file = File.expand_path "#{@cwd}/autoload/plug.vim"
unless File.exists?(plug_file)
sh "curl -fLk --insecure https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim > #{plug_file}"
end
end
desc "Install Vim plugins."
task:plugins do
print_output "/ updating Vim plugins"
vim_config = "~/.vimrc"
if @windows
vim_config = "#{Dir.home}/_vimrc"
end
sh "vim -S #{vim_config} -c PlugUpgrade -c PlugUpdate -c PlugClean! -c qa"
end
desc "Install packages"
task:packages do
packages =
[
"instant-markdown-d",
"jshint",
"eslint",
"typescript",
"tslint",
"dtsm",
"@angular/cli",
"ts-server",
"typescript-formatter",
"js-beautify",
"remark-cli", # formatter for markdown
"instant-markdown-d",
"tern",
"tern-jsx",
"git+https://github.com/ramitos/jsctags.git"
]
packages.each do |p|
print_output p
sh "npm install -g --production #{p}"
end
sh "npm update -g"
print_output "sass"
sh "gem install sass --no-ri --no-rdoc"
end
desc "Compile YouCompleteMe"
task :ycm do
print_output "Compiling" "YouCompleteMe"
dir = File.expand_path("#{@cwd}/plugins/YouCompleteMe")
Dir.chdir dir do
if @windows
sh "python install.py --cs-completer --js-completer"
else
sh "./install.py --cs-completer --js-completer"
end
end
end
def print_output(verb, name = nil)
if !name
name = verb
verb = "Installing"
end
puts
puts "*" * 42
puts "*#{"#{verb} #{name}".center(40)}*"
puts "*" * 42
puts
end