Skip to content

Conversation

@williamjameshandley
Copy link
Owner

Summary

This is a major rewrite of vimteractive introducing dual backend support and enhanced AI assistant integration.

Key Features

  • Dual Backend Support: Choose between tmux (external terminals) and vim's native terminal
  • Enhanced AI Integration: Built-in support for sgpt, gpt-command-line, and aichat with response retrieval
  • Robust Command Handling: Commands defined as lists for proper argument escaping
  • Response Retrieval: Ctrl-Y support for IPython, AI assistants, and shell REPLs
  • Markdown Code Extraction: Automatic extraction of code blocks from AI responses

Architecture Changes

  • Dispatcher Pattern: Clean separation between frontend and backend implementations
  • Backend Implementations:
    • tmux: External terminals via tmux (default for backward compatibility)
    • vimterminal: Vim's native terminal (no external dependencies)
  • Common Utilities: Shared response retrieval and text processing functions

New Dependencies

Core (both backends):

  • vim-slime (for sending text to terminals)

Tmux backend only:

  • tmux, xterm (or terminal emulator), xdotool (optional for focus management)

Vimterminal backend:

  • No additional dependencies!

Configuration

" Choose your backend
let g:vimteractive_backend = 'tmux'        " or 'vimterminal'

" Configure vimterminal split behavior (optional)
let g:vimteractive_vimterminal_config = {
    \ 'vertical': 1,
    \ 'term_rows': 20
    \ }

Migration from v2

For users who want the v2 experience (vim's native terminal):

let g:vimteractive_backend = 'vimterminal'

Security & Robustness Improvements

  • Fixed shell injection vulnerabilities
  • Added dependency checks for external tools
  • Improved error handling and edge case management
  • Buffer-local slime configuration to avoid global pollution

Documentation

  • Updated README with migration guide and backend comparison
  • Comprehensive help documentation with configuration examples
  • Architecture documentation for developers

Test plan

  • Test tmux backend with multiple REPLs (ipython, aichat, zsh)
  • Test vimterminal backend with same REPLs
  • Verify response retrieval works for all supported REPLs
  • Test backend switching and buffer-local overrides
  • Verify dependency checks and graceful degradation
  • Test markdown code block extraction
  • Verify documentation accuracy

🤖 Generated with Claude Code

williamjameshandley and others added 25 commits August 14, 2024 00:57
- Add CLAUDE.md for AI assistant guidance
- Update README.rst to reflect tmux/vim-slime architecture
- Document new dependencies (tmux, vim-slime, xdotool)
- Add aichat to supported REPLs list
- Fix configuration variable names (default_shells → default_repls)
- Document response retrieval for all supported REPLs
- Update help documentation with new features and requirements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Based on GPT-5 review, fixed multiple issues:

Code fixes:
- Fix :Iterm command to properly autodetect (was passing '-auto-')
- Fix g:vimteractive_terminal typo (was checking 'termina')
- Remove debug echo from aichat response retrieval
- Remove duplicate autoload/new.vim file

Documentation updates:
- Update docs to reflect external terminal/tmux architecture
- Fix bracketed paste configuration (list not dict)
- Document Visual mode Ctrl-Y behavior
- Add zsh prompt configuration variables
- Add perl and col dependencies for zsh
- Remove references to unimplemented g:vimteractive_slow_prompt
- Clarify :Iconn uses tmux pane names, not buffers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Major architectural change to support both backends:
- vim's native terminal (no external dependencies)
- tmux with external terminals (original behavior)

Changes:
- Add dispatcher pattern in main vimteractive.vim
- Create backend/ directory with tmux.vim and vimterminal.vim
- Move common functions to common.vim
- Add g:vimteractive_backend configuration (default: 'tmux')
- Update documentation for both backends

Benefits:
- No external dependencies with vimterminal backend
- Full backward compatibility with tmux backend
- Both backends can work simultaneously
- Clean, extensible architecture

Based on architecture advice from Gemini AI analysis.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixes and improvements based on architectural review:

Bug fixes:
- Fix division by zero in tmux next_term/prev_term when no panes exist
- Remove g:slime_target setting from dispatcher (now only set in backends)

Code quality improvements:
- Extract common REPL setup logic to vimteractive#common#prepare_repl_info()
- Reduce code duplication between tmux and vimterminal backends
- Make vimterminal split command configurable via g:vimteractive_vimterminal_config

Configuration example for vimterminal users:
  let g:vimteractive_vimterminal_config = {'split_command': '30vsplit'}

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The dispatcher was using exists() to check for function existence, but this
doesn't trigger vim's autoload mechanism. Changed to use try-catch with
call() which properly triggers autoload when calling functions in
backend/*.vim files.

Also fixed show_term in tmux backend to check for slime_config existence
before accessing it.

Co-Authored-By: Claude <noreply@anthropic.com>
Changed all REPL commands from strings to lists to handle complex quoting
correctly. This ensures arguments with spaces or quotes are properly escaped
when passed to subprocesses.

- Updated common.vim to handle list commands and substitute placeholders
- Modified tmux backend to shell-escape and join list arguments
- Converted all command definitions in plugin/vimteractive.vim to lists

This fixes the ipython logfile quoting issue and provides a more robust
foundation for command handling across backends.

Co-Authored-By: Claude <noreply@anthropic.com>
Removed explicit split creation and curwin option. Now term_start() handles
window creation directly, matching the behavior of the master branch and
providing standard vim terminal split behavior.

Also fixed duplicate window issue by removing redundant split command.

Co-Authored-By: Claude <noreply@anthropic.com>
Silenced the file rename command to prevent vim from showing the buffer
modification message, which was triggering the 'Press ENTER' prompt.
Kept the 'Connected to' message for consistency with tmux backend.

Co-Authored-By: Claude <noreply@anthropic.com>
Updated README.rst, CLAUDE.md, and doc/vimteractive.txt to document the new
dual backend support (tmux and vimterminal).

Added:
- Migration instructions for v2 users who want vim's native terminal
- Clear explanation of backend differences and configuration
- Updated dependencies for each backend
- Comprehensive options documentation
- Architecture details for the dispatcher pattern

This ensures users understand how to choose between external tmux terminals
and vim's built-in terminal based on their needs.

Co-Authored-By: Claude <noreply@anthropic.com>
The dispatcher was using exists() to check for function existence, but this
doesn't trigger vim's autoload mechanism. Changed to use try-catch with
call() which properly triggers autoload when calling functions in
backend/*.vim files.

Also fixed show_term in tmux backend to check for slime_config existence
before accessing it.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Updated default REPL documentation to match code (empty string = filetype detection)
- Fixed remaining string command example to use list format
- Documentation now accurately reflects actual behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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