Skip to content

Conversation

@danhorner
Copy link

Thanks for this great plugin. I want to keep my costs down and also prevent any private information from being shared with claude. Here are two commits that add the ability to select which buffers are uploaded to claude:

  1. Adds commands ClaudeOnlySendMarkedBuffers to enable this mode and and ClaudeMarkBuffer to mark a buffer. Also ClaudeShowMarkedBuffers which lists the buffer numbers.
  2. Adds UI to the top of the claude chat window that shows which buffers will be sent.
image

When g:claude_only_send_marked_buffers is set, send only buffers that have been
previously marked. Any buffers that claude creates are automatically
marked.

  Commands:
    :ClaudeMarkBuffer - Mark this buffer for sending
    :ClaudeToggleSendBuffer - Switch between sending marked buffers and
      sending all visible buffers
    :ClaudeShowMarkedbuffers - List the buffer numbers of marked buffers

  Helpers:
    Review which buffers are marked using
  - The status region lists buffers that will be sent to claude
  - Status region updates when cursor moves to a new window, which handles
    events that would change the list
@danhorner
Copy link
Author

@pasky in #18 :

The ability to use Claude to code claude.vim would be one thing I'd be concerned about. Can we figure out how to preserve it (without having to have 10 windows open :)

Small plug for this PR, which lets you select offscreen buffers and share them in the context :) If you have feedback I'm happy to revise it.

@pasky
Copy link
Owner

pasky commented Dec 5, 2024

Sorry I missed this!

I certainly like the general idea. However, I think it would be more natural to actually control the buffers being sent by editing the Claude Chat buffer? That's how all other lines in the buffer work, they actually fully control the state, and this would be an exception. (I'm not sure if we can hook to new window / close window events to adjust the list dynamically...)

(Can you also make sure you use consistent formatting? Spaces around operators, sw=2.)

@danhorner
Copy link
Author

Great idea. Could definitely parse the status region for buffers, automatically removing them when buffer is closed. Possibly with two settings selecting buffers: :ClaudeSendVisibleBuffers and :ClaudeSendMarkedBuffers

Also, new to vimscript. I'll tidy the formatting. Is there a linter you recommend?

  - Per PR feedback, ClaudeMarkBuffer keeps is state in the bulleted list in the chat window.
  - You can manually add/delete lines to this list. Valid lines start with
    two spaces a dash, and a buffer number
  - Autocommand deletes entries for buffers that are deleted
  - Autocommand cleans up when claude window is deleted
  - Tab handling: By default claude.vim will send buffers open in any tab
    where the Claude Chat window is open
@danhorner
Copy link
Author

danhorner commented Jan 5, 2025

I took some time to incorporate your feedback. This new version keeps its state in the Claude Window and fixes formatting. In addition to the provided ClaudeMarkBuffer command, you can mark/unmark buffers by simply typing them into the list.

Edit buffer list in Claude Chat
image

After switching to a new window
image

Aside: I added logging and some Vader tests on a private branch. They are not included here but I'm happy to contribute them if you think useful.

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.

2 participants