Skip to content

assistant/codecompanion-nvim: add mappings - #740

Open
Sc3l3t0n wants to merge 1 commit into
NotAShelf:mainfrom
Sc3l3t0n:feature/mappings-for-codecompanion
Open

assistant/codecompanion-nvim: add mappings#740
Sc3l3t0n wants to merge 1 commit into
NotAShelf:mainfrom
Sc3l3t0n:feature/mappings-for-codecompanion

Conversation

@Sc3l3t0n

Copy link
Copy Markdown
Contributor

I tried out the codecompanion-nvim plugin and noticed, there were no mappings available, so I mapped some common commands of the plugin.

Maybe @ArmandoCIII could take a look too.

Sanity Checking

  • I have updated the changelog as per my changes (I'm not sure if I should, because the plugin is new in this release)
  • I have tested, and self-reviewed my code
  • My changes fit guidelines found in hacking nvf
  • Style and consistency
    • I ran Alejandra to format my code (nix fmt)
    • My code conforms to the editorconfig configuration of the project
    • My changes are consistent with the rest of the codebase
  • If new changes are particularly complex:
    • My code includes comments in particularly complex areas
    • I have added a section in the manual
    • (For breaking changes) I have included a migration guide
  • Package(s) built:
    • .#nix (default package)
    • .#maximal
    • .#docs-html (manual, must build)
    • .#docs-linkcheck (optional, please build if adding links)
  • Tested on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin

Add a 👍 reaction to pull requests you find important.

Add mappings for common commands in codecompanion-nvim
@Sc3l3t0n
Sc3l3t0n requested a review from NotAShelf as a code owner March 24, 2025 16:45
github-actions Bot pushed a commit that referenced this pull request Mar 24, 2025
@github-actions

Copy link
Copy Markdown

🚀 Live preview deployed from df1b3f7

View it here:

Debug Information

Triggered by: Sc3l3t0n

HEAD at: feature/mappings-for-codecompanion

Reruns: 480

inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding mkSetLuaBinding;

self = import ./codecompanion-nvim.nix {inherit lib;};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't do this, this is leftover code that we haven't refactored yet. you can get the options definition from the "top-level" function args (see above)

@@ -3,9 +3,21 @@
lib,
...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...
options,
...

then you can access the mappings option as options.vim.assistant.codecompanion-nvim.mappings

see run-nvim for a full example

@horriblename

Copy link
Copy Markdown
Collaborator

@NotAShelf what's the current policy regarding default keymaps? are we still adding them or?

@NotAShelf

Copy link
Copy Markdown
Owner

@NotAShelf what's the current policy regarding default keymaps? are we still adding them or?

I am still not very keen on adding more, but I also don't want to discourage anyone from contributing. Since we're going to add a toggle in the future, I think they are okay... for now.

@TafkaMax

Copy link
Copy Markdown

Hi, what is the status of these mappings PR? I would like to use them.

@TafkaMax

TafkaMax commented Dec 11, 2025

Copy link
Copy Markdown

For whomever it may concern I converted the mappings to vim.keymaps, until these mappings might come into the main branch.

**NB! I change one mapping key.

{
  key = "<leader>aa";
  mode = ["n" "v"];
  silent = true;
  action = "<cmd>CodeCompanion<CR>";
  desc = "[CodeCompanion] Open inline Assistant";
}
{
  key = "<leader>ao";
  mode = ["n" "v"];
  silent = true;
  action = "<cmd>CodeCompanionChat<CR>";
  desc = "[CodeCompanion] Open chat";
}
{
  key = "<leader>at";
  mode = ["n" "v"];
  silent = true;
  action = "<cmd>CodeCompanionChat Toggle<CR>";
  desc = "[CodeCompanion] Toggle chat";
}
{
  key = "<C-a>";
  mode = ["n" "v"];
  silent = true;
  action = "<cmd>CodeCompanionActions<CR>";
  desc = "[CodeCompanion] Open actions";
}
{
  key = "<leader>ag";
  mode = ["n" "v"];
  silent = true;
  action = "function() vim.fn.feedkeys(\":CodeCompanionCmd \") end";
  lua = true;
  desc = "[CodeCompanion] Open cli command generation prompt";
}
{
  key = "<leader>ab";
  mode = ["v"];
  silent = true;
  action = "<leader>ab";
  desc = "[CodeCompanion] Add selection chat";
}

@Sc3l3t0n

Copy link
Copy Markdown
Contributor Author

Hi, I totally forgot about this one.

When I created this PR, I didn’t realize that these could be set up easily on your own.
Additionally, I’m no longer using the plugin, so I think we can just close this one, right? @NotAShelfd

@TafkaMax

Copy link
Copy Markdown

Well I got the mappings and commands from here. So it would be a good idea to either document these for easy visibility or add them as defaults imho.

@Sc3l3t0n

Sc3l3t0n commented Jan 1, 2026

Copy link
Copy Markdown
Contributor Author

I see your point. Maybe there is a way to make these key bindings discoverable through the options search without assigning them default values.

That said, this could still introduce some maintenance overhead if the plugin changes over time. Maybe it’s reasonable to expect users to check the plugin themselves to see which commands are available.

@snoweuph

snoweuph commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator

@NotAShelf what's the current policy regarding default keymaps? are we still adding them or?

I am still not very keen on adding more, but I also don't want to discourage anyone from contributing. Since we're going to add a toggle in the future, I think they are okay... for now.

There should prolly be a pinned Issue about keymappings, also encouring the usage of vim.keymaps over *.mappings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants