diff --git a/CHANGELOG.md b/CHANGELOG.md index 188134b..44e3ecd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Mailbox attributes [#134] - Wiki entry about new messages counter [#121] +- Copy/move/delete a message in vim [#95] ### Changed @@ -241,6 +242,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#86]: https://github.com/soywod/himalaya/issues/86 [#87]: https://github.com/soywod/himalaya/issues/87 [#89]: https://github.com/soywod/himalaya/issues/89 +[#95]: https://github.com/soywod/himalaya/issues/95 [#96]: https://github.com/soywod/himalaya/issues/96 [#100]: https://github.com/soywod/himalaya/issues/100 [#121]: https://github.com/soywod/himalaya/issues/121 diff --git a/vim/README.md b/vim/README.md index c9bb459..ec28778 100644 --- a/vim/README.md +++ b/vim/README.md @@ -23,6 +23,32 @@ It is highly recommanded to have this option on: set hidden ``` +## Configuration + +### Mailbox picker provider + +```vim +let g:himalaya_mailbox_picker = 'native' | 'fzf' | 'telescope' +``` + +Defines the provider used for picking mailboxes: + +- `native`: a vim native input +- `fzf`: https://github.com/junegunn/fzf.vim +- `telescope`: https://github.com/nvim-telescope/telescope.nvim + +If no value given, the first loaded (and available) provider will be used (fzf +> telescope > native). + +### Telescope preview + +```vim +let g:himalaya_telescope_preview_enabled = 0 +``` + +Should enable telescope preview when picking a mailbox with the telescope +provider. + ## Usage ### List messages view @@ -43,7 +69,10 @@ set hidden | Reply to the focused msg | `gr` | | Reply all to the focused msg | `gR` | | Forward the focused message | `gf` | -| Download all focused msg attachments | `ga` | +| Download attachments from focused message | `ga` | +| Copy the focused message | `gC` | +| Move the focused message | `gM` | +| Delete the focused message(s) | `gD` | They can be customized: @@ -57,6 +86,9 @@ nmap gr (himalaya-msg-reply) nmap gR (himalaya-msg-reply-all) nmap gf (himalaya-msg-forward) nmap ga (himalaya-msg-attachments) +nmap gC (himalaya-msg-copy) +nmap gM (himalaya-msg-move) +nmap gD (himalaya-msg-delete) ``` ### List mailboxes @@ -84,6 +116,9 @@ With [fzf](https://github.com/junegunn/fzf) support: | Reply all to the msg | `gR` | | Forward the message | `gf` | | Download all msg attachments | `ga` | +| Copy the message | `gC` | +| Move the message | `gM` | +| Delete the message | `gD` | They can be customized: @@ -93,6 +128,9 @@ nmap gr (himalaya-msg-reply) nmap gR (himalaya-msg-reply-all) nmap gf (himalaya-msg-forward) nmap ga (himalaya-msg-attachments) +nmap gC (himalaya-msg-copy) +nmap gM (himalaya-msg-move) +nmap gD (himalaya-msg-delete) ``` ### Write message view diff --git a/vim/autoload/himalaya/mbox.vim b/vim/autoload/himalaya/mbox.vim index b7c9ae5..788423d 100644 --- a/vim/autoload/himalaya/mbox.vim +++ b/vim/autoload/himalaya/mbox.vim @@ -70,7 +70,11 @@ function! himalaya#mbox#pick(cb) endtry endfunction -function! himalaya#mbox#set(mbox) +function! himalaya#mbox#change() + call himalaya#mbox#pick("himalaya#mbox#_change") +endfunction + +function! himalaya#mbox#_change(mbox) let s:curr_mbox = a:mbox let s:curr_page = 0 call himalaya#msg#list() diff --git a/vim/autoload/himalaya/msg.vim b/vim/autoload/himalaya/msg.vim index a710a0c..e8ce202 100644 --- a/vim/autoload/himalaya/msg.vim +++ b/vim/autoload/himalaya/msg.vim @@ -147,7 +147,11 @@ function! himalaya#msg#forward() endtry endfunction -function! himalaya#msg#copy(target_mbox) +function! himalaya#msg#copy() + call himalaya#mbox#pick("himalaya#msg#_copy") +endfunction + +function! himalaya#msg#_copy(target_mbox) try let pos = getpos(".") let msg_id = stridx(bufname("%"), "Himalaya messages") == 0 ? s:get_focused_msg_id() : s:msg_id @@ -162,7 +166,11 @@ function! himalaya#msg#copy(target_mbox) endtry endfunction -function! himalaya#msg#move(target_mbox) +function! himalaya#msg#move() + call himalaya#mbox#pick("himalaya#msg#_move") +endfunction + +function! himalaya#msg#_move(target_mbox) try let msg_id = stridx(bufname("%"), "Himalaya messages") == 0 ? s:get_focused_msg_id() : s:msg_id let choice = input(printf("Are you sure you want to move the message %d? (y/N) ", msg_id)) diff --git a/vim/autoload/himalaya/shared/bindings.vim b/vim/autoload/himalaya/shared/bindings.vim index 90a0f4d..0cac565 100644 --- a/vim/autoload/himalaya/shared/bindings.vim +++ b/vim/autoload/himalaya/shared/bindings.vim @@ -2,7 +2,7 @@ function! himalaya#shared#bindings#define(bindings) for [mode, key, name] in a:bindings let plug = substitute(name, "[#_]", "-", "g") let plug = printf("(himalaya-%s)", plug) - execute printf("%snoremap %s :call himalaya#%s", mode, plug, name) + execute printf("%snoremap %s :call himalaya#%s()", mode, plug, name) if !hasmapto(plug, mode) execute printf("%smap %s %s", mode, key, plug) diff --git a/vim/ftplugin/himalaya-msg-list.vim b/vim/ftplugin/himalaya-msg-list.vim index 3e5db2f..9231211 100644 --- a/vim/ftplugin/himalaya-msg-list.vim +++ b/vim/ftplugin/himalaya-msg-list.vim @@ -5,17 +5,17 @@ setlocal nomodifiable setlocal nowrap call himalaya#shared#bindings#define([ - \["n", "gm" , "mbox#pick('himalaya#mbox#set')"], - \["n", "gp" , "mbox#prev_page()" ], - \["n", "gn" , "mbox#next_page()" ], - \["n", "", "msg#read()" ], - \["n", "gw" , "msg#write()" ], - \["n", "gr" , "msg#reply()" ], - \["n", "gR" , "msg#reply_all()" ], - \["n", "gf" , "msg#forward()" ], - \["n", "ga" , "msg#attachments()" ], - \["n", "gC" , "mbox#pick('himalaya#msg#copy')"], - \["n", "gM" , "mbox#pick('himalaya#msg#move')"], - \["n", "gD" , "msg#delete()" ], - \["v", "gD" , "msg#delete()" ], + \["n", "gm" , "mbox#change" ], + \["n", "gp" , "mbox#prev_page" ], + \["n", "gn" , "mbox#next_page" ], + \["n", "", "msg#read" ], + \["n", "gw" , "msg#write" ], + \["n", "gr" , "msg#reply" ], + \["n", "gR" , "msg#reply_all" ], + \["n", "gf" , "msg#forward" ], + \["n", "ga" , "msg#attachments"], + \["n", "gC" , "msg#copy" ], + \["n", "gM" , "msg#move" ], + \["n", "gD" , "msg#delete" ], + \["v", "gD" , "msg#delete" ], \]) diff --git a/vim/ftplugin/himalaya-msg-read.vim b/vim/ftplugin/himalaya-msg-read.vim index 5c5133a..427ddf5 100644 --- a/vim/ftplugin/himalaya-msg-read.vim +++ b/vim/ftplugin/himalaya-msg-read.vim @@ -1,3 +1,5 @@ +syntax on + setlocal bufhidden=wipe setlocal buftype=nofile setlocal cursorline @@ -5,12 +7,14 @@ setlocal filetype=mail setlocal foldexpr=himalaya#shared#thread#fold(v:lnum) setlocal foldmethod=expr setlocal nomodifiable -syntax on call himalaya#shared#bindings#define([ - \["n", "gw", "msg#write()" ], - \["n", "gr", "msg#reply()" ], - \["n", "gR", "msg#reply_all()" ], - \["n", "gf", "msg#forward()" ], - \["n", "ga", "msg#attachments()"], + \["n", "gw", "msg#write" ], + \["n", "gr", "msg#reply" ], + \["n", "gR", "msg#reply_all" ], + \["n", "gf", "msg#forward" ], + \["n", "ga", "msg#attachments"], + \["n", "gC", "msg#copy" ], + \["n", "gM", "msg#move" ], + \["n", "gD", "msg#delete" ], \])