Skip to content

Merge 0.3.0 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,50 @@ A proof of concept integration between Claude Desktop and Neovim using Model Con
### Resources

- `nvim://session`: Current neovim text editor session
- `nvim://buffers`: List of all open buffers in the current Neovim session with metadata including modified status, syntax, and window IDs

### Tools
- **vim_buffer**
- Current VIM text editor buffer with line numbers shown
- Input `filename` (string)
- Filename is ignored, returns a string of numbered lines with the current active buffer content
- **vim_command**
- Send a command to VIM for navigation, spot editing, and line deletion.
- Send a command to VIM for navigation, spot editing, and line deletion
- Input `command` (string)
- Runs a vim command first passed through `nvim.replaceTermcodes`. Multiple commands will work if separated by newlines.
- Runs a vim command first passed through `nvim.replaceTermcodes`. Multiple commands will work if separated by newlines
- On error, `'nvim:errmsg'` contents are returned
- **vim_status**
- Get the status of the VIM editor
- Status contains line, col, mode, filename, and visual selection
- Status contains cursor position, mode, filename, visual selection, window layout, current tab, marks, registers, and working directory
- **vim_edit**
- Edit lines using insert or replace in the VIM editor.
- Edit lines using insert or replace in the VIM editor
- Input `startLine` (number), `mode` (`"insert"` | `"replace"`), `lines` (string)
- insert will insert lines at startLine. replace will replace lines starting at the startLine to the end of the buffer.
- insert will insert lines at startLine. replace will replace lines starting at the startLine to the end of the buffer
- **vim_window**
- Manipulate Neovim windows (split, vsplit, close, navigate)
- Input `command` (string: "split", "vsplit", "only", "close", "wincmd h/j/k/l")
- Allows window management operations
- **vim_mark**
- Set a mark at a specific position
- Input `mark` (string: a-z), `line` (number), `column` (number)
- Sets named marks at specified positions
- **vim_register**
- Set content of a register
- Input `register` (string: a-z or "), `content` (string)
- Manages register contents
- **vim_visual**
- Make a visual selection
- Input `startLine` (number), `startColumn` (number), `endLine` (number), `endColumn` (number)
- Creates visual mode selections

Using this simple set of tools, Claude can peer into your neovim session to answer questions as well as make edits to the buffer.

## Limitations

- This is a quick proof of concept to experiment with Model Context Protocol. Use at your own risk.
- May not interact well with a custom neovim config!
- It may or may not be properly handling the socket connections to neovim.
- Error handling could be better.
- Sometimes Claude doesn't get the vim command input just right or the way I am passing it along doesn't agree.
- Reading the output from a vim command needs improvement.
- Support for multiple buffers/windows.
- Sometimes Claude doesn't get the vim command input just right.

## Usage with Claude Desktop
Add this to your `claude_desktop_config.json`:
Expand Down
Loading