Add check for vimplug file, curl vimplug file

This commit is contained in:
Lucas Noki 2019-12-28 09:12:08 +01:00 committed by Marcel Schwarz
parent f92cb202b3
commit 7bf711875b

View File

@ -1,5 +1,6 @@
import json
import os
import subprocess
from pathlib import Path
from PyInquirer import prompt
@ -24,6 +25,17 @@ class VimModule(AbstractModule):
os.makedirs(str(get_vim_root().joinpath("autoload")), exist_ok=True)
os.makedirs(str(get_vim_root().joinpath("plugged")), exist_ok=True)
def get_vimplug_file(self):
vimplug_filepath = Path(str(get_vim_root().joinpath("autoload")))
print(vimplug_filepath)
if os.path.isfile(str(get_vim_root().joinpath("autoload", "plug.vim"))):
print("Vimplug already installed!")
else:
curl_request = "curl https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim " + \
"-o " + \
str(get_vim_root().joinpath("autoload", "plug.vim"))
subprocess.call(curl_request, shell=True)
def create_plugin_section(self):
vimrc_content = []
mapped_list = []
@ -56,8 +68,6 @@ class VimModule(AbstractModule):
vimrc_content.append(plugins[element] + "\n")
vimrc_content.append("call plug#end()\n")
# TODO: check if existing plugin manager file
# TODO: else download plugin manager
return vimrc_content
def create_setting_section(self):
@ -95,6 +105,7 @@ class VimModule(AbstractModule):
def run(self):
self.create_folder_structure()
self.get_vimplug_file()
plugin_section = self.create_plugin_section()
settings_section = self.create_setting_section()
self.write_vimfile(settings_section + plugin_section)