From 7bf711875b50a6925c2a23c244e92a3c2f49991e Mon Sep 17 00:00:00 2001 From: Lucas Noki Date: Sat, 28 Dec 2019 09:12:08 +0100 Subject: [PATCH] Add check for vimplug file, curl vimplug file --- modules/vim/module.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/vim/module.py b/modules/vim/module.py index c526795..ab43b7d 100644 --- a/modules/vim/module.py +++ b/modules/vim/module.py @@ -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)