summaryrefslogtreecommitdiffstats
path: root/modules/by-name/nv/nvim/module.nix
blob: 66ba7ad6982766dad816d5f23c912a51b2ca051e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
  pkgs,
  lib,
  config,
  extra_modules,
  extra_lib,
  ...
}: let
  cfg = config.soispha.programs.nvim;

  plgs = builtins.attrValues (extra_lib.mkByName {
    useShards = false;
    baseDirectory = ./plgs;
    fileName = "default.nix";
    finalizeFunction = name: path: import path {inherit config lib pkgs extra_lib;};
  });

  autocmds = import ./autocmds {inherit config;};
  clipboard = import ./clipboard {};
  mappings = import ./mappings {};
  options = import ./options {inherit config lib;};
  performance = import ./performance {};
in {
  options.soispha.programs.nvim = {
    enable = lib.mkEnableOption "custom nvim config";
    shell = lib.mkOption {
      type = lib.types.package;
      description = "The package to use for the shell in :!";
    };
  };

  config = lib.mkIf cfg.enable (
    lib.mkMerge (plgs
      ++ [
        autocmds
        clipboard
        mappings
        options
        performance
        {
          soispha.services.unison.pathsToSync = [
            "~/.local/state/nvim"
          ];
          vhack.persist.userDirectories.soispha = [
            ".local/state/nvim"
          ];

          home-manager.users.soispha = {
            imports = [
              extra_modules.home.nixvim
            ];

            home.sessionVariables = {
              EDITOR = "nvim";
              VISUAL = "nvim";
              CODEEDITOR = "nvim";
            };

            programs.nixvim = {
              enable = true;

              # Use my global nixpkgs set, instead of constructing a separate one.
              nixpkgs.useGlobalPackages = true;

              # source: https://www.patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=Neovim
              extraConfigLuaPre = lib.mkBefore ''
                ---------------------------------------------------------------------------
                --
                --     ███╗   ██╗███████╗ ██████╗ ██╗   ██╗██╗███╗   ███╗
                --     ████╗  ██║██╔════╝██╔═══██╗██║   ██║██║████╗ ████║
                --     ██╔██╗ ██║█████╗  ██║   ██║██║   ██║██║██╔████╔██║
                --     ██║╚██╗██║██╔══╝  ██║   ██║╚██╗ ██╔╝██║██║╚██╔╝██║
                --     ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║
                --     ╚═╝  ╚═══╝╚══════╝ ╚═════╝   ╚═══╝  ╚═╝╚═╝     ╚═╝
                --
                ---------------------------------------------------------------------------
              '';

              extraPackages = [
                /*
                These are mostly linters and formatters used for different file types.
                Including them here is fine, as they are not necessarily-sync able to different people.
                */
                # nix
                pkgs.alejandra
                pkgs.statix

                # yaml
                pkgs.yamllint

                # shell
                pkgs.shellcheck
                pkgs.shfmt
              ];
            };
          };
        }
      ])
  );
}