Mercurial > dotfiles
diff install.py @ 432:06a551d3fbb2
Move vim plugin subrepos to a separate config section, support cleaning up.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 02 Apr 2018 09:01:46 -0700 |
parents | e0bb52007402 |
children | 8986ec3a9c1c |
line wrap: on
line diff
--- a/install.py Sun Apr 01 22:57:57 2018 -0700 +++ b/install.py Mon Apr 02 09:01:46 2018 -0700 @@ -65,6 +65,15 @@ fp.write('\n') +def _on_rmtree_err(func, name, excinfo): + os.chmod(name, stat.S_IWUSR | stat.S_IWGRP) + os.remove(name) + + +def rmtree(dirpath): + shutil.rmtree(dirpath, onerror=_on_rmtree_err) + + def only_on_nix(f): @functools.wraps(f) def decorator(*args, **kwargs): @@ -119,7 +128,9 @@ ['source %s' % _p('fish', 'config.fish')]) -def install_vim(): +@needs_config +@supports_forcing +def install_vim(cfg, force=False): vimrc_path = '~/.vimrc' if is_windows: vimrc_path = '~/_vimrc' @@ -128,6 +139,25 @@ 'source %s' % nixslash(_p('vim', 'vimrc')) ]) + if cfg.has_section('vimbundles'): + bundle_dir = _p('vim', 'bundle') + os.makedirs(bundle_dir, exist_ok=True) + existing_plugins = set(os.listdir(bundle_dir)) + + for name, url in cfg.items('vimbundles'): + path = os.path.join(bundle_dir, name) + if url.startswith('[git]'): + clone_git(url[len('[git]'):], path, force=force) + else: + clone_hg(url, path, force=force) + + existing_plugins.discard(name) + + for name in existing_plugins: + print("Removing plugin %s" % name) + path = os.path.join(bundle_dir, name) + rmtree(path) + @run_priority(2) # Needs to run before `fish`. def install_mercurial():