From 04e6f9b16036e31ae05066104f6a02c6c21ea03e Mon Sep 17 00:00:00 2001 From: Lucas Noki Date: Sun, 22 Dec 2019 04:23:03 +0100 Subject: [PATCH] Extract plugin list into json file Adjust line-breaks within strings Simplify if clause --- modules/vim/module.py | 31 +++++++++++++++++-------------- modules/vim/vim_plugins.json | 10 ++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 modules/vim/vim_plugins.json diff --git a/modules/vim/module.py b/modules/vim/module.py index 3b6bf36..384ec16 100644 --- a/modules/vim/module.py +++ b/modules/vim/module.py @@ -3,19 +3,15 @@ from subprocess import call from PyInquirer import prompt import os import shutil +import json class VimModule(AbstractModule): def __init__(self): super().__init__() - self.plugins = { - "Colorschemes": "Plug 'https://github.com/rafi/awesome-vim-colorschemes.git'", - "Unix Operations": "Plug 'https://github.com/tpope/vim-eunuch.git'", - "Emmet": "Plug 'https://github.com/mattn/emmet-vim.git'", - "Meta5 Theme": "Plug 'https://github.com/christophermca/meta5.git'", - "Nerdtree": "Plug 'https://github.com/scrooloose/nerdtree'", - "Lightline": "Plug 'https://github.com/itchyny/lightline.vim'" - } + self.plugins = {} + with open("modules/vim/vim_plugins.json") as plugins: + self.plugins = json.load(plugins)['plugins'] def do_module_selection(self): mapped_list = [] @@ -33,11 +29,11 @@ class VimModule(AbstractModule): 'choices': mapped_list } ] - return prompt(module_selection) + return prompt(module_selection)['modules'] def run(self): - selected_modules = self.do_module_selection()['modules'] + selected_modules = self.do_module_selection() # print out selected plugins [print(x) for x in selected_modules] @@ -71,14 +67,21 @@ class VimModule(AbstractModule): autoloaddir_exists = os.path.isdir("/home/clay/Gitlab/linux-tools/testdirectory/autoload/") # Create necessary folder structure for Plugin Manager - if autoloaddir_exists == False: + if not autoloaddir_exists: if vimdir_exists: - install_vimplug = "cd ~/Gitlab/linux-tools/testdirectory/ && mkdir autoload && cd autoload && touch test.txt" + 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""" + 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!") diff --git a/modules/vim/vim_plugins.json b/modules/vim/vim_plugins.json new file mode 100644 index 0000000..ae2c3b2 --- /dev/null +++ b/modules/vim/vim_plugins.json @@ -0,0 +1,10 @@ +{ + "plugins": { + "Colorschemes": "Plug 'https://github.com/rafi/awesome-vim-colorschemes.git'", + "Unix Operations": "Plug 'https://github.com/tpope/vim-eunuch.git'", + "Emmet": "Plug 'https://github.com/mattn/emmet-vim.git'", + "Meta5 Theme": "Plug 'https://github.com/christophermca/meta5.git'", + "Nerdtree": "Plug 'https://github.com/scrooloose/nerdtree'", + "Lightline": "Plug 'https://github.com/itchyny/lightline.vim'" + } +} \ No newline at end of file