Extract plugin list into json file

Adjust line-breaks within strings
Simplify if clause
This commit is contained in:
Lucas Noki 2019-12-22 04:23:03 +01:00 committed by Marcel Schwarz
parent 7a05624f36
commit 04e6f9b160
2 changed files with 27 additions and 14 deletions

View File

@ -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!")

View File

@ -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'"
}
}