-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathupdate_vim.py
executable file
·59 lines (52 loc) · 1.94 KB
/
update_vim.py
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
#!/usr/bin/env python3
# Assumes Github repos. Use shorthand "user/repo-name".
#
# Note: if you change the URL that's not currently detected!
# A suggested workaround: comment out the plugin, run
# update_vim.py to remove it, then uncomment and change
# the URL, and run update_vim.py again to install the new one.
vim_bundles = {
# insert and delete parens, braces, etc in pairs
"autopairs": "LunarWatcher/auto-pairs",
# automatically adds ending keyword to blocks (end, endif, ...)
"endwise": "tpope/vim-endwise",
# github-flavored markdown plugin
"ghmarkdown": "jtratner/vim-flavored-markdown",
# PaperColor theme, based on Material
"papercolor": "NLKNguyen/papercolor-theme",
# Vim plugin manager
"pathogen": "tpope/vim-pathogen",
# support for Perl
"perl": "vim-perl/vim-perl",
# postgres-flavored SQL support
"pgsql": "exu/pgsql.vim",
# status line
"statline": "millermedeiros/vim-statline",
# change surrounding things (quotes, parens, etc)
"surround": "tpope/vim-surround",
# easily comment / uncomment lines, blocks, selections...
"tcomment": "tomtom/tcomment_vim",
}
import os
import shutil
dir_path = os.path.dirname(os.path.realpath(__file__))
bundle_path = dir_path + "/roles/vim/files/vim/bundle"
if not os.path.isdir(bundle_path):
print("=> Creating bundle path")
os.mkdir(bundle_path)
os.chdir(bundle_path)
# Clean up old bundles no longer in our list
for filename in os.listdir():
if filename not in vim_bundles:
print("=> Removing {}".format(filename))
shutil.rmtree(filename)
for bundle in vim_bundles:
url = "https://github.com/" + vim_bundles[bundle] + ".git"
if os.path.isdir(bundle):
print("=> Updating {}".format(bundle))
os.chdir(bundle)
os.system("git pull")
os.chdir("..")
else:
print("=> Installing {}".format(bundle))
os.system("git clone {} {}".format(url, bundle))