Procházet zdrojové kódy

update vim readme with new mappings and options

Clément DOUIN před 4 roky
rodič
revize
ccfc3b0d6e

+ 2 - 0
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

+ 39 - 1
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   <plug>(himalaya-msg-reply)
 nmap gR   <plug>(himalaya-msg-reply-all)
 nmap gf   <plug>(himalaya-msg-forward)
 nmap ga   <plug>(himalaya-msg-attachments)
+nmap gC   <plug>(himalaya-msg-copy)
+nmap gM   <plug>(himalaya-msg-move)
+nmap gD   <plug>(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 <plug>(himalaya-msg-reply)
 nmap gR <plug>(himalaya-msg-reply-all)
 nmap gf <plug>(himalaya-msg-forward)
 nmap ga <plug>(himalaya-msg-attachments)
+nmap gC <plug>(himalaya-msg-copy)
+nmap gM <plug>(himalaya-msg-move)
+nmap gD <plug>(himalaya-msg-delete)
 ```
 
 ### Write message view

+ 5 - 1
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()

+ 10 - 2
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))

+ 1 - 1
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("<plug>(himalaya-%s)", plug)
-    execute printf("%snoremap <silent>%s :call himalaya#%s<cr>", mode, plug, name)
+    execute printf("%snoremap <silent>%s :call himalaya#%s()<cr>", mode, plug, name)
 
     if !hasmapto(plug, mode)
       execute printf("%smap <nowait><buffer>%s %s", mode, key, plug)

+ 13 - 13
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", "<cr>", "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", "<cr>", "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"     ],
 \])

+ 10 - 6
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"     ],
 \])