Add settings.json, Append settings to vimrc

Write settings in right order
This commit is contained in:
Lucas Noki 2019-12-26 23:41:51 +01:00 committed by Marcel Schwarz
parent 381d01cb82
commit f9ce15619e
2 changed files with 30 additions and 4 deletions

View File

@ -12,6 +12,16 @@ class VimModule(AbstractModule):
with open("modules/vim/vim_plugins.json") as plugins: with open("modules/vim/vim_plugins.json") as plugins:
self.plugins = json.load(plugins)['plugins'] self.plugins = json.load(plugins)['plugins']
self.settings = {}
with open("modules/vim/vim_settings.json") as settings:
self.settings = json.load(settings)['settings']
def add_settings(self):
list_settings = []
for setting in self.settings.values():
list_settings.append(setting)
return list_settings
def do_plugin_selection(self): def do_plugin_selection(self):
mapped_list = [] mapped_list = []
for choice in self.plugins.keys(): for choice in self.plugins.keys():
@ -33,9 +43,10 @@ class VimModule(AbstractModule):
def run(self): def run(self):
selected_plugins = self.do_plugin_selection() selected_plugins = self.do_plugin_selection()
default_settings = self.add_settings()
# print out selected plugins # print out selected plugins
[print(x) for x in selected_plugins] [print(x) for x in selected_plugins]
[print(i) for i in default_settings]
# Create vimrc file # Create vimrc file
try: try:
@ -46,9 +57,13 @@ class VimModule(AbstractModule):
try: try:
index = vimrc_content.index("call plug#begin('~/.vim/plugged')\n") + 1 index = vimrc_content.index("call plug#begin('~/.vim/plugged')\n") + 1
print("Index of plugman " + str(index)) # print("Index of plugman " + str(index))
for plugin in selected_plugins: for plugin in selected_plugins:
vimrc_content.insert(index, self.plugins[plugin] + "\n") vimrc_content.insert(index, self.plugins[plugin] + "\n")
default_settings.reverse()
for setting in default_settings:
vimrc_content.insert(index - 1, setting + "\n")
except ValueError: except ValueError:
vimrc_content.append("call plug#begin('~/.vim/plugged')\n") vimrc_content.append("call plug#begin('~/.vim/plugged')\n")
for element in selected_plugins: for element in selected_plugins:
@ -64,8 +79,8 @@ class VimModule(AbstractModule):
vimrc_file.write(line) vimrc_file.write(line)
# Create necessary folder structure for Plugin Manager # Create necessary folder structure for Plugin Manager
if not os.path.isdir("/home/clay/Gitlab/linux-tools/testdirectory/autoload/"): if not os.path.isdir("/home/john/Gitlab/linux-tools/testdirectory/autoload/"):
if os.path.isdir("/home/clay/Gitlab/linux-tools/testdirectory/"): if os.path.isdir("/home/john/Gitlab/linux-tools/testdirectory/"):
install_vimplug = "cd ~/Gitlab/linux-tools/testdirectory/ " \ install_vimplug = "cd ~/Gitlab/linux-tools/testdirectory/ " \
"&& mkdir autoload " \ "&& mkdir autoload " \
"&& cd autoload " \ "&& cd autoload " \

View File

@ -0,0 +1,11 @@
{
"settings": {
"tabstop": "set tabstop=2",
"shiftwidth": "set shiftwidth=2",
"expand": "set noexpandtab",
"highlighting": "syntax on",
"linenumbers": "set number",
"status": "set laststatus=2",
"noshowmode": "set noshowmode"
}
}