-
-
Notifications
You must be signed in to change notification settings - Fork 393
Expand file tree
/
Copy pathcodecompanion.txt
More file actions
6685 lines (5048 loc) · 231 KB
/
codecompanion.txt
File metadata and controls
6685 lines (5048 loc) · 231 KB
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*codecompanion.txt* For NVIM v0.11 Last change: 2026 January 21
==============================================================================
Table of Contents *codecompanion-table-of-contents*
1. Welcome |codecompanion-welcome|
- Features |codecompanion-welcome-features|
- Overview |codecompanion-welcome-overview|
- Supported LLMs and Agents|codecompanion-welcome-supported-llms-and-agents|
2. Installation |codecompanion-installation|
- Requirements |codecompanion-installation-requirements|
- Installation |codecompanion-installation-installation|
- Extensions |codecompanion-installation-extensions|
- Other s |codecompanion-installation-other-s|
- Completion |codecompanion-installation-completion|
- Help |codecompanion-installation-help|
3. Getting Started |codecompanion-getting-started|
- Documentation |codecompanion-getting-started-documentation|
- Interactions |codecompanion-getting-started-interactions|
- With an Adapter |codecompanion-getting-started-with-an-adapter|
- Chat Buffer |codecompanion-getting-started-chat-buffer|
- Inline Assistant |codecompanion-getting-started-inline-assistant|
- Commands |codecompanion-getting-started-commands|
- Action Palette |codecompanion-getting-started-action-palette|
- List of Commands |codecompanion-getting-started-list-of-commands|
- Suggested Workflow |codecompanion-getting-started-suggested-workflow|
4. Upgrading General |codecompanion-upgrading-general|
- v17.33.0 to v18.0.0 |codecompanion-upgrading-general-v17.33.0-to-v18.0.0|
- default_memory has been renamed to autoload (#2509)|codecompanion-upgrading-general-default_memory-has-been-renamed-to-autoload-(#2509)|
5. Configuration |codecompanion-configuration|
- Action Palette |codecompanion-configuration-action-palette|
- ACP Adapters |codecompanion-configuration-acp-adapters|
- HTTP Adapters |codecompanion-configuration-http-adapters|
- Chat Buffer |codecompanion-configuration-chat-buffer|
- Inline Assistant |codecompanion-configuration-inline-assistant|
- Rules |codecompanion-configuration-rules|
- Prompt Library |codecompanion-configuration-prompt-library|
- System Prompts |codecompanion-configuration-system-prompts|
- Extensions |codecompanion-configuration-extensions|
- Other Options |codecompanion-configuration-other-options|
6. Usage |codecompanion-usage|
- General |codecompanion-usage-general|
- ACP Protocol Reference |codecompanion-usage-acp-protocol-reference|
- Action Palette |codecompanion-usage-action-palette|
- Chat Buffer |codecompanion-usage-chat-buffer|
- Agents |codecompanion-usage-agents|
- Rules |codecompanion-usage-rules|
- Tools |codecompanion-usage-tools|
- Slash Commands |codecompanion-usage-slash-commands|
- Variables |codecompanion-usage-variables|
- Events / Hooks |codecompanion-usage-events-/-hooks|
- Inline Assistant |codecompanion-usage-inline-assistant|
- Prompt Library |codecompanion-usage-prompt-library|
- User Interface |codecompanion-usage-user-interface|
- Workflows |codecompanion-usage-workflows|
7. Extending |codecompanion-extending|
- Extending with Adapters |codecompanion-extending-extending-with-adapters|
- Extending with Agentic Workflows|codecompanion-extending-extending-with-agentic-workflows|
- Extending with Extensions|codecompanion-extending-extending-with-extensions|
- Extending with Rules Parsers|codecompanion-extending-extending-with-rules-parsers|
- Extending with Tools |codecompanion-extending-extending-with-tools|
- Extending the UI |codecompanion-extending-extending-the-ui|
==============================================================================
1. Welcome *codecompanion-welcome*
AI Coding, Vim Style
CodeCompanion is a Neovim plugin which enables you to code with AI, using LLMs
and agents, in Neovim.
FEATURES *codecompanion-welcome-features*
- Copilot Chat <https://github.com/features/copilot> meets Zed AI <https://zed.dev/blog/zed-ai>, in Neovim
- Support for LLMs from Anthropic, Copilot, GitHub Models, DeepSeek, Gemini, Mistral AI, Novita, Ollama, OpenAI, Azure OpenAI, HuggingFace and xAI out of the box (or bring your own!)
- Support for Agent Client Protocol <https://agentclientprotocol.com/overview/introduction>, enabling coding with agents like Augment Code <https://docs.augmentcode.com/cli/overview>, Cagent <https://github.com/docker/cagent> from Docker, Claude Code <https://docs.anthropic.com/en/docs/claude-code/overview>, Codex <https://openai.com/codex>, Gemini CLI <https://github.com/google-gemini/gemini-cli>, Goose <https://block.github.io/goose/>, Kimi CLI <https://github.com/MoonshotAI/kimi-cli> and OpenCode <https://opencode.ai>
- User contributed and supported |codecompanion-configuration-adapters-http-community-adapters|
- |codecompanion-usage-inline-assistant.html|, code creation and refactoring
- |codecompanion-usage-chat-buffer-variables|, |codecompanion-usage-chat-buffer-slash-commands|, |codecompanion-usage-chat-buffer-tools| and |codecompanion-usage-workflows| to improve LLM output
- Support for |codecompanion-usage-chat-buffer-rules| files like `CLAUDE.md`, `.cursor/rules` and your own custom ones
- Native |codecompanion-usage-chat-buffer-index-super-diff| for tracking agent edits
- Built-in |codecompanion-usage-action-palette.html| for common tasks like advice on LSP errors and code explanations
- Create your own |codecompanion-configuration-prompt-library-creating-prompts|, Variables and Slash Commands
- Have |codecompanion-usage-introduction-quickly-accessing-a-chat-buffer| open at the same time
- Support for |codecompanion-usage-chat-buffer--images-vision| as input
- Async execution for fast performance
OVERVIEW *codecompanion-welcome-overview*
The plugin utilises objects called `interactions`. These are the different ways
that a user can interact with the plugin. The `chat` interaction harnesses a
buffer to allow direct conversation with the LLM. The `inline` interaction
allows for output from the LLM to be written directly into a pre-existing
Neovim buffer.
The plugin allows you to specify adapters for each interaction and also for
each |codecompanion-configuration-prompt-library| entry.
SUPPORTED LLMS AND AGENTS *codecompanion-welcome-supported-llms-and-agents*
CodeCompanion uses |codecompanion-configuration-adapters-http| and
|codecompanion-configuration-adapters-acp| adapters to connect to LLMs and
agents. Out of the box, the plugin supports:
- Anthropic (`anthropic`) - Requires an API key and supports prompt caching <https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching>
- Augment Code (`auggie_cli`) - Requires an API key
- Cagent (`cagent`)
- Claude Code (`claude_code`) - Requires an API key or a Claude Pro subscription
- Codex (`codex`) - Requires an API key
- Copilot (`copilot`) - Requires a token which is created via `:Copilot setup` in Copilot.vim <https://github.com/github/copilot.vim>
- Gemini CLI (`gemini_cli`) - Requires an API key or a Gemini Pro subscription
- GitHub Models (`githubmodels`) - Requires `gh` <https://github.com/cli/cli> to be installed and logged in
- Goose (`goose`) - Requires an API key
- DeepSeek (`deepseek`) - Requires an API key
- Gemini (`gemini`) - Requires an API key
- HuggingFace (`huggingface`) - Requires an API key
- Kimi CLI (`kimi_cli`) - Requires an API key
- Mistral AI (`mistral`) - Requires an API key
- Novita (`novita`) - Requires an API key
- Ollama (`ollama`) - Both local and remotely hosted
- OpenAI (`openai`) - Requires an API key
- opencode (`opencode`) - Requires an API key
- xAI (`xai`) - Requires an API key
In order to add a custom adapter, please refer to the
|codecompanion-extending-adapters| documentation. Also, be sure to check out
the |codecompanion-configuration-adapters-http-community-adapters| section for
user contributed adapters.
==============================================================================
2. Installation *codecompanion-installation*
[!IMPORTANT] To avoid breaking changes, it is recommended to pin the plugin to
a specific release when installing.
REQUIREMENTS *codecompanion-installation-requirements*
- The `curl` library
- Neovim 0.11.0 or greater
- `(Optional)` An API key for your chosen LLM
- `(Optional)` nvim-treesitter <https://github.com/nvim-treesitter/nvim-treesitter> and a `yaml` parser for markdown prompt library items
- `(Optional)` The file <https://man7.org/linux/man-pages/man1/file.1.html> command for detecting image mimetype
- `(Optional)` The ripgrep <https://github.com/BurntSushi/ripgrep> library for the `grep_search` tool
You can run `:checkhealth codecompanion` to verify that all requirements are
met.
INSTALLATION *codecompanion-installation-installation*
The plugin can be installed with the plugin manager of your choice. It is
recommended to pin the plugin to a specific release to avoid breaking changes.
nvim-treesitter <https://github.com/nvim-treesitter/nvim-treesitter> is
required if you plan to use markdown prompts in the
|codecompanion-configuration-prompt-library|, ensuring you have the `yaml`
parser installed.
**Plenary.nvim note:**
As per #377 <https://github.com/olimorris/codecompanion.nvim/issues/377>, if
you pin your plugins to the latest releases, ensure you set plenary.nvim to
follow the master branch
EXTENSIONS *codecompanion-installation-extensions*
CodeCompanion supports extensions that add additional functionality to the
plugin. Below is an example which installs and configures mcphub.nvim
<https://github.com/ravitemer/mcphub.nvim>:
Visit the |codecompanion-extending-extensions| to learn more about available
extensions and how to create your own.
OTHER S *codecompanion-installation-other-s*
CodeCompanion integrates with a number of other plugins to make your AI coding
experience more enjoyable. Below are some common lazy.nvim configurations for
popular plugins:
Use render-markdown.nvim
<https://github.com/MeanderingProgrammer/render-markdown.nvim> or markview.nvim
<https://github.com/OXY2DEV/markview.nvim> to render the markdown in the chat
buffer. Use img-clip.nvim <https://github.com/hakonharnes/img-clip.nvim> to
copy images from your system clipboard into a chat buffer via `:PasteImage`:
COMPLETION *codecompanion-installation-completion*
When in the |codecompanion-usage-chat-buffer-index|, completion can be used to
more easily add |codecompanion-usage-chat-buffer-variables|,
|codecompanion-usage-chat-buffer-slash-commands| and
|codecompanion-usage-chat-buffer-tools|. Out of the box, the plugin supports
completion with both nvim-cmp <https://github.com/hrsh7th/nvim-cmp> and
blink.cmp <https://github.com/Saghen/blink.cmp>. For the latter, on version <=
0.10.0, ensure that you’ve added `codecompanion` as a source:
>lua
sources = {
per_filetype = {
codecompanion = { "codecompanion" },
}
},
<
The plugin also supports |codecompanion-usage-chat-buffer-index-completion| and
coc.nvim <https://github.com/neoclide/coc.nvim>.
HELP *codecompanion-installation-help*
If you’re having trouble installing the plugin, as a first step, run
`:checkhealth codecompanion` to check that plugin is installed correctly. After
that, consider using the minimal.lua
<https://github.com/olimorris/codecompanion.nvim/blob/main/minimal.lua> file to
troubleshoot, running it with `nvim --clean -u minimal.lua`.
==============================================================================
3. Getting Started *codecompanion-getting-started*
[!IMPORTANT] The default adapter in CodeCompanion is GitHub Copilot
<https://docs.github.com/en/copilot/using-github-copilot/copilot-chat/asking-github-copilot-questions-in-your-ide>.
If you have copilot.vim <https://github.com/github/copilot.vim> or copilot.lua
<https://github.com/zbirenbaum/copilot.lua> installed then expect CodeCompanion
to work out of the box.
This guide is intended to help you get up and running with CodeCompanion and
begin your journey of coding with AI in Neovim. It assumes that you have
already installed the plugin. If you haven’t done so, please refer to the
|codecompanion-installation| first.
DOCUMENTATION *codecompanion-getting-started-documentation*
Throughout the documentation you will see examples that are wrapped in a
`require("codecompanion").setup({ })` block. This is purposefully done so that
users can apply them to their own Neovim configuration.
If you’re using lazy.nvim <https://github.com/folke/lazy.nvim>, you can
simply apply the examples that you see in this documentation in the `opts`
table. For example, the following code snippet from these docs:
>lua
require("codecompanion").setup({
interactions = {
chat = {
adapter = "anthropic",
model = "claude-sonnet-4-20250514"
},
},
opts = {
log_level = "DEBUG",
},
})
<
can be used in a `lazy.nvim` configuration like so:
>lua
{
"olimorris/codecompanion.nvim",
dependencies = {
"nvim-lua/plenary.nvim"
},
opts = {
interactions = {
chat = {
adapter = "anthropic",
model = "claude-sonnet-4-20250514"
},
},
-- NOTE: The log_level is in `opts.opts`
opts = {
log_level = "DEBUG",
},
},
},
<
INTERACTIONS *codecompanion-getting-started-interactions*
The plugin uses the notion of `interactions` to describe the many different
ways that you can interact with an LLM from within CodeCompanion. There are
four main types of interactions:
- **Chat** - A chat buffer where you can converse with an LLM (`:CodeCompanionChat`)
- **Inline** - An inline assistant that can write code directly into a buffer (`:CodeCompanion`)
- **Cmd** - Create Neovim commands in the command-line (`:CodeCompanionCmd`)
- **Background** - Runs tasks in the background such as compacting chat messages or generating titles for chats
WITH AN ADAPTER *codecompanion-getting-started-with-an-adapter*
[!NOTE] The adapters that the plugin supports out of the box can be found here
<https://github.com/olimorris/codecompanion.nvim/tree/main/lua/codecompanion/adapters>.
Or, see the user contributed adapters
|codecompanion-configuration-adapters-http-community-adapters|
An adapter is what connects Neovim to an LLM (via `HTTP`) or an agent (via ACP
<https://agentclientprotocol.com/overview/introduction>). It’s the interface
that allows data to be sent, received and processed. In order to use the
plugin, you need to make sure you’ve configured an adapter first:
>lua
require("codecompanion").setup({
interactions = {
chat = {
-- You can specify an adapter by name and model (both ACP and HTTP)
adapter = {
name = "copilot",
model = "gpt-4.1",
},
},
-- Or, just specify the adapter by name
inline = {
adapter = "anthropic",
},
cmd = {
adapter = "openai",
},
background = {
adapter = {
name = "ollama",
model = "qwen-7b-instruct",
},
},
},
})
<
In the example above, we’re using the Copilot adapter for the chat
interaction and the Anthropic one for the inline. We’re also using something
cheap for the background adapter (although these interactions are opt-in). You
can mix and match adapters as you see fit for your workflow.
[!IMPORTANT] |codecompanion-configuration-adapters-acp| are only supported for
the chat interaction.
There are two "types" of adapter in CodeCompanion;
|codecompanion-configuration-adapters-http| adapters which connect you to an
LLM and |codecompanion-configuration-adapters-acp| adapters which leverage the
Agent Client Protocol <https://agentclientprotocol.com> to connect you to an
agent.
Refer to the respective sections to understand more about working with adapters
that enable agents like
|codecompanion-configuration-adapters-acp-setup-claude-code|.
SETTING AN API KEY ~
Because most LLMs require an API key, you’ll need to share that with the
adapter. By default, adapters will look in your environment for a `*_API_KEY`
where `*` is the name of the adapter such as `ANTHROPIC` or `OPENAI`. Refer to
the documentation of the LLM or agent you’re using to find out what the
environment variable is called.
You can extend an adapter and change the API key like so:
>lua
require("codecompanion").setup({
adapters = {
http = {
anthropic = function()
return require("codecompanion.adapters").extend("anthropic", {
env = {
api_key = "MY_OTHER_ANTHROPIC_KEY",
},
})
end,
},
},
})
<
There are numerous ways that environment variables can be set for adapters.
Refer to the |codecompanion-configuration-adapters-http-environment-variables|
section for more information.
CHAT BUFFER *codecompanion-getting-started-chat-buffer*
The Chat Buffer is where you can converse with an LLM from within Neovim. It
operates on a single response per turn, basis. Once your adapter has been
configured, you can start using the chat buffer and begin interacting with an
LLM.
Run `:CodeCompanionChat` to open a chat buffer. Type your prompt and send it by
pressing `<C-s>` while in insert mode or `<CR>` in normal mode. Alternatively,
run `:CodeCompanionChat why are Lua and Neovim so perfect together?` to open
the chat buffer and send a prompt at the same time. Toggle the chat buffer with
`:CodeCompanionChat Toggle`.
You can add context from your code base by using `Variables` and `Slash
Commands` in the chat buffer.
VARIABLES ~
`Variables`, accessed via `#`, contain data about the present state of Neovim.
You can find a list of available variables,
|codecompanion-usage-chat-buffer-variables.html|. The buffer variable will
automatically link a buffer to the chat buffer, by default, updating the LLM
when the buffer changes.
[!TIP] Use them in your prompt like: `What does the code in #{buffer} do?`
SLASH COMMANDS ~
[!IMPORTANT] These have been designed to work with native Neovim completions
alongside nvim-cmp and blink.cmp. To open the native completion menu use
`<C-_>` in insert mode when in the chat buffer. Note: Slash commands should
also work with coc.nvim.
`Slash commands`, accessed via `/`, run commands to insert additional context
into the chat buffer. You can find a list of available commands as well as how
to use them, |codecompanion-usage-chat-buffer-slash-commands.html|.
TOOLS ~
`Tools`, accessed via `@`, allow the LLM to function as an agent and leverage
external tools. You can find a list of available tools as well as how to use
them, |codecompanion-usage-chat-buffer-tools.html-available-tools|.
[!TIP] Use them in your prompt like:
`Can you use @{grep_search} to find occurrences of "hello world"`
INLINE ASSISTANT *codecompanion-getting-started-inline-assistant*
[!NOTE] The diff provider in the video is mini.diff
<https://github.com/echasnovski/mini.diff>
The inline assistant enables an LLM to write code directly into a Neovim
buffer.
Run `:CodeCompanion your prompt` to call the inline assistant. The assistant
will evaluate the prompt and either write code or open a chat buffer. You can
also make a visual selection and call the assistant. To send additional context
alongside your prompt, you can leverage
|codecompanion-usage-inline-assistant-variables| such as `:CodeCompanion
#{buffer} <your prompt>`.
For convenience, you can call prompts with their `alias` from the prompt
library
<https://github.com/olimorris/codecompanion.nvim/blob/6a4341a4cfe8988a57ad9e8b7dc01ccd6f3e1628/lua/codecompanion/config.lua#L565>
such as `:'<,'>CodeCompanion /explain`. The prompt library comes with the
following presets:
- `/commit` - Generate a commit message
- `/explain` - Explain how selected code in a buffer works
- `/fix` - Fix the selected code
- `/lsp` - Explain the LSP diagnostics for the selected code
- `/tests` - Generate unit tests for selected code
COMMANDS *codecompanion-getting-started-commands*
Use CodeCompanion to create Neovim commands in command-line mode
(|Command-line|) via `:CodeCompanionCmd <your prompt>`.
ACTION PALETTE *codecompanion-getting-started-action-palette*
Run `:CodeCompanionActions` to open the action palette, which gives you access
to the plugin’s features, including your prompts from the
|codecompanion-configuration-prompt-library|.
By default the plugin uses `vim.ui.select`, however, you can change the
provider by altering the `display.action_palette.provider` config value to be
`telescope`, `mini_pick` or `snacks`. You can also call the Telescope extension
with `:Telescope codecompanion`.
[!NOTE] Some actions and prompts will only be visible if you’re in `Visual
mode`.
LIST OF COMMANDS *codecompanion-getting-started-list-of-commands*
The plugin has four core commands:
- `CodeCompanion` - Open the inline assistant
- `CodeCompanionChat` - Open a chat buffer
- `CodeCompanionCmd` - Generate a command in the command-line
- `CodeCompanionActions` - Open the `Action Palette`
However, there are multiple options available:
- `CodeCompanion <prompt>` - Prompt the inline assistant
- `CodeCompanion adapter=<adapter> <prompt>` - Prompt the inline assistant with a specific adapter
- `CodeCompanion /<prompt library>` - Call an item via its alias from the |codecompanion-configuration-prompt-library|
- `CodeCompanionChat <prompt>` - Send a prompt to the LLM via a chat buffer
- `CodeCompanionChat adapter=<adapter> model=<model>` - Open a chat buffer with a specific http adapter and model
- `CodeCompanionChat adapter=<adapter> command=<command>` - Open a chat buffer with a specific ACP adapter and command
- `CodeCompanionChat Add` - Add visually selected chat to the current chat buffer
- `CodeCompanionChat RefreshCache` - Used to refresh conditional elements in the chat buffer
- `CodeCompanionChat Toggle` - Toggle a chat buffer
SUGGESTED WORKFLOW *codecompanion-getting-started-suggested-workflow*
For an optimum plugin workflow, I recommend the following:
>lua
vim.keymap.set({ "n", "v" }, "<C-a>", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "<LocalLeader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true })
vim.keymap.set("v", "ga", "<cmd>CodeCompanionChat Add<cr>", { noremap = true, silent = true })
-- Expand 'cc' into 'CodeCompanion' in the command line
vim.cmd([[cab cc CodeCompanion]])
<
[!NOTE] You can also assign prompts from the library to specific mappings. See
the |codecompanion-configuration-prompt-library-assigning-prompts-to-a-keymap|
section for more information.
==============================================================================
4. Upgrading General *codecompanion-upgrading-general*
This document provides a guide for upgrading from one version of CodeCompanion
to another.
CodeCompanion follows semantic versioning <https://semver.org/> and to avoid
breaking changes, it is recommended to pin the plugin to a specific version in
your Neovim configuration. The |codecompanion-installation| provides more
information on how to do this.
V17.33.0 TO V18.0.0 *codecompanion-upgrading-general-v17.33.0-to-v18.0.0*
CONFIG ~
- The biggest change in this release is the renaming of `strategies` to `interactions`. This will only be a breaking change if you specifically reference `codecompanion.strategies` in your configuration. If you do, you’ll need to change it to `codecompanion.interactions` (#2485 <https://github.com/olimorris/codecompanion.nvim/pull/2485>)
- Previously, built-in slash commands and tools were stored in `/catalog` folders which have now been renamed to `/builtin`. If you reference these in your configuration you’ll need to update the paths accordingly (#2482 <https://github.com/olimorris/codecompanion.nvim/pull/2482>)
- Workspaces have now been removed from the plugin. Please use |codecompanion-configuration-rules| instead.
ADAPTERS ~
- If you have a custom adapter, you’ll need to rename `condition` to be `enabled` on any schema items (#2439 <https://github.com/olimorris/codecompanion.nvim/pull/2439/commits/cb14c7bac869346e2d12b775c4bf258606add569>):
>lua
return {
schema = {
["reasoning.effort"] = {
---@type fun(self: CodeCompanion.HTTPAdapter): boolean
condition = function(self) -- [!code --]
enabled = function(self) -- [!code ++]
--
end,
},
}
}
<
- The default adapters on the **Anthropic** and **Gemini** adapters have changed to `claude-sonnet-4-5-20250929` and `gemini-3-pro-preview`, respectively (#2494 <https://github.com/olimorris/codecompanion.nvim/pull/2494>)
- If you wish to hide the adapters that come with CodeCompanion, `adapter.[acp|http].opts.show_defaults` has been renamed to `adapter.[acp|http].opts.show_presets` for both HTTP and ACP adapters (#2497 <https://github.com/olimorris/codecompanion.nvim/pull/2497>)
CHAT ~
- Memory has been renamed to rules. Please rename any references to `memory` in your configuration to `rules`. Please refer to the |codecompanion-configuration-rules| documentation for more information (#2440 <https://github.com/olimorris/codecompanion.nvim/pull/2440>)
- DEFAULT_MEMORY HAS BEEN RENAMED TO AUTOLOAD (#2509)*codecompanion-upgrading-general-default_memory-has-been-renamed-to-autoload-(#2509)*
- The variable and parameter `#{buffer}{watch}` has been renamed to `#{buffer}{diff}`. This better reflects that an LLM receives a diff of buffer changes with each request (#2444 <https://github.com/olimorris/codecompanion.nvim/pull/2444>)
- The variable and parameter `#{buffer}{pin}` has now been renamed to `#{buffer}{all}`. This better reflects that the
entire buffer is sent to the LLM with each request (#2444 <https://github.com/olimorris/codecompanion.nvim/pull/2444>)
—
- Passing an adapter as an argument to `:CodeCompanionChat` is now done with `:CodeCompanionChat adapter=<adapter_name>` (#2437 <https://github.com/olimorris/codecompanion.nvim/pull/2437>)
- If your chat buffer system prompt is still stored at `opts.system_prompt` you’ll need to change it to `interactions.chat.opts.system_prompt` (#2484 <https://github.com/olimorris/codecompanion.nvim/pull/2484>)
PROMPT LIBRARY ~
If you have any prompts defined in your config, you’ll need to:
- Rename `opts.short_name` to `opts.alias` for each item in order to allow you to call them with `require("codecompanion").prompt("my_prompt")` or as slash commands in the chat buffer (#2471 <https://github.com/olimorris/codecompanion.nvim/pull/2471>).
>lua
["my custom prompt"] = {
strategy = "chat",
description = "My custom prompt",
opts = {
short_name = "my_prompt", -- [!code --]
alias = "my_prompt", -- [!code ++]
},
prompts = {
-- ...
},
},
<
- Change all workflow prompts, replacing `strategy = "workflow"` with `interaction = "chat"` and specifying `opts.is_workflow = true` (#2487 <https://github.com/olimorris/codecompanion.nvim/pull/2487>).
>lua
["my_workflow"] = {
strategy = "workflow", -- [!code --]
interaction = "chat", -- [!code ++]
description = "My custom workflow",
opts = {
is_workflow = true, -- [!code ++]
},
prompts = {
-- ...
},
},
<
- If you don’t wish to display any of the built-in prompt library items, you’ll need to change `display.action_palette.show_default_prompt_library` to `display.action_palette.show_preset_prompts` (#2499 <https://github.com/olimorris/codecompanion.nvim/pull/2499>)
TOOLS ~
If you have any tools in your config, you’ll need to rename:
- `requires_approval` to `require_approval_before` (#2439 <https://github.com/olimorris/codecompanion.nvim/pull/2439/commits/cb14c7bac869346e2d12b775c4bf258606add569>)
- `user_confirmation` to `require_confirmation_after` (#2450 <https://github.com/olimorris/codecompanion.nvim/pull/2450>)
These now better reflect the timing of each action.
UI ~
- The `display.chat.child_window` has been renamed `display.chat.floating_window` to better describe what it is (#2452 <https://github.com/olimorris/codecompanion.nvim/pull/2452>)
- The `display.action_palette.opts.show_default_actions` has been renamed to be `display.action_palette.opts.show_preset_actions` (#2499 <https://github.com/olimorris/codecompanion.nvim/pull/2499>)
==============================================================================
5. Configuration *codecompanion-configuration*
ACTION PALETTE *codecompanion-configuration-action-palette*
The Action Palette holds plugin specific items like the ability to launch a
chat buffer and the currently open chat buffers alongside displaying the
prompts from the |codecompanion-prompt-library|.
LAYOUT ~
[!NOTE] The Action Palette also supports Telescope.nvim
<https://github.com/nvim-telescope/telescope.nvim>, fzf_lua
<https://github.com/ibhagwan/fzf-lua>, mini.pick
<https://github.com/echasnovski/mini.pick> and snacks.nvim
<https://github.com/folke/snacks.nvim>
You can change the appearance of the chat buffer by changing the
`display.action_palette` table in your configuration:
>lua
require("codecompanion").setup({
display = {
action_palette = {
width = 95,
height = 10,
prompt = "Prompt ", -- Prompt used for interactive LLM calls
provider = "default", -- Can be "default", "telescope", "fzf_lua", "mini_pick" or "snacks". If not specified, the plugin will autodetect installed providers.
opts = {
show_preset_actions = true, -- Show the preset actions in the action palette?
show_preset_prompts = true, -- Show the preset prompts in the action palette?
title = "CodeCompanion actions", -- The title of the action palette
},
},
},
}),
<
ACP ADAPTERS *codecompanion-configuration-acp-adapters*
This section contains configuration which is specific to Agent Client Protocol
(ACP) adapters only. There is a lot of shared functionality between ACP and
|codecompanion-configuration-adapters-http| adapters. Therefore it’s
recommended you read the two pages together.
CHANGING THE DEFAULT ADAPTER ~
You can select an ACP adapter to be the default for all chat interactions:
>lua
require("codecompanion").setup({
interactions = {
chat = {
adapter = "gemini_cli",
},
},
}),
<
CHANGING THE DEFAULT MODEL ~
You can change the default model used by an ACP adapter. For example, to change
the default model for the Claude Code adapter:
Using a `function` is useful for working around the limitations
<https://github.com/zed-industries/claude-code-acp/issues/225> in the Claude
Code SDK (which enables ACP support).
CHANGING ADAPTER SETTINGS ~
To change any of the default settings for an ACP adapter, you can extend it in
your CodeCompanion setup. For example, to change the timeout and authentication
method for the Gemini CLI adapter, you can do the following:
>lua
require("codecompanion").setup({
adapters = {
acp = {
gemini_cli = function()
return require("codecompanion.adapters").extend("gemini_cli", {
commands = {
default = {
"some-other-gemini"
"--experimental-acp",
},
},
defaults = {
auth_method = "gemini-api-key",
timeout = 20000, -- 20 seconds
},
env = {
GEMINI_API_KEY = "GEMINI_API_KEY",
},
})
end,
},
},
})
<
HIDING PRESET ADAPTERS ~
By default, the plugin shows all available adapters, including the presets. If
you prefer to only display the adapters defined in your user configuration, you
can set the `show_presets` option to `false`:
>lua
require("codecompanion").setup({
adapters = {
acp = {
opts = {
show_presets = false,
},
},
},
})
<
SETUP: AUGGIE CLI FROM AUGMENT CODE ~
To use Auggie CLI <https://docs.augmentcode.com/cli/overview> within
CodeCompanion, you simply need to follow their Getting Started
<https://docs.augmentcode.com/cli/overview#getting-started> guide.
SETUP: CAGENT ~
To use Docker’s Cagent <https://github.com/docker/cagent> within
CodeCompanion, you need to follow these steps:
1. Install <https://github.com/docker/cagent?tab=readme-ov-file#installation> Cagent as per their instructions
2. Create an agent <https://github.com/docker/cagent?tab=readme-ov-file#run-agents> in the repository you’re working from
3. Test the agent by running `cagent run your_agent.yaml` in the CLI
4. In your CodeCompanion config, extend the `cagent` adapter to include the agent:
>lua
require("codecompanion").setup({
adapters = {
acp = {
cagent = function()
return require("codecompanion.adapters").extend("cagent", {
commands = {
default = {
"cagent",
"acp",
"your_agent.yaml",
},
},
})
end,
},
},
})
<
If you have multiple agent files that you like to run separately, you can
create multiple commands for each agent.
SETUP: CLAUDE CODE ~
To use Claude Code <https://www.anthropic.com/claude-code> within
CodeCompanion, you’ll need to take the following steps:
1. Install <https://docs.anthropic.com/en/docs/claude-code/quickstart#step-1%3A-install-claude-code> Claude Code
2. Install <https://github.com/zed-industries/claude-code-acp> the Zed ACP adapter for Claude Code
CLAUDE PRO SUBSCRIPTION
1. In your CLI, run `claude setup-token`. You’ll be redirected to the Claude.ai website for authorization:
2. Back in your CLI, copy the OAuth token (in yellow):
3. In your CodeCompanion config, extend the `claude_code` adapter and include the OAuth token (see the section on |codecompanion-configuration-adapters-http-environment-variables-setting-an-api-key| for other ways to do this):
>lua
require("codecompanion").setup({
adapters = {
acp = {
claude_code = function()
return require("codecompanion.adapters").extend("claude_code", {
env = {
CLAUDE_CODE_OAUTH_TOKEN = "my-oauth-token",
},
})
end,
},
},
})
<
AN API KEY
1. Create <https://console.anthropic.com/settings/keys> an API key in your Anthropic console.
2. In your CodeCompanion config, extend the `claude_code` adapter and set the `ANTHROPIC_API_KEY`:
>lua
require("codecompanion").setup({
adapters = {
acp = {
claude_code = function()
return require("codecompanion.adapters").extend("claude_code", {
env = {
ANTHROPIC_API_KEY = "my-api-key",
},
})
end,
},
},
})
<
SETUP: CODEX ~
To use OpenAI’s Codex <https://openai.com/codex/>, install an ACP-compatible
adapter like this <https://github.com/zed-industries/codex-acp> one from Zed
<https://zed.dev>.
By default, the adapter will look for an `OPENAI_API_KEY` in your shell,
however you can also authenticate via ChatGPT. This can be customized in the
plugin configuration:
>lua
require("codecompanion").setup({
adapters = {
acp = {
codex = function()
return require("codecompanion.adapters").extend("codex", {
defaults = {
auth_method = "openai-api-key", -- "openai-api-key"|"codex-api-key"|"chatgpt"
},
env = {
OPENAI_API_KEY = "my-api-key",
},
})
end,
},
},
})
<
SETUP: GEMINI CLI ~
1. Install Gemini CLI <https://github.com/google-gemini/gemini-cli>
2. Update your CodeCompanion config and select which authentication methods you’d like to use. Currently there are:- `oauth-personal` which uses your Google login
- `gemini-api-key`
- `vertex-ai`)
The example below uses the `gemini-api-key` method, pulling the API key from
1Password CLI <https://developer.1password.com/docs/cli/get-started/>:
>lua
require("codecompanion").setup({
adapters = {
acp = {
gemini_cli = function()
return require("codecompanion.adapters").extend("gemini_cli", {
defaults = {
auth_method = "gemini-api-key", -- "oauth-personal"|"gemini-api-key"|"vertex-ai"
},
env = {
GEMINI_API_KEY = "cmd:op read op://personal/Gemini_API/credential --no-newline",
},
})
end,
},
},
})
<
SETUP: GOOSE CLI ~
To use Goose <https://block.github.io/goose/> in CodeCompanion, ensure you’ve
followed their documentation
<https://block.github.io/goose/docs/getting-started/installation/> to setup and
install Goose CLI. Then ensure that in your chat buffer you select the `goose`
adapter.
SETUP: KIMI CLI ~
Install Kimi CLI
<https://github.com/MoonshotAI/kimi-cli?tab=readme-ov-file#installation> as per
their instructions. Then in the CLI, run `kimi` followed by `/setup` to
configure your API key. Then ensure that in your chat buffer you select the
`kimi_cli` adapter.
SETUP: OPENCODE ~
To use OpenCode <https://opencode.ai> in CodeCompanion, ensure you’ve
followed their documentation to install <https://opencode.ai/docs/#install> and
configure <https://opencode.ai/docs/#configure> it. Then ensure that in your
chat buffer you select the `opencode` adapter.
You can specify a custom model in your `~/.config/opencode/config.json` file:
>json
{
"$schema": "https://opencode.ai/config.json",
"model": "github-copilot/claude-sonnet-4.5",
}
<
HTTP ADAPTERS *codecompanion-configuration-http-adapters*
[!TIP] Want to connect to an LLM that isn’t supported out of the box? Check
out |codecompanion--community-adapters| user contributed adapters,
|codecompanion-extending-adapters.html| your own or post in the discussions
<https://github.com/olimorris/codecompanion.nvim/discussions>
An adapter is what connects Neovim to an LLM provider and model. It’s the
interface that allows data to be sent, received and processed. There are a
multitude of ways to customize them.
There are two "types" of adapter in CodeCompanion; **http** adapters which
connect you to an LLM and |codecompanion-configuration-adapters-acp| adapters
which leverage the Agent Client Protocol <https://agentclientprotocol.com> to
connect you to an agent.
The configuration for both types of adapters is exactly the same, however they
sit within their own tables (`adapters.http.*` and `adapters.acp.*`) and have
different options available. HTTP adapters use `models` to allow users to
select the specific LLM they’d like to interact with. ACP adapters use
`commands` to allow users to customize their interaction with agents (e.g.�
enabling `yolo` mode). As there is a lot of shared functionality between the
two adapters, it is recommend that you read this page alongside the ACP one.
CHANGING THE DEFAULT ADAPTER ~
You can change the default adapter for each interaction as follows:
>lua
require("codecompanion").setup({
interactions = {
chat = {
adapter = "anthropic",
},
inline = {
adapter = "copilot",
},