aboutsummaryrefslogtreecommitdiff
path: root/modules/user/editors/kakoune/default.nix
blob: 07a246126af8f8a60be7c29096df7ef5db9e2cf1 (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
{
  config,
  lib,
  options,
  pkgs,
  ...
}:
{
  config.programs.kakoune = lib.mkIf config.editors.kakoune.enable {
    enable = true;
    colorSchemePackage = pkgs.kakounePlugins.kakoune-catppuccin;
    config = {
      alignWithTabs = true;
      colorScheme = "catppuccin_mocha";
      hooks = [
        {
          commands = "set window tabstop 2";
          group = "set-indentwidth";
          name = "WinSetOption";
          option = "filetype=(nix)";
        }
        {
          commands = "lsp-enable-window";
          name = "WinSetOption";
          option = "filetype=(css|html|java|zig)";
        }
        {
          commands = "set buffer filetype json";
          name = "BufCreate";
          option = ".*\.mcmeta";
        }
        {
          commands = ''
                        	        	set buffer lsp_servers %{
            	            	        	[vscode-json-language-server]
            		            	        args = ["--stdio"]
            		            	        root_globs = [".git"]
            		            	        settings_section = "_"
            		            	        [[vscode-json-language-server.settings._]]
            			            	      provideFormatter = true
            			            	      json.format.enable = true
            			            	      json.validate.enabble = true

                        		        	[[vscode-json-language-server.settings._.json.schemas]]
                        			        fileMatch = ["fabric.mod.json"]
                        			        url = "https://www.schemastore.org/fabric.mod.json"
                        	        	}
                        	        '';
          name = "BufSetOption";
          option = "filetype=json";
        }
      ];

      indentWidth = 0;
      keyMappings = [
        {
          docstring = "Open a new window";
          effect = ":new<ret>";
          key = "<c-w>";
          mode = "normal";
        }
        {
          docstring = "Open a new file";
          effect = ":e %sh{${pkgs.fd}/bin/fd -tf | fuzzel --prompt=\"open: \" --dmenu --minimal-lines --width=60}<ret>";
          key = "<c-o>";
          mode = "normal";
        }
        {
          docstring = "Comment the selected line(s)";
          effect = ":comment-line<ret>";
          key = "<c-a-c>";
          mode = "normal";
        }
        {
          docstring = "Rename the symbol below the cursor";
          effect = ":lsp-rename-prompt<ret>";
          key = "<a-r>";
          mode = "normal";
        }
        {
          docstring = "Create a new file";
          effect = ":e %sh{${(pkgs.writeShellScript "newfile" (builtins.readFile ./newfile.sh))}}<ret>";
          key = "<c-a-n>";
          mode = "normal";
        }
      ];

      numberLines = {
        enable = true;
        highlightCursor = true;
        relative = true;
      };

      tabStop = 4;
      ui.assistant = "cat";
    };

    defaultEditor = true;
    extraConfig = builtins.readFile ./kakrc;
    plugins = with pkgs.kakounePlugins; [
      auto-pairs-kak
      kakoune-extra-filetypes
      kakoune-lsp
    ];
  };

  options.editors.kakoune.enable = lib.mkEnableOption "rosa's kakoune setup";
}