summaryrefslogtreecommitdiffstats
path: root/modules/plugins/assistant/codecompanion/codecompanion-nvim.nix
blob: 119a3b6fe4243204662aab6b93d11498d4a75252 (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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
{lib, ...}: let
  inherit (lib.options) mkOption mkEnableOption literalExpression;
  inherit (lib.types) int str enum nullOr attrs either submodule;
  inherit (lib.nvim.types) mkPluginSetupOption luaInline;
in {
  options.vim.assistant = {
    codecompanion-nvim = {
      enable = mkEnableOption "complementary neovim plugin for codecompanion.nvim";

      setupOpts = mkPluginSetupOption "codecompanion-nvim" {
        opts = {
          send_code =
            mkEnableOption ""
            // {
              default = true;
              description = ''
                Whether to enable code being sent to the LLM.
              '';
            };

          log_level = mkOption {
            type = enum ["DEBUG" "INFO" "ERROR" "TRACE"];
            default = "ERROR";
            description = "Change the level of logging.";
          };

          language = mkOption {
            type = str;
            default = "English";
            description = "Specify which language an LLM should respond in.";
          };
        };

        display = {
          diff = {
            enabled =
              mkEnableOption ""
              // {
                default = true;
                description = ''
                  Whether to enable a diff view
                  to see the changes made by the LLM.
                '';
              };

            close_chat_at = mkOption {
              type = int;
              default = 240;
              description = ''
                Close an open chat buffer if the
                total columns of your display are less than...
              '';
            };

            layout = mkOption {
              type = enum ["vertical" "horizontal"];
              default = "vertical";
              description = "Type of split for default provider.";
            };

            provider = mkOption {
              type = enum ["inline" "split" "mini_diff"];
              default = "inline";
              description = "The preferred kind of provider.";
            };
          };

          inline = {
            layout = mkOption {
              type = enum ["vertical" "horizontal" "buffer"];
              default = "vertical";
              description = "Customize how output is created in new buffer.";
            };
          };

          chat = {
            auto_scroll =
              mkEnableOption ""
              // {
                default = true;
                description = "Whether to enable automatic page scrolling.";
              };

            show_settings = mkEnableOption ''
              LLM settings to appear at the top of the chat buffer.
            '';

            start_in_insert_mode = mkEnableOption ''
              opening the chat buffer in insert mode.
            '';

            show_header_separator = mkEnableOption ''
              header separators in the chat buffer.

              Set this to false if you're using an
              external markdown formatting plugin.
            '';

            show_references =
              mkEnableOption ""
              // {
                default = true;
                description = ''
                  Whether to enable references in the chat buffer.
                '';
              };

            show_token_count =
              mkEnableOption ""
              // {
                default = true;
                description = ''
                  Whether to enable the token count for each response.
                '';
              };

            intro_message = mkOption {
              type = str;
              default = "Welcome to CodeCompanion ✨! Press ? for options.";
              description = "Message to appear in chat buffer.";
            };

            separator = mkOption {
              type = str;
              default = "─";
              description = ''
                The separator between the
                different messages in the chat buffer.
              '';
            };

            icons = {
              pinned_buffer = mkOption {
                type = str;
                default = " ";
                description = "The icon to represent a pinned buffer.";
              };

              watched_buffer = mkOption {
                type = str;
                default = "👀 ";
                description = "The icon to represent a watched buffer.";
              };
            };
          };

          action_palette = {
            width = mkOption {
              type = int;
              default = 95;
              description = "Width of the action palette.";
            };

            height = mkOption {
              type = int;
              default = 10;
              description = "Height of the action palette.";
            };

            prompt = mkOption {
              type = str;
              default = "Prompt ";
              description = "Prompt used for interactive LLM calls.";
            };

            provider = mkOption {
              type = enum ["default" "telescope" "mini_pick"];
              default = "default";
              description = "Provider used for the action palette.";
            };

            opts = {
              show_default_actions =
                mkEnableOption ""
                // {
                  default = true;
                  description = ''
                    Whether to enable showing default
                    actions in the action palette.
                  '';
                };

              show_default_prompt_library =
                mkEnableOption ""
                // {
                  default = true;
                  description = ''
                    Whether to enable showing default
                    prompt library in the action palette.
                  '';
                };
            };
          };
        };

        adapters = mkOption {
          type = nullOr luaInline;
          default = null;
          description = "An adapter is what connects Neovim to an LLM.";
        };

        interactions = {
          chat = {
            adapter = mkOption {
              default = null;
              description = "Adapter used for the chat interaction.";
              type = nullOr (either str (submodule {
                options = {
                  name = mkOption {
                    type = nullOr str;
                    default = null;
                    description = "Name of the Adapter";
                  };

                  model = mkOption {
                    type = nullOr str;
                    default = null;
                    description = "Model used for Adapter.";
                  };
                };
              }));
            };

            keymaps = mkOption {
              type = nullOr attrs;
              default = null;
              description = "Define or override the default keymaps.";
            };

            variables = mkOption {
              type = nullOr luaInline;
              default = null;
              description = ''
                Define your own variables
                to share specific content.
              '';
            };

            slash_commands = mkOption {
              type = nullOr luaInline;
              default = null;
              description = ''
                Slash Commands (invoked with /) let you dynamically
                insert context into the chat buffer,
                such as file contents or date/time.
              '';
            };

            tools = mkOption {
              type = nullOr attrs;
              default = null;
              description = ''
                Configure tools to perform specific
                tasks when invoked by an LLM.
              '';
            };

            roles = mkOption {
              type = nullOr luaInline;
              default = null;
              description = ''
                The chat buffer places user and LLM responses under a H2 header.
                These can be customized in the configuration.
              '';
            };
          };

          inline = {
            adapter = mkOption {
              default = null;
              description = "Adapter used for the inline interaction.";
              type = nullOr (either str (submodule {
                options = {
                  name = mkOption {
                    type = nullOr str;
                    default = null;
                    description = "Name of the Adapter";
                  };

                  model = mkOption {
                    type = nullOr str;
                    default = null;
                    description = "Model used for Adapter.";
                  };
                };
              }));
            };

            variables = mkOption {
              type = nullOr luaInline;
              default = null;
              description = ''
                Define your own variables
                to share specific content.
              '';
            };

            keymaps = {
              accept_change = {
                n = mkOption {
                  type = str;
                  default = "ga";
                  description = "Accept the suggested change.";
                };
              };

              reject_change = {
                n = mkOption {
                  type = str;
                  default = "gr";
                  description = "Reject the suggested change.";
                };
              };
            };
          };
        };

        prompt_library = mkOption {
          type = nullOr attrs;
          default = null;
          description = ''
            A prompt library is a collection of prompts
            that can be used in the action palette.
          '';
        };
      };
    };
  };
}