Skip to content

Conversation

@pratyushmittal
Copy link
Contributor

Description

This PR adds a CodeCompanionComplete command to trigger a code completion on demand.

Though I added it as a test POC (proof-of-concept), I ended us using it extensively.

I use it with this setting in my init.lua:

vim.keymap.set({ 'i' }, '<C-f>', '<cmd>CodeCompanionComplete<cr>', { noremap = true, silent = true, desc = 'Complete [F]orward' })

The above triggers a tab-style code completion on pressing Ctrl+f in insert mode. No need to pass any chat instructions. Usually the comments and context around the cursor is sufficient to provide a good completion.

Screenshots

CodeCompanionComplete.mp4

Checklist

  • I've read the contributing guidelines and have adhered to them in this PR
  • I've updated CodeCompanion.has in the init.lua file for my new feature
  • I've added test coverage for this fix/feature
  • I've updated the README and/or relevant docs pages
  • I've run make all to ensure docs are generated, tests pass and my formatting is applied

@pratyushmittal
Copy link
Contributor Author

pratyushmittal commented Aug 14, 2025

@olimorris I am not sure if this fits within the scope of the library. I personally have been finding this feature very useful.

The current PR is a draft. I can work on improving it if you too find it useful.

Improvements to make:

  • Add some visual feedback to show when loading a autocomplete.
  • Try to use list_code_usages tool along with for even better suggestions.

self:start_diff()
pcall(vim.cmd.undojoin)
self:output(json.code)
-- After auto-applying inline edits (e.g., no_diff), move cursor to end of insertion
Copy link
Owner

Choose a reason for hiding this comment

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

This is a very nice QOL feature!

@olimorris
Copy link
Owner

olimorris commented Aug 14, 2025

Hey @pratyushmittal

I am not sure if this fits within the scope of the library

It definitely does and would be an awesome addition. I'm not sure I'd want to have this as a separate command though. As this utilizes the inline assistant, I think it would make sense for it to be :CodeCompanion complete. This is because the current "main" commands all map to strategies i.e. :CodeCompanionChat and :CodeCompanionCmd. It could always be its own context variable :CodeCompanion #{complete} (like we have this for #{buffer} and #{chat} right now). This would keep it nicely structured and contained but appreciate its doing something a bit more than just sharing context so isn't that intuitive to a user.

Bottom line, totally want this in CodeCompanion just need to workout what the UX would be.

Add some visual feedback to show when loading a autocomplete.

I wouldn't want this directly in CodeCompanion but we could fire some events with the buffer number, line numbers etc so users could hook into that themselves. I will always endeavour for CodeCompanion to not force anything on a user from a UI perspective beyond what happens in the chat buffer.

Try to use list_code_usages tool along with for even better suggestions.

This would be so good and so powerful, but I suspect this could be quite complicated to achieve. How are you envisioning this would work?

@github-actions
Copy link
Contributor

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the Stale label Oct 14, 2025
@github-actions github-actions bot removed the Stale label Nov 19, 2025
@github-actions
Copy link
Contributor

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the Stale label Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants