This repository was archived by the owner on Feb 16, 2022. It is now read-only.
forked from amix/vimrc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_plugins.py
More file actions
131 lines (105 loc) · 3.82 KB
/
update_plugins.py
File metadata and controls
131 lines (105 loc) · 3.82 KB
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
126
127
128
129
130
131
try:
import concurrent.futures as futures
except ImportError:
try:
import futures
except ImportError:
futures = None
import zipfile
import shutil
import tempfile
import requests
from os import path
#--- Globals ----------------------------------------------
FILE_PLUGINS = """
bufexplorer https://github.com/corntrace/bufexplorer
ctrlp.vim https://github.com/ctrlpvim/ctrlp.vim
mru.vim https://github.com/vim-scripts/mru.vim
nerdtree https://github.com/scrooloose/nerdtree
"""
MOTION_PLUGINS = """
auto-pairs https://github.com/jiangmiao/auto-pairs
comfortable-motion.vim https://github.com/yuttie/comfortable-motion.vim
tabular https://github.com/godlygeek/tabular
vim-commentary https://github.com/tpope/vim-commentary
vim-expand-region https://github.com/terryma/vim-expand-region
vim-indent-object https://github.com/michaeljsmith/vim-indent-object
vim-markdown https://github.com/tpope/vim-markdown
vim-surround https://github.com/tpope/vim-surround
"""
GIT_PLUGINS = """
vim-fugitive https://github.com/tpope/vim-fugitive
vim-gitgutter https://github.com/airblade/vim-gitgutter
"""
INTERFACE_PLUGINS = """
lightline-ale https://github.com/maximbaz/lightline-ale
lightline.vim https://github.com/itchyny/lightline.vim
"""
LANGUAGE_PLUGINS = """
ale https://github.com/w0rp/ale
nginx.vim https://github.com/chr4/nginx.vim
rust.vim https://github.com/rust-lang/rust.vim
vim-flake8 https://github.com/nvie/vim-flake8
vim-go https://github.com/fatih/vim-go
vim-markdown https://github.com/plasticboy/vim-markdown
"""
HELPER_PLUGINS = """
ack.vim https://github.com/mileszs/ack.vim
tlib https://github.com/vim-scripts/tlib
vim-addon-mw-utils https://github.com/MarcWeber/vim-addon-mw-utils
"""
UTILITIES_PLUGINS = """
open_file_under_cursor.vim https://github.com/amix/open_file_under_cursor.vim
snipmate-snippets https://github.com/scrooloose/snipmate-snippets
vim-repeat https://github.com/tpope/vim-repeat
vim-snipmate https://github.com/garbas/vim-snipmate
vim-snippets https://github.com/honza/vim-snippets
vim-yankstack https://github.com/maxbrunsfeld/vim-yankstack
"""
MISC_PLUGINS = """
goyo.vim https://github.com/junegunn/goyo.vim
gruvbox https://github.com/morhetz/gruvbox
vim-zenroom2 https://github.com/amix/vim-zenroom2
"""
PLUGINS = (FILE_PLUGINS +
MOTION_PLUGINS +
GIT_PLUGINS +
INTERFACE_PLUGINS +
LANGUAGE_PLUGINS +
HELPER_PLUGINS +
UTILITIES_PLUGINS +
MISC_PLUGINS).strip()
GITHUB_ZIP = '%s/archive/master.zip'
SOURCE_DIR = path.join(path.dirname(__file__), 'sources_non_forked')
def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
temp_zip_path = path.join(temp_dir, plugin_name)
# Download and extract file in temp dir
req = requests.get(zip_path)
open(temp_zip_path, 'wb').write(req.content)
zip_f = zipfile.ZipFile(temp_zip_path)
zip_f.extractall(temp_dir)
plugin_temp_path = path.join(temp_dir,
path.join(temp_dir, '%s-master' % plugin_name))
# Remove the current plugin and replace it with the extracted
plugin_dest_path = path.join(source_dir, plugin_name)
try:
shutil.rmtree(plugin_dest_path)
except OSError:
pass
shutil.move(plugin_temp_path, plugin_dest_path)
print('Updated {0}'.format(plugin_name))
def update(plugin):
name, github_url = plugin.split(' ')
zip_path = GITHUB_ZIP % github_url
download_extract_replace(name, zip_path,
temp_directory, SOURCE_DIR)
if __name__ == '__main__':
temp_directory = tempfile.mkdtemp()
try:
if futures:
with futures.ThreadPoolExecutor(16) as executor:
executor.map(update, PLUGINS.splitlines())
else:
[update(x) for x in PLUGINS.splitlines()]
finally:
shutil.rmtree(temp_directory)