Skip to content

TwIStOy/dotvim

Repository files navigation

dotvim

License Repo Size

✨Features

Caution

Please use my configuration with care and understand what will happen before using it. If you are looking for a more general configuration, see dora.nvim

⚡️Requirements

  1. Neovim 0.9+ (nightly is better)
  2. Nerd Fonts
    • Any nerd font to show glyph correctly.
    • Or using font fallback(kitty, wezterm) if terminal supports that.
  3. Node
  4. Terminal with true color and graphic protocol support, recommand Kitty
  5. (Optional) rime_ls: RIME as LSP
  6. Optional Requirements

📦Installation

Non-nix

$ ln -s /path/to/dotvim ~/.dotvim
$ mkdir -p ~/.config/nvim
$ cp ~/.dotvim/init.lua ~/.config/nvim/init.lua

Nix

{
  config,
  lib,
  pkgs,
  pkgs-unstable,
  nur-hawtian,
  ...
}: let
  user-dotpath = "${config.home.homeDirectory}/.dotvim";

  plugins = {
    inherit (nur-hawtian.packages.${pkgs.system}.vimPlugins) gh-actions-nvim;
    inherit (pkgs-unstable.vimPlugins) telescope-fzf-native-nvim;
    inherit (pkgs-unstable.vimPlugins) markdown-preview-nvim;
  };

  bins = with pkgs-unstable; {
    inherit fzf stylua lua-language-server statix;
    clangd = llvmPackages_17.clang-unwrapped;
    clang-format = llvmPackages_17.clang-unwrapped;
    inherit (python312Packages) black;
    inherit (pkgs) rust-analyzer rustfmt;
  };

  nixAwareNvimConfig = pkgs.stdenv.mkDerivation {
    name = "nix-aware-nvim-config";

    buildInputs =
      (lib.mapAttrsToList (_: pkg: pkg) plugins)
      ++ (lib.mapAttrsToList (_: pkg: pkg) bins);

    phases = ["installPhase"];

    nixAwareNvimConfigJson =
      pkgs.writeText
      "nixAwareNvimConfig.json"
      (builtins.toJSON {
        pkgs = plugins;
        bin = lib.mapAttrs (name: pkg: "${pkg}/bin/${name}") bins;
        try_nix_only = true;
      });

    installPhase = ''
      mkdir -p $out
      cp $nixAwareNvimConfigJson $out/nix-aware.json
    '';
  };

  init-dora = ''
    vim.loader.enable()
    local dotpath = "${user-dotpath}"
    vim.opt.rtp:prepend(dotpath)
    require("dotvim").setup()
  '';
in {
  home.packages = with pkgs; [
    python3.pkgs.pynvim
    nodePackages.neovim
    tree-sitter
    nixAwareNvimConfig
  ];

  programs.neovim = {
    enable = true;
    package = pkgs.neovim-nightly;
    plugins = builtins.attrValues plugins;
  };

  xdg.configFile = {
    "nvim/init.lua" = {
      text = init-dora;
      force = true;
    };
    "nvim/nix-aware.json" = {
      source = "${nixAwareNvimConfig}/nix-aware.json";
      force = true;
    };
  };
}