2015-06-06 11:12:17 -04:00
|
|
|
try:
|
|
|
|
import concurrent.futures as futures
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
import futures
|
|
|
|
except ImportError:
|
|
|
|
futures = None
|
|
|
|
|
2021-07-30 16:53:30 -04:00
|
|
|
import re
|
2013-04-13 13:45:21 -04:00
|
|
|
import shutil
|
|
|
|
import tempfile
|
2022-11-21 04:11:47 -05:00
|
|
|
import urllib.request
|
|
|
|
import zipfile
|
|
|
|
from io import BytesIO
|
2013-04-13 13:45:21 -04:00
|
|
|
from os import path
|
|
|
|
|
2019-11-16 14:16:20 -05:00
|
|
|
# --- Globals ----------------------------------------------
|
2013-04-13 13:45:21 -04:00
|
|
|
PLUGINS = """
|
2018-06-14 06:30:22 -04:00
|
|
|
auto-pairs https://github.com/jiangmiao/auto-pairs
|
2021-10-11 05:25:27 -04:00
|
|
|
ale https://github.com/dense-analysis/ale
|
2017-12-13 09:05:24 -05:00
|
|
|
vim-yankstack https://github.com/maxbrunsfeld/vim-yankstack
|
2017-04-01 08:29:02 -04:00
|
|
|
ack.vim https://github.com/mileszs/ack.vim
|
2019-11-16 14:22:13 -05:00
|
|
|
bufexplorer https://github.com/jlanzarotta/bufexplorer
|
2016-04-29 11:52:07 -04:00
|
|
|
ctrlp.vim https://github.com/ctrlpvim/ctrlp.vim
|
2013-04-13 13:45:21 -04:00
|
|
|
mayansmoke https://github.com/vim-scripts/mayansmoke
|
2021-10-11 05:25:27 -04:00
|
|
|
nerdtree https://github.com/preservim/nerdtree
|
2017-11-24 08:54:40 -05:00
|
|
|
nginx.vim https://github.com/chr4/nginx.vim
|
2013-04-13 13:45:21 -04:00
|
|
|
open_file_under_cursor.vim https://github.com/amix/open_file_under_cursor.vim
|
2021-08-04 09:43:43 -04:00
|
|
|
tlib https://github.com/tomtom/tlib_vim
|
2013-04-13 13:45:21 -04:00
|
|
|
vim-addon-mw-utils https://github.com/MarcWeber/vim-addon-mw-utils
|
|
|
|
vim-bundle-mako https://github.com/sophacles/vim-bundle-mako
|
|
|
|
vim-coffee-script https://github.com/kchmck/vim-coffee-script
|
|
|
|
vim-colors-solarized https://github.com/altercation/vim-colors-solarized
|
|
|
|
vim-indent-object https://github.com/michaeljsmith/vim-indent-object
|
|
|
|
vim-less https://github.com/groenewege/vim-less
|
|
|
|
vim-pyte https://github.com/therubymug/vim-pyte
|
|
|
|
vim-snipmate https://github.com/garbas/vim-snipmate
|
|
|
|
vim-snippets https://github.com/honza/vim-snippets
|
|
|
|
vim-surround https://github.com/tpope/vim-surround
|
2013-04-14 11:48:31 -04:00
|
|
|
vim-expand-region https://github.com/terryma/vim-expand-region
|
2013-04-14 11:55:47 -04:00
|
|
|
vim-multiple-cursors https://github.com/terryma/vim-multiple-cursors
|
2013-11-16 14:45:48 -05:00
|
|
|
vim-fugitive https://github.com/tpope/vim-fugitive
|
2021-10-11 05:29:06 -04:00
|
|
|
vim-rhubarb https://github.com/tpope/vim-rhubarb
|
2013-12-29 06:36:43 -05:00
|
|
|
goyo.vim https://github.com/junegunn/goyo.vim
|
2013-12-29 05:37:14 -05:00
|
|
|
vim-zenroom2 https://github.com/amix/vim-zenroom2
|
2014-03-02 09:35:00 -05:00
|
|
|
vim-repeat https://github.com/tpope/vim-repeat
|
|
|
|
vim-commentary https://github.com/tpope/vim-commentary
|
2015-07-13 06:22:46 -04:00
|
|
|
vim-gitgutter https://github.com/airblade/vim-gitgutter
|
|
|
|
gruvbox https://github.com/morhetz/gruvbox
|
2015-12-08 08:20:04 -05:00
|
|
|
vim-flake8 https://github.com/nvie/vim-flake8
|
2016-02-20 08:13:10 -05:00
|
|
|
vim-pug https://github.com/digitaltoad/vim-pug
|
2016-05-14 08:22:57 -04:00
|
|
|
lightline.vim https://github.com/itchyny/lightline.vim
|
2018-06-14 06:30:22 -04:00
|
|
|
lightline-ale https://github.com/maximbaz/lightline-ale
|
2021-10-11 05:25:27 -04:00
|
|
|
vim-abolish https://github.com/tpope/vim-abolish
|
2019-11-16 11:14:34 -05:00
|
|
|
rust.vim https://github.com/rust-lang/rust.vim
|
2018-02-04 06:35:08 -05:00
|
|
|
vim-markdown https://github.com/plasticboy/vim-markdown
|
2020-04-15 22:41:14 -04:00
|
|
|
vim-gist https://github.com/mattn/vim-gist
|
2019-11-16 12:43:18 -05:00
|
|
|
vim-ruby https://github.com/vim-ruby/vim-ruby
|
|
|
|
typescript-vim https://github.com/leafgarland/typescript-vim
|
|
|
|
vim-javascript https://github.com/pangloss/vim-javascript
|
2019-11-16 14:16:20 -05:00
|
|
|
vim-python-pep8-indent https://github.com/Vimjas/vim-python-pep8-indent
|
2021-07-04 17:01:36 -04:00
|
|
|
vim-indent-guides https://github.com/nathanaelkane/vim-indent-guides
|
2021-05-05 04:24:20 -04:00
|
|
|
mru.vim https://github.com/vim-scripts/mru.vim
|
2021-06-06 03:51:23 -04:00
|
|
|
editorconfig-vim https://github.com/editorconfig/editorconfig-vim
|
2021-07-30 16:53:30 -04:00
|
|
|
dracula https://github.com/dracula/vim
|
2023-04-01 16:49:41 -04:00
|
|
|
co-pilot.vim https://github.com/github/copilot.vim
|
2013-04-13 13:45:21 -04:00
|
|
|
""".strip()
|
|
|
|
|
2020-04-15 22:41:14 -04:00
|
|
|
GITHUB_ZIP = "%s/archive/master.zip"
|
2013-04-13 13:45:21 -04:00
|
|
|
|
2020-04-15 22:41:14 -04:00
|
|
|
SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked")
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
|
|
|
|
# Download and extract file in temp dir
|
2022-11-21 04:11:47 -05:00
|
|
|
with urllib.request.urlopen(zip_path) as req:
|
|
|
|
zip_f = zipfile.ZipFile(BytesIO(req.read()))
|
|
|
|
zip_f.extractall(temp_dir)
|
|
|
|
content_disp = req.headers.get("Content-Disposition")
|
2013-04-13 13:45:21 -04:00
|
|
|
|
2021-07-30 16:53:30 -04:00
|
|
|
filename = re.findall("filename=(.+).zip", content_disp)[0]
|
|
|
|
plugin_temp_path = path.join(temp_dir, path.join(temp_dir, filename))
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
# 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)
|
2020-04-15 22:41:14 -04:00
|
|
|
print("Updated {0}".format(plugin_name))
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
|
2015-06-06 11:12:17 -04:00
|
|
|
def update(plugin):
|
2020-04-15 22:41:14 -04:00
|
|
|
name, github_url = plugin.split(" ")
|
2015-06-06 11:12:17 -04:00
|
|
|
zip_path = GITHUB_ZIP % github_url
|
2021-07-30 16:53:30 -04:00
|
|
|
try:
|
|
|
|
download_extract_replace(name, zip_path, temp_directory, SOURCE_DIR)
|
|
|
|
except Exception as exp:
|
|
|
|
print("Could not update {}. Error was: {}".format(name, str(exp)))
|
2015-06-06 11:12:17 -04:00
|
|
|
|
|
|
|
|
2020-04-15 22:41:14 -04:00
|
|
|
if __name__ == "__main__":
|
2013-04-13 13:45:21 -04:00
|
|
|
temp_directory = tempfile.mkdtemp()
|
|
|
|
|
|
|
|
try:
|
2015-06-06 11:12:17 -04:00
|
|
|
if futures:
|
|
|
|
with futures.ThreadPoolExecutor(16) as executor:
|
|
|
|
executor.map(update, PLUGINS.splitlines())
|
|
|
|
else:
|
|
|
|
[update(x) for x in PLUGINS.splitlines()]
|
2013-04-13 13:45:21 -04:00
|
|
|
finally:
|
|
|
|
shutil.rmtree(temp_directory)
|