Mercurial > dotfiles
comparison 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 |
comparison
equal
deleted
inserted
replaced
431:e0bb52007402 | 432:06a551d3fbb2 |
---|---|
63 for l in lines: | 63 for l in lines: |
64 fp.write(l) | 64 fp.write(l) |
65 fp.write('\n') | 65 fp.write('\n') |
66 | 66 |
67 | 67 |
68 def _on_rmtree_err(func, name, excinfo): | |
69 os.chmod(name, stat.S_IWUSR | stat.S_IWGRP) | |
70 os.remove(name) | |
71 | |
72 | |
73 def rmtree(dirpath): | |
74 shutil.rmtree(dirpath, onerror=_on_rmtree_err) | |
75 | |
76 | |
68 def only_on_nix(f): | 77 def only_on_nix(f): |
69 @functools.wraps(f) | 78 @functools.wraps(f) |
70 def decorator(*args, **kwargs): | 79 def decorator(*args, **kwargs): |
71 if is_nix: | 80 if is_nix: |
72 return f(*args, **kwargs) | 81 return f(*args, **kwargs) |
117 ensure_dir('~/.config/fish') | 126 ensure_dir('~/.config/fish') |
118 writelines('~/.config/fish/config.fish', | 127 writelines('~/.config/fish/config.fish', |
119 ['source %s' % _p('fish', 'config.fish')]) | 128 ['source %s' % _p('fish', 'config.fish')]) |
120 | 129 |
121 | 130 |
122 def install_vim(): | 131 @needs_config |
132 @supports_forcing | |
133 def install_vim(cfg, force=False): | |
123 vimrc_path = '~/.vimrc' | 134 vimrc_path = '~/.vimrc' |
124 if is_windows: | 135 if is_windows: |
125 vimrc_path = '~/_vimrc' | 136 vimrc_path = '~/_vimrc' |
126 writelines(vimrc_path, [ | 137 writelines(vimrc_path, [ |
127 'set runtimepath+=%s' % nixslash(_p('vim')), | 138 'set runtimepath+=%s' % nixslash(_p('vim')), |
128 'source %s' % nixslash(_p('vim', 'vimrc')) | 139 'source %s' % nixslash(_p('vim', 'vimrc')) |
129 ]) | 140 ]) |
141 | |
142 if cfg.has_section('vimbundles'): | |
143 bundle_dir = _p('vim', 'bundle') | |
144 os.makedirs(bundle_dir, exist_ok=True) | |
145 existing_plugins = set(os.listdir(bundle_dir)) | |
146 | |
147 for name, url in cfg.items('vimbundles'): | |
148 path = os.path.join(bundle_dir, name) | |
149 if url.startswith('[git]'): | |
150 clone_git(url[len('[git]'):], path, force=force) | |
151 else: | |
152 clone_hg(url, path, force=force) | |
153 | |
154 existing_plugins.discard(name) | |
155 | |
156 for name in existing_plugins: | |
157 print("Removing plugin %s" % name) | |
158 path = os.path.join(bundle_dir, name) | |
159 rmtree(path) | |
130 | 160 |
131 | 161 |
132 @run_priority(2) # Needs to run before `fish`. | 162 @run_priority(2) # Needs to run before `fish`. |
133 def install_mercurial(): | 163 def install_mercurial(): |
134 hgrc_path = '~/.hgrc' | 164 hgrc_path = '~/.hgrc' |