Fix path creation, add devenv path for testing
This commit is contained in:
parent
9ef6efcbc3
commit
371cdcc906
@ -1,9 +1,15 @@
|
||||
from AbstractModule import AbstractModule
|
||||
from subprocess import call
|
||||
from PyInquirer import prompt
|
||||
from pathlib import Path
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from PyInquirer import prompt
|
||||
|
||||
from AbstractModule import AbstractModule
|
||||
|
||||
|
||||
def get_vim_root():
|
||||
# return Path().home().joinpath(".vim")
|
||||
return Path(os.getcwd()).joinpath("devenv", ".vim")
|
||||
|
||||
|
||||
class VimModule(AbstractModule):
|
||||
@ -36,6 +42,10 @@ class VimModule(AbstractModule):
|
||||
|
||||
def run(self):
|
||||
|
||||
# Create necessary folder structure for vim
|
||||
os.makedirs(str(get_vim_root().joinpath("autoload")), exist_ok=True)
|
||||
os.makedirs(str(get_vim_root().joinpath("plugged")), exist_ok=True)
|
||||
|
||||
selected_plugins = self.do_plugin_selection()
|
||||
default_settings = list(self.settings.values())
|
||||
# print out selected plugins
|
||||
@ -45,15 +55,15 @@ class VimModule(AbstractModule):
|
||||
[print(i) for i in default_settings]
|
||||
|
||||
# Create vimrc file
|
||||
vimrc_path = str(get_vim_root().joinpath(".vimrc"))
|
||||
try:
|
||||
with open("vim_testfile", "r") as vim_file:
|
||||
vimrc_content = vim_file.readlines()
|
||||
with open(vimrc_path, "r") as vimrc_file:
|
||||
vimrc_content = vimrc_file.readlines()
|
||||
except FileNotFoundError:
|
||||
vimrc_content = []
|
||||
|
||||
try:
|
||||
index = vimrc_content.index("call plug#begin('~/.vim/plugged')\n") + 1
|
||||
# print("Index of plugman " + str(index))
|
||||
for plugin in selected_plugins:
|
||||
vimrc_content.insert(index, self.plugins[plugin] + "\n")
|
||||
|
||||
@ -70,28 +80,9 @@ class VimModule(AbstractModule):
|
||||
seen_add = seen.add
|
||||
vimrc_content = [x1 for x1 in vimrc_content if not (x1 in seen or seen_add(x1))]
|
||||
|
||||
with open("vim_testfile", "w") as vimrc_file:
|
||||
with open(vimrc_path, "w") as vimrc_file:
|
||||
for line in vimrc_content:
|
||||
vimrc_file.write(line)
|
||||
|
||||
# Create necessary folder structure for Plugin Manager
|
||||
autoload = str(Path.home().joinpath("Gitlab", "linux-tools", "testdirectory", "autoload"))
|
||||
testdirectory = str(Path.home().joinpath("Gitlab", "linux-tools", "testdirectory"))
|
||||
if not os.path.isdir(autoload):
|
||||
if os.path.isdir(testdirectory):
|
||||
install_vimplug = "cd ~/Gitlab/linux-tools/testdirectory/ " \
|
||||
"&& mkdir autoload " \
|
||||
"&& cd autoload " \
|
||||
"&& touch test.txt"
|
||||
call(install_vimplug, shell=True)
|
||||
|
||||
else:
|
||||
make_vimdir = "cd ~/Gitlab/linux-tools/ " \
|
||||
"&& mkdir testdirectory " \
|
||||
"&& cd testdirectory " \
|
||||
"&& mkdir autoload " \
|
||||
"&& cd autoload " \
|
||||
"&& touch test.txt"
|
||||
call(make_vimdir, shell=True)
|
||||
else:
|
||||
print("Vim-Plug already installed!")
|
||||
# TODO: check if existing plugin manager file
|
||||
# TODO: else download plugin manager
|
||||
|
Loading…
Reference in New Issue
Block a user