From 9afcc87711da71697ea726bc1054a243a2243391 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Tue, 10 Mar 2026 16:22:28 +0100 Subject: [PATCH] Add claudecode.nvim for email refinement in neomutt --- vim.org | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/vim.org b/vim.org index 3e92c35..0981d86 100644 --- a/vim.org +++ b/vim.org @@ -131,6 +131,12 @@ Plug 'nvim-telescope/telescope-ui-select.nvim' Plug 'folke/which-key.nvim' #+end_src +** Claude Code +#+begin_src vimrc +Plug 'folke/snacks.nvim' +Plug 'coder/claudecode.nvim' +#+end_src + ** Plug End #+begin_src vimrc call plug#end() @@ -526,6 +532,13 @@ snoremap b[sviw #+begin_src vimrc autocmd FileType mail set spell spelllang=en_us,fr autocmd FileType mail set textwidth=0 +autocmd FileType mail lcd %:p:h + +" Start Claude: save, open Claude, add current buffer, then ask to refine +autocmd FileType mail nnoremap ae lua ClaudeMailRefine() + +" Finish: accept diff, close Claude pane, save and quit +autocmd FileType mail nnoremap aq ClaudeCodeDiffAcceptClaudeCode function! Mailcomplete(findstart, base) if a:findstart == 1 @@ -788,6 +801,55 @@ lua << EOF EOF #+end_src +** Diff wrap +#+begin_src vimrc +autocmd OptionSet diff if v:option_new | setlocal wrap linebreak | endif +#+end_src + +** =claudecode= +#+begin_src vimrc +lua << EOF +require('claudecode').setup({ + split_side = "right", + split_width_percentage = 0.35, +}) + +function ClaudeMailRefine() + local win = vim.api.nvim_get_current_win() + vim.cmd('w') + vim.cmd('ClaudeCode') + vim.defer_fn(function() + if vim.api.nvim_win_is_valid(win) then + vim.api.nvim_set_current_win(win) + end + vim.cmd('ClaudeCodeAdd %') + vim.defer_fn(function() + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + local name = vim.api.nvim_buf_get_name(buf) + if name:match('claude') then + local job_id = vim.b[buf].terminal_job_id + if job_id then + vim.api.nvim_chan_send(job_id, "Refine this email using a single file edit tool call: fix the subject, grammar, clarity and tone all at once. Do not make multiple edits.\r") + break + end + end + end + end, 500) + end, 1000) +end +EOF + +nnoremap ac ClaudeCode +nnoremap af ClaudeCodeFocus +nnoremap ar ClaudeCode --resume +nnoremap aC ClaudeCode --continue +nnoremap am ClaudeCodeSelectModel +nnoremap ab ClaudeCodeAdd % +vnoremap as ClaudeCodeSend +nnoremap aa ClaudeCodeDiffAccept +nnoremap ad ClaudeCodeDiffDeny +#+end_src + * Key Bindings ** Quit #+begin_src vimrc