Add settings.json, Append settings to vimrc
Write settings in right order
This commit is contained in:
parent
381d01cb82
commit
f9ce15619e
@ -12,6 +12,16 @@ class VimModule(AbstractModule):
|
||||
with open("modules/vim/vim_plugins.json") as 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):
|
||||
mapped_list = []
|
||||
for choice in self.plugins.keys():
|
||||
@ -33,9 +43,10 @@ class VimModule(AbstractModule):
|
||||
def run(self):
|
||||
|
||||
selected_plugins = self.do_plugin_selection()
|
||||
|
||||
default_settings = self.add_settings()
|
||||
# print out selected plugins
|
||||
[print(x) for x in selected_plugins]
|
||||
[print(i) for i in default_settings]
|
||||
|
||||
# Create vimrc file
|
||||
try:
|
||||
@ -46,9 +57,13 @@ class VimModule(AbstractModule):
|
||||
|
||||
try:
|
||||
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:
|
||||
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:
|
||||
vimrc_content.append("call plug#begin('~/.vim/plugged')\n")
|
||||
for element in selected_plugins:
|
||||
@ -64,8 +79,8 @@ class VimModule(AbstractModule):
|
||||
vimrc_file.write(line)
|
||||
|
||||
# Create necessary folder structure for Plugin Manager
|
||||
if not os.path.isdir("/home/clay/Gitlab/linux-tools/testdirectory/autoload/"):
|
||||
if os.path.isdir("/home/clay/Gitlab/linux-tools/testdirectory/"):
|
||||
if not os.path.isdir("/home/john/Gitlab/linux-tools/testdirectory/autoload/"):
|
||||
if os.path.isdir("/home/john/Gitlab/linux-tools/testdirectory/"):
|
||||
install_vimplug = "cd ~/Gitlab/linux-tools/testdirectory/ " \
|
||||
"&& mkdir autoload " \
|
||||
"&& cd autoload " \
|
||||
|
11
modules/vim/vim_settings.json
Normal file
11
modules/vim/vim_settings.json
Normal 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"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user