from libdotfiles import packages, util


def run():
    spell_dir = "~/.config/nvim/spell/"
    if util.distro_name() == "arch":
        packages.try_install("neovim")
        packages.try_install("neovim", method="pip")
    elif util.distro_name() == "linuxmint":
        packages.try_install("neovim")
        packages.try_install("python3-neovim")
    packages.try_install("black", method="pip")

    for name in ["undo", "backup", "swap", "spell"]:
        util.create_dir("~/.config/nvim/" + name)

    for path in util.find("./nvim/*.vim"):
        util.create_symlink(path, "~/.config/nvim/")
    util.create_symlink("./editorconfig", "~/.editorconfig")
    util.create_symlink("./spell/pl.utf-8.add", spell_dir)
    util.create_symlink("./spell/en.utf-8.add", spell_dir)
    util.download(
        "ftp://ftp.vim.org/pub/vim/runtime/spell/en.utf-8.spl",
        "~/.config/nvim/spell/",
    )
    util.download(
        "ftp://ftp.vim.org/pub/vim/runtime/spell/pl.utf-8.spl",
        "~/.config/nvim/spell/",
    )
    util.download(
        "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim",
        "~/.config/nvim/autoload/plug.vim",
    )
    util.create_file(
        "~/.config/zsh/editor.sh",
        "export EDITOR=nvim;alias vim=nvim",
        overwrite=True,
    )

    commands = ["PlugInstall"]
    for path in util.find(spell_dir):
        if "add" in path and "spl" not in path:
            commands.append("mkspell! " + path)
    util.run_verbose(["nvim"] + sum([["-c", cmd] for cmd in commands], []))

from libdotfiles import packages, util


def run():
    spell_dir = "~/.config/nvim/spell/"
    if util.distro_name() == "arch":
        packages.try_install("neovim")
        packages.try_install("pynvim", method="pip")
    elif util.distro_name() == "linuxmint":
        packages.try_install("neovim")
        packages.try_install("python3-neovim")
    packages.try_install("black", method="pip")
    packages.try_install("isort", method="pip")

    for name in ["undo", "backup", "swap", "spell"]:
        util.create_dir("~/.config/nvim/" + name)

    for path in util.find("./nvim/*.vim"):
        util.create_symlink(path, "~/.config/nvim/")
    util.create_symlink("./editorconfig", "~/.editorconfig")
    util.create_symlink("./spell/pl.utf-8.add", spell_dir)
    util.create_symlink("./spell/en.utf-8.add", spell_dir)
    util.download(
        "ftp://ftp.vim.org/pub/vim/runtime/spell/en.utf-8.spl",
        "~/.config/nvim/spell/",
    )
    util.download(
        "ftp://ftp.vim.org/pub/vim/runtime/spell/pl.utf-8.spl",
        "~/.config/nvim/spell/",
    )
    util.download(
        "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim",
        "~/.config/nvim/autoload/plug.vim",
    )
    util.create_file(
        "~/.config/zsh/editor.sh",
        "export EDITOR=nvim;alias vim=nvim",
        overwrite=True,
    )

    commands = ["PlugInstall"]
    for path in util.find(spell_dir):
        if "add" in path and "spl" not in path:
            commands.append("mkspell! " + path)
    util.run_verbose(["nvim"] + sum([["-c", cmd] for cmd in commands], []))

fix install