Home

dotnix @e71b2fa7a3682280b700be2a61ae3150b9a39898 - refs - log -
-
https://git.jolheiser.com/dotnix.git
My nix dotfiles
dotnix / apps / nogui / helix.nix
- raw
  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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
{pkgs, ...}: let
  query = scm:
    builtins.readFile (pkgs.fetchFromGitea {
        domain = "git.jojodev.com";
        owner = "jolheiser";
        repo = "templ-helix";
        rev = "2a47b9c5af0fd9ae8bba8198fd66abc6d07fdf10";
        sha256 = "sha256-pTdOX9bPup626t+ko6k3Xq/tprAMAZCUBl+xeIBkhfs=";
      }
      + "/queries/templ/${scm}.scm");
in {
  programs.helix = {
    enable = true;
    defaultEditor = true;
    settings = {
      theme = "catppuccin_mocha_transparent";
      editor = {
        line-number = "relative";
        mouse = false;
        bufferline = "always";
        color-modes = true;
        cursor-shape = {
          insert = "bar";
          normal = "block";
          select = "underline";
        };
        file-picker = {hidden = false;};
        indent-guides = {
          render = true;
          skip-levels = 1;
        };
        soft-wrap = {enable = true;};
        statusline = {
          right = [
            "version-control"
            "diagnostics"
            "selections"
            "position"
            "file-encoding"
          ];
        };
        lsp = {display-messages = true;};
      };
      keys = {
        normal = {
          space = {
            q = ":quit";
            Q = ":quit!";
            w = ":write";
            W = ":write!";
          };
          C-c = ":config-open";
          C-r = ":config-reload";
          "C-/" = "toggle_comments";
          S-right = "goto_next_buffer";
          S-left = "goto_previous_buffer";
          C-b = ":buffer-close";
          C-s = ["select_all" "select_regex"];

          C-j = "shrink_selection";
          C-k = "expand_selection";
          C-l = "select_next_sibling";
          C-a = "select_all";
          C-u = ["half_page_up" "align_view_center"];
          C-d = ["half_page_down" "align_view_center"];

          "{" = ["goto_prev_paragraph" "collapse_selection"];
          "}" = ["goto_next_paragraph" "collapse_selection"];
          "0" = "goto_line_start";
          "$" = "goto_line_end";
          "^" = "goto_first_nonwhitespace";
          G = "goto_file_end";
          "%" = "match_brackets";
          V = ["select_mode" "extend_to_line_bounds"];
          C = ["collapse_selection" "extend_to_line_end" "change_selection"];
          D = ["extend_to_line_end" "delete_selection"];
          S = "surround_add";

          d = {
            d = ["extend_to_line_bounds" "delete_selection"];
            t = ["extend_till_char"];
            s = ["surround_delete"];
            i = ["select_textobject_inner"];
            a = ["select_textobject_around"];
          };

          x = "delete_selection";
          p = "paste_clipboard_after";
          P = "paste_clipboard_before";
          y = [
            "yank_main_selection_to_clipboard"
            "normal_mode"
            "flip_selections"
            "collapse_selection"
          ];
          Y = [
            "extend_to_line_bounds"
            "yank_main_selection_to_clipboard"
            "goto_line_start"
            "collapse_selection"
          ];

          w = ["move_next_word_start" "move_char_right" "collapse_selection"];
          e = ["move_next_word_end" "collapse_selection"];
          b = ["move_prev_word_start" "collapse_selection"];

          i = ["insert_mode" "collapse_selection"];
          a = ["append_mode" "collapse_selection"];

          esc = ["collapse_selection" "keep_primary_selection"];
        };
        insert = {esc = ["collapse_selection" "normal_mode"];};
        select = {
          space = {
            j = {
              e = ":pipe jq";
              c = ":pipe jq -c";
            };
          };
          "{" = ["extend_to_line_bounds" "goto_prev_paragraph"];
          "}" = ["extend_to_line_bounds" "goto_next_paragraph"];
          "0" = "goto_line_start";
          "$" = "goto_line_end";
          "^" = "goto_first_nonwhitespace";
          G = "goto_file_end";
          D = ["extend_to_line_bounds" "delete_selection" "normal_mode"];
          C = ["goto_line_start" "extend_to_line_bounds" "change_selection"];
          "%" = "match_brackets";
          S = "surround_add";

          i = "select_textobject_inner";
          a = "select_textobject_around";

          tab = ["insert_mode" "collapse_selection"];
          C-a = ["append_mode" "collapse_selection"];

          k = ["extend_line_up" "extend_to_line_bounds"];
          j = ["extend_line_down" "extend_to_line_bounds"];

          d = ["yank_main_selection_to_clipboard" "delete_selection"];
          x = ["yank_main_selection_to_clipboard" "delete_selection"];
          y = [
            "yank_main_selection_to_clipboard"
            "normal_mode"
            "flip_selections"
            "collapse_selection"
          ];
          Y = [
            "extend_to_line_bounds"
            "yank_main_selection_to_clipboard"
            "goto_line_start"
            "collapse_selection"
            "normal_mode"
          ];
          p = "replace_selections_with_clipboard";
          P = "paste_clipboard_before";

          esc = ["collapse_selection" "keep_primary_selection" "normal_mode"];
        };
      };
    };
    languages = {
      language = [
        {
          name = "go";
          formatter = {
            command = "gofumpt";
          };
        }
        {
          name = "lua";
          formatter = {
            command = "luafmt";
            args = ["--stdin"];
          };
        }
        {
          name = "python";
          auto-format = true;
          formatter = {
            command = "black";
            args = ["--quiet" "-"];
          };
        }
        {
          name = "nix";
          auto-format = true;
          formatter = {
            command = "alejandra";
            args = ["-qq"];
          };
        }
        {
          name = "templ";
          auto-format = true;
          scope = "source.templ";
          injection-regex = "templ";
          file-types = ["templ"];
          roots = ["go.mod"];
          comment-token = "//";
          language-server = {
            command = "templ";
            args = ["lsp"];
          };
          formatter = {
            command = "templ";
            args = ["fmt"];
          };
        }
      ];
      grammar = [
        {
          name = "templ";
          source = {
            git = "https://github.com/vrischmann/tree-sitter-templ";
            rev = "9f63037ad08a58050d0582ef1ae0009bd0fbf2f1";
          };
        }
      ];
    };
    themes = {
      catppuccin_frappe_transparent = {
        inherits = "catppuccin_frappe";
        "ui.background" = {};
      };
      catppuccin_latte_transparent = {
        inherits = "catppuccin_latte";
        "ui.background" = {};
      };
      catppuccin_macchiato_transparent = {
        inherits = "catppuccin_macchiato";
        "ui.background" = {};
      };
      catppuccin_mocha_transparent = {
        inherits = "catppuccin_mocha";
        "ui.background" = {};
      };
    };
  };
  xdg.configFile = {
    "helix/runtime/queries/templ/highlights.scm".text = query "highlights";
    "helix/runtime/queries/templ/indents.scm".text = query "indents";
    "helix/runtime/queries/templ/injections.scm".text = query "injections";
    "helix/runtime/queries/templ/structure.scm".text = query "structure";
  };
}