-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.py
More file actions
103 lines (75 loc) · 3.04 KB
/
install.py
File metadata and controls
103 lines (75 loc) · 3.04 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
#!/usr/bin/env python
""" Install the files needed for this config to operate on the user's system
correctly
any plugin git repo's should be listed in a 'bundle_list' file in the
same dir as this file
adadpted from: https://github.com/mitechie/pyvim
"""
import os
import subprocess
CONFIG_FILES = ['vimrc', 'vim']
HOME_PATH = os.path.expanduser('~')
def removefile(filename):
removing_link = "%s/.%s" % (HOME_PATH, filename)
ret = subprocess.call(["rm", "-rf", removing_link])
print(f"ret is the status code for removing removing_link")
return
def linkfile(filename):
link_location = "%s/.%s" % (HOME_PATH, filename)
is_located = "%s" % (os.path.abspath(filename))
ret = subprocess.call(["ln", "-s", is_located, link_location])
print("ret is the status code for linking is_located to link_location")
return
def empty_bundles():
"""Need to clear out the bundles to make this reusable"""
subprocess.call('rm -rf bundle/*', shell=True)
def remove_bundles():
"""Remove the bundle dir from the .vim dir"""
subprocess.call('rm -rf $HOME/.vim/bundle', shell=True)
def install_bundles():
"""Read bundles file and git clone each repo into .vim/bundle"""
bundle_list = open('bundle_list')
git_cmd = '/usr/bin/git clone {0} $HOME/.vim/bundle/{1}'
for b in bundle_list:
if not b.startswith('#'):
dirname_idx = b.rfind('/') + 1
dirname = b[dirname_idx:].strip()
subprocess.call(git_cmd.format(b.strip(), dirname), shell=True)
# and finally link to the .vim/bundle dir
#link_location = "%s/%s" % (HOME_PATH, '.vim/bundle')
#is_located = "%s" % (os.path.abspath('bundle'))
#ret = subprocess.call(["cp", "-r", is_located, link_location])
#print "{0} is the status code for linking {1} to {2}".format(ret,
# is_located, link_location)
return
def fix_xmledit():
"""In order xmledit in html you need to link the file to html.vim"""
xmledit_path = "$HOME/.vim/bundle/xmledit.git/ftplugin"
xml = os.path.join(xmledit_path, 'xml.vim')
html = os.path.join(xmledit_path, 'html.vim')
mako = os.path.join(xmledit_path, 'mako.vim')
print(xml)
print(html)
print(mako)
subprocess.call('ln -s {0} {1}'.format(xml, html), shell=True)
subprocess.call('ln -s {0} {1}'.format(xml, mako), shell=True)
def copy_custom_snippets():
"""We need to add our custom snippets after the plugin is downloaded/setup"""
import glob, shutil, os
copy_to = os.path.expanduser('~/.vim/bundle/snipMate.git/snippets')
for file in glob.glob("custom_snippets/*.snippets"):
shutil.copy(file, copy_to)
def setup_commandt():
"""Need to compile for the command-t plugin"""
cmd = 'cd $HOME/.vim/bundle/Command-T.git/ruby/command-t/ && ruby extconf.rb && make'
subprocess.call(cmd, shell=True)
# ok, setup vimrc and clone any plugin repos!
for conf_file in CONFIG_FILES:
removefile(conf_file)
linkfile(conf_file)
#empty_bundles()
remove_bundles()
install_bundles()
#setup_commandt()
#fix_xmledit()
#copy_custom_snippets()