Skip to content

feat: add vi mode indicator support for prompts#23

Merged
eitsupi merged 10 commits intomainfrom
feature/vi-config
Feb 1, 2026
Merged

feat: add vi mode indicator support for prompts#23
eitsupi merged 10 commits intomainfrom
feature/vi-config

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Feb 1, 2026

Fix #22

eitsupi and others added 3 commits February 1, 2026 02:59
Add configuration and runtime support for vi mode indicators in prompts:

- Add ViConfig/ViSymbol structs for vi mode symbol configuration
  - insert: symbol for vi insert mode
  - normal: symbol for vi normal mode
  - non_vi: symbol for non-vi modes (Emacs, future Helix, etc.)

- Add ViColorConfig for vi mode indicator colors

- Add {vi} placeholder to PromptFormatter for dynamic vi mode expansion

- Update RPrompt to render vi mode indicators with colors via
  render_prompt_indicator()

- Update PromptRuntimeConfig to pass ViConfig and ViColorConfig

Design notes:
- ViSymbol is pub(crate) as it's an internal implementation detail
- non_vi field added for future-proofing (potential Helix mode support)
- Status colors and vi colors apply to different parts of the prompt
  and don't conflict

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Rename `vi_color` field to `vi_colors` in PromptRuntimeConfig and RPrompt
- Rename `with_vi_color()` method to `with_vi_colors()` in RPrompt
- Remove unused re-exports from editor/mod.rs
- Add #[allow(dead_code)] to ViMode and format_with_vi (reserved for future use)

This aligns with the existing `status_colors` naming convention.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add documentation for the vi mode indicator feature:
- Add {vi} placeholder to prompt placeholders table
- Add [prompt.vi] and [colors.prompt.vi] to default config
- Add vi mode colors to prompt colors table
- Add new "Vi Mode Indicator" section with configuration examples

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings February 1, 2026 03:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Resolved conflicts in:
- config/mod.rs: merged ViConfig export
- config/prompt.rs: added ViSymbol and ViConfig, removed duplicate StatusConfig impl
- repl/state.rs: merged vi config handling in prompts and tests

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi marked this pull request as draft February 1, 2026 05:34
@eitsupi eitsupi added this to the 0.2.0 milestone Feb 1, 2026
The {vi} placeholder now works as documented:
- When {vi} is in the prompt format string, it expands to the current
  vi mode symbol (insert/normal/non_vi) at that position
- render_prompt_indicator returns empty when {vi} is present to avoid
  duplicate display
- Uses Cell<EditModeKind> to track mode with interior mutability

This allows users to position the vi mode indicator anywhere in their
prompt format string, e.g., "R [{vi}] {version}> ".

Includes comprehensive tests for the placeholder functionality.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi requested a review from Copilot February 1, 2026 05:40
@eitsupi eitsupi marked this pull request as ready for review February 1, 2026 05:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Adds test_pty_vi_placeholder_mode_switch to document the current
behavior of the {vi} placeholder.

Documents known issue: The {vi} placeholder is always 1 render cycle
behind the actual vi mode due to reedline's Prompt trait design:
- render_prompt_left() is called before render_prompt_indicator()
- Mode information is only passed to render_prompt_indicator()

Observed behavior:
- After Escape: [I] (should be [N]) - 1 cycle behind
- After 'j':    [N] (correct, but delayed)
- After 'i':    [N] (should be [I]) - 1 cycle behind

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi marked this pull request as draft February 1, 2026 06:33
eitsupi and others added 2 commits February 1, 2026 06:35
Remove {vi} placeholder approach due to 1-cycle delay issue caused by
reedline's render order (render_prompt_left called before render_prompt_indicator).

Instead, display vi mode indicator at end of prompt via render_prompt_indicator(),
following the same approach as nushell.

- Remove ViMode enum and format_with_vi from editor/prompt.rs
- Add documentation comments explaining reedline constraint
- Update docs with recommended config using ">" and ":" indicators
- Update integration test to verify correct mode switching

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi marked this pull request as ready for review February 1, 2026 06:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@eitsupi eitsupi merged commit 045b8c8 into main Feb 1, 2026
10 checks passed
@eitsupi eitsupi deleted the feature/vi-config branch February 1, 2026 08:00
eitsupi added a commit that referenced this pull request Feb 1, 2026
- [Unreleased] history import (#31), :info enhancements (#29)
- [0.2.0-beta.1] vi mode indicator (#23), Windows Rprofile fix (#20)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

Feature request: telegraph current vi mode

2 participants