mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-11-17 22:16:26 +00:00
Better handling of meta names
This commit is contained in:
parent
8d0123a2f7
commit
0b5655c955
@ -28,6 +28,12 @@ class Language(Enum):
|
|||||||
YAML = "yaml"
|
YAML = "yaml"
|
||||||
|
|
||||||
|
|
||||||
|
META_LANGS: dict[Language, set[Language]] = {
|
||||||
|
Language.NEOVIM: {Language.VIM, Language.LUA},
|
||||||
|
Language.WEB: {Language.CSS, Language.JAVASCRIPT, Language.HTML},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def command_exists(command: str) -> bool:
|
def command_exists(command: str) -> bool:
|
||||||
return shutil.which(command) is not None
|
return shutil.which(command) is not None
|
||||||
|
|
||||||
@ -60,7 +66,9 @@ def maybe_pip_install(*args: str, library=False) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if not library and command_exists("pipx"):
|
if not library and command_exists("pipx"):
|
||||||
return all([maybe_run("pipx", "upgrade", "--install", bin) for bin in user_bins])
|
return all(
|
||||||
|
[maybe_run("pipx", "upgrade", "--install", bin) for bin in user_bins]
|
||||||
|
)
|
||||||
elif command_exists("pip3"):
|
elif command_exists("pip3"):
|
||||||
return maybe_run(
|
return maybe_run(
|
||||||
"pip3",
|
"pip3",
|
||||||
@ -138,9 +146,9 @@ def install_language_servers(langs: set[Language]):
|
|||||||
def install_linters(langs: set[Language]):
|
def install_linters(langs: set[Language]):
|
||||||
if Language.PYTHON in langs:
|
if Language.PYTHON in langs:
|
||||||
maybe_pip_install("mypy")
|
maybe_pip_install("mypy")
|
||||||
if {Language.CSS, Language.WEB} & langs:
|
if Language.CSS in langs:
|
||||||
maybe_npm_install("csslint")
|
maybe_npm_install("csslint")
|
||||||
if {Language.VIM, Language.NEOVIM} in langs:
|
if Language.VIM in langs:
|
||||||
maybe_pip_install("vim-vint")
|
maybe_pip_install("vim-vint")
|
||||||
if Language.YAML in langs:
|
if Language.YAML in langs:
|
||||||
maybe_pip_install("yamllint")
|
maybe_pip_install("yamllint")
|
||||||
@ -163,7 +171,7 @@ def install_linters(langs: set[Language]):
|
|||||||
"golangci-lint-{version}-{system}-{arch}.tar.gz",
|
"golangci-lint-{version}-{system}-{arch}.tar.gz",
|
||||||
"/tmp/",
|
"/tmp/",
|
||||||
)
|
)
|
||||||
if {Language.LUA, Language.NEOVIM} & langs:
|
if Language.LUA in langs:
|
||||||
if not maybe_run("lua", "-e", "require('lfs')"):
|
if not maybe_run("lua", "-e", "require('lfs')"):
|
||||||
maybe_run("luarocks", "--local", "install", "luafilesystem")
|
maybe_run("luarocks", "--local", "install", "luafilesystem")
|
||||||
maybe_run("luarocks", "--local", "install", "luacheck", "1.1.0")
|
maybe_run("luarocks", "--local", "install", "luacheck", "1.1.0")
|
||||||
@ -216,13 +224,13 @@ def install_fixers(langs: set[Language]):
|
|||||||
Language.CSS,
|
Language.CSS,
|
||||||
Language.WEB,
|
Language.WEB,
|
||||||
Language.JSON,
|
Language.JSON,
|
||||||
} & set(langs):
|
} & langs:
|
||||||
maybe_npm_install("prettier")
|
maybe_npm_install("prettier")
|
||||||
if Language.PYTHON in langs:
|
if Language.PYTHON in langs:
|
||||||
maybe_pip_install("black", "reorder-python-imports", "isort")
|
maybe_pip_install("black", "reorder-python-imports", "isort")
|
||||||
if Language.RUST in langs:
|
if Language.RUST in langs:
|
||||||
maybe_run("rustup", "component", "add", "rustfmt")
|
maybe_run("rustup", "component", "add", "rustfmt")
|
||||||
if {Language.LUA, Language.NEOVIM} in langs:
|
if Language.LUA in langs:
|
||||||
_ = maybe_release_gitter(
|
_ = maybe_release_gitter(
|
||||||
stylua=[
|
stylua=[
|
||||||
"--git-url",
|
"--git-url",
|
||||||
@ -268,14 +276,11 @@ def main():
|
|||||||
|
|
||||||
langs = set(args.langs or Language)
|
langs = set(args.langs or Language)
|
||||||
|
|
||||||
# Handle some aliases
|
# Expand meta languages
|
||||||
if Language.NEOVIM in langs:
|
for lang, aliases in META_LANGS.items():
|
||||||
langs.add(Language.VIM)
|
if lang in langs:
|
||||||
langs.add(Language.LUA)
|
langs.update(aliases)
|
||||||
if Language.WEB in langs:
|
|
||||||
langs.add(Language.CSS)
|
|
||||||
langs.add(Language.JAVASCRIPT)
|
|
||||||
langs.add(Language.HTML)
|
|
||||||
|
|
||||||
install_language_servers(langs)
|
install_language_servers(langs)
|
||||||
install_linters(langs)
|
install_linters(langs)
|
||||||
|
Loading…
Reference in New Issue
Block a user