Skip to content

Comments

Add coder/claudecode.nvim and improve terminal experience#71

Draft
ikuwow wants to merge 12 commits intomainfrom
feature/add-claudecode-nvim
Draft

Add coder/claudecode.nvim and improve terminal experience#71
ikuwow wants to merge 12 commits intomainfrom
feature/add-claudecode-nvim

Conversation

@ikuwow
Copy link
Owner

@ikuwow ikuwow commented Feb 20, 2026

Summary

  • Neovimプラグイン coder/claudecode.nvim と依存の folke/snacks.nvim を追加
  • Neovimターミナルバッファの表示・操作性を改善
  • Ghosttyの非アクティブpaneのdimを無効化

詳細

プラグインの追加

  • .vimrchas('nvim') セクションに coder/claudecode.nvimfolke/snacks.nvim を追加
  • plug#end() の後に Lua setup ブロックを追加(pcall でプラグイン未インストール時のエラー回避)
  • ターミナル幅を40%に設定

ambiwidth=double の削除

  • ambiwidth=doublesnacks.nvimlistchars 設定で E1512: Wrong character width for field "extends" エラーを引き起こすため削除
  • モダンなターミナルとフォントでは ambiwidth=double なしでも問題なく動作する

ターミナルバッファの表示改善

  • vim-zenspaceHighlightTrailingSpaces による全角空白・末尾空白のハイライトをターミナルバッファで無効化(clearmatches()TermOpen/BufEnter/WinEnter で実行)
  • vim-indent-guides をターミナルバッファで無効化
  • desert カラースキームのグレー背景をターミナルバッファで透過に変更
    • TermNormal ハイライトグループを guibg=NONE で定義
    • autocmd による winhighlight 設定は snacks.nvim のウィンドウ設定に上書きされるため、snacks_win_opts.wo.winhighlight 経由で設定する必要があった
    • ColorScheme イベントと VimResized イベントでも再適用してリサイズ時の表示崩れを防止

ターミナルバッファの操作性改善

  • TermOpen/BufEnter で自動的に insert mode に入るよう設定
  • <C-w>h/j/k/l でターミナルモードから直接ウィンドウ移動できるよう tnoremap を追加
    • Neovimのターミナルモードではデフォルトで <C-w> がターミナルプロセスに送信されるため、明示的なマッピングが必要
    • <Cmd>wincmd<CR> を使うことでモード変更なしにウィンドウ操作を実行

Ghostty設定

  • unfocused-split-opacity = 1 で非アクティブpaneのdimを無効化
  • アクティブpaneの判別はカーソルの表示/点滅で可能

注意点/ハマりどころ

  • snacks.nvimambiwidth=double と互換性がない(listchars のUnicode文字がエラーになる)
  • ターミナルウィンドウの winhighlight は autocmd で設定しても snacks.nvim のウィンドウ作成時に上書きされる。claudecode.nvimsnacks_win_opts.wo 経由で渡す必要がある
  • ModeChanged t:nt による normal mode 無効化はマウススクロール時にモードが高速で切り替わる問題を引き起こすため不採用とした

Test plan

  • Neovimを起動して :PlugInstall でプラグインがインストールされることを確認
  • :ClaudeCode でClaude Codeターミナルが開くことを確認
  • ターミナルバッファで全角空白がハイライトされないことを確認
  • ターミナルバッファの背景がグレーにならないことを確認(リサイズ時も含む)
  • ターミナル開いた時に自動で insert mode に入ることを確認
  • <C-w>h でターミナルから左のペインに移動できることを確認
  • マウスとキーボードでターミナルバッファのスクロールができることを確認
  • Ghosttyで非アクティブpaneのdimが無効化されていることを確認
  • CJK文字の表示に問題がないことを確認

🤖 Generated with Claude Code

ikuwow and others added 12 commits February 20, 2026 14:45
Add claudecode.nvim and its dependency snacks.nvim to the Neovim-only
plugin section. Include Lua setup block after plug#end().

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
ambiwidth=double causes E1512 error when snacks.nvim tries to set
listchars with ambiguous-width Unicode characters. Modern terminals
handle character widths correctly without this setting.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Disable line numbers in terminal buffers
- Clear match highlights (trailing spaces, zenspace) on terminal enter
- Disable indent guides in terminal buffers to fix grey background
- Auto-enter insert mode when opening/entering terminal buffers

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Define TermNormal highlight group with no background color and apply
it to terminal windows via winhighlight. This lets the terminal
emulator's native background show through instead of desert
colorscheme's grey.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Use ModeChanged autocmd to immediately re-enter insert mode when
terminal mode switches to terminal-normal mode, effectively
preventing normal mode in terminal buffers.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
clearmatches and IndentGuidesDisable were only triggered on TermOpen
and BufEnter, so window resize (which fires WinEnter) allowed
HighlightTrailingSpaces and indent guides to re-apply.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Re-define TermNormal on ColorScheme event to survive reloads
- Re-apply winhighlight on BufEnter/WinEnter, not just TermOpen
- Clear matches on VimResized for terminal buffers

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
winhighlight set by autocmd was being overridden by snacks.nvim's
window configuration. Pass it through snacks_win_opts so snacks.nvim
applies it natively.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
In Neovim terminal mode, C-w is sent to the terminal process by
default. Add tnoremap mappings using <Cmd>wincmd to enable window
navigation without leaving terminal mode.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
The t:nt ModeChanged autocmd caused rapid mode switching when
scrolling with mouse. Removing it allows normal mode for scrolling
while BufEnter auto-insert is still active.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Set unfocused-split-opacity to 1 so inactive panes are not dimmed.
Active pane is still identifiable by cursor visibility.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@ikuwow ikuwow changed the title Add coder/claudecode.nvim plugin for Neovim Add coder/claudecode.nvim and improve terminal experience Feb 20, 2026
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.

1 participant