{
  neovim,
  tree-sitter,
  python3,
  vimPlugins,
  omnisharp-roslyn,
  callPackage,
  lib,
  fetchFromGitHub,
}:
let
  ftPlugins = with vimPlugins; [
    {
      plug = vim-graphql;
      ft = "graphql";
      ext = "graphql";
    }
    {
      plug = callPackage ./omnisharp-vim.nix { };
      ft = "cs";
      ext = "cs";
    }
    {
      plug = vim-qml;
      ft = "qml";
      ext = "qml";
      init = "set smartindent";
    }
    {
      plug = vim-toml;
      ft = "toml";
      ext = "toml";
    }
    {
      plug = vim-terraform;
      ft = "terraform";
      ext = "tf";
    }
    {
      plug = kotlin-vim;
      ft = "kotlin";
      ext = "kts";
    }
    {
      plug = callPackage ./vim-arduino.nix { };
      ft = "arduino";
      ext = "ino";
    }
    {
      plug = coc-nvim;
      ft = "java";
      ext = "java";
      init = "let b:ale_disable_lsp = 1";
    }
    {
      plug = coc-nvim;
      ft = "slint";
      ext = "slint";
      init = "set smartindent";
    }
    {
      plug = nvim-metals;
      ft = "scala";
      ext = "scala";
      init = "lua require('metals').initialize_or_attach({})";
    }
  ];
  plugins = builtins.attrNames (builtins.readDir ./vimrc.d);
in
neovim.override {
  vimAlias = true;

  configure = {
    customRC =
      builtins.readFile ./vimrc
      + "\" LSP paths (autogenerated) {{{\n"
      + "let g:OmniSharp_server_path = '${omnisharp-roslyn}/bin/omnisharp'\n"
      + "\" }}}"
      + "\n\" Filetype plugins (autogenerated) {{{\n"
      + lib.concatMapStrings (
        x:
        "autocmd BufRead,BufNewFile *.${x.ext} packadd ${x.plug.pname} | set filetype=${x.ft}\n"
        + "autocmd FileType ${x.ft} packadd ${x.plug.pname}\n"
        + (if x ? init then "autocmd FileType ${x.ft} ${x.init}\n" else "")
      ) ftPlugins
      + "\" }}}\n\n\" vimrc.d/ contents:\n\n"
      + lib.concatMapStrings (x: "\" ${x}\n${(builtins.readFile (./vimrc.d + "/${x}"))}\n\n") plugins;

    packages.leovim = with vimPlugins; {
      start = [
        vim-abolish
        vim-unimpaired
        vim-hardtime
        editorconfig-vim
        vim-sleuth
        plenary-nvim
        ale
        nvim-treesitter.withAllGrammars
        playground
        nvim-treesitter-refactor
        vim-auto-save
        (callPackage ./nvim-echo-diagnostics.nix { })
        nvim-solarized-lua
        (callPackage ./vim-poryscript.nix { })
        vim-fetch
        direnv-vim
      ];

      opt = [ vimspector ] ++ map (x: x.plug) ftPlugins;
    };
  };
}
