Refactor getconfig function

This commit is contained in:
Anton Vilhelm Ásgeirsson 2019-05-30 15:14:50 +00:00 committed by Oliver Blanthorn
parent 07d1ed6586
commit 66de3e815d
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -501,6 +501,9 @@ export class default_config {
zo: "zoom",
installnative: "nativeinstall",
nativeupdate: "updatenative",
mkt: "mktridactylrc",
"mkt!": "mktridactylrc -f",
"mktridactylrc!": "mktridactylrc -f"
}
/**
@ -1385,33 +1388,24 @@ export function parseConfig(): string {
for (const i in USERCONFIG) {
if (typeof USERCONFIG[i] !== "object")
parsedConf.push(`set ${i} ${USERCONFIG[i]}`)
else if (i === "nmaps") {
for (const e in USERCONFIG[i]) {
else {
for (const e of Object.keys(USERCONFIG[i])) {
if (i === "nmaps") {
parsedBinds.push(`bind ${e} ${USERCONFIG[i][e]}`)
}
} else if (i === "exaliases") {
for (const e in USERCONFIG[i]) {
// Only really useful if mapping the entire config and not just USERCONFIG.
if (e === "alias")
if (e === "alias") {
parsedAliases.push(`command ${e} ${USERCONFIG[i][e]}`)
} else {
parsedAliases.push(`alias ${e} ${USERCONFIG[i][e]}`)
}
} else if (i === "autocmds") {
for (const e in USERCONFIG[i]) {
for (const a in USERCONFIG[i][e]) {
parsedAucmds.push(
`autocmd ${e} ${a} ${USERCONFIG[i][e][a]}`,
)
}
for (const a of Object.keys(USERCONFIG[i][e])) {
parsedAucmds.push(`autocmd ${e} ${a} ${USERCONFIG[i][e][a]}`)
}
} else if (i === "autocontain") {
for (const e in USERCONFIG[i]) {
parsedAucmds.push(
`autocontain ${e} ${USERCONFIG[i][e]}`,
)
}
parsedAucmds.push(`autocontain ${e} ${USERCONFIG[i][e]}`)
} else if (i === "logging") {
for (const e in USERCONFIG[i]) {
// Map the int values in e to a log level
let level
if (USERCONFIG[i][e] === 0) level = "never"
@ -1420,13 +1414,12 @@ export function parseConfig(): string {
if (USERCONFIG[i][e] === 3) level = "info"
if (USERCONFIG[i][e] === 4) level = "debug"
parsedLogging.push(`set logging.${e} ${level}`)
}
} else {
for (let e in USERCONFIG[i]) {
parsedConf.push(`set ${i}.${e} ${USERCONFIG[i][e]}`)
}
}
}
}
let genSettings = ``
let bindSettings = ``