aboutsummaryrefslogtreecommitdiff
path: root/modules/neovim/default.nix
blob: fd7708597530b3ea886e7ae97401e3d36a3f3819 (plain)
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
{ config, lib, pkgs, ...}:
let
  cfg = config.modules.neovim;
  lua = str: "lua << EOF\n${str}\nEOF\n";
  luaImport = file: "lua << EOF\n${builtins.readFile file}\nEOF\n";
in
{
  options.modules.neovim = {
        enable = lib.mkEnableOption "neovim";
  };

  config = {
    programs.neovim = lib.mkIf cfg.enable {
      enable = true;
      defaultEditor = true;
      viAlias = true;
      vimAlias = true;
      vimdiffAlias = true;
      plugins = with pkgs.vimPlugins; [
        {
          plugin = nvim-lspconfig;
          config = let
            servers = [
              { name = "clangd"; }
            ];
          in lua (pkgs.lib.strings.concatStrings (pkgs.lib.lists.forEach servers (s: "require('lspconfig')['${s.name}'].setup(${s.config or "{}"})\n")));
        }

        (nvim-treesitter.withPlugins (p: with p; [
          tree-sitter-nix
          tree-sitter-c
          tree-sitter-lua
          tree-sitter-zig
          tree-sitter-markdown
          tree-sitter-markdown-inline
        ]))

        base16-nvim
        telescope-nvim
        telescope-fzf-native-nvim
      ];
      extraLuaConfig = ''
          ${builtins.readFile ./settings.lua}
          ${builtins.readFile ./keybinds.lua}
      '';
    };
  };
}