diff --git a/ftplugin/mail.lua b/ftplugin/mail.lua new file mode 100644 index 0000000..b65e2ea --- /dev/null +++ b/ftplugin/mail.lua @@ -0,0 +1,42 @@ +if vim.startswith(vim.fs.basename(vim.api.nvim_buf_get_name(0)), "thread:") then + vim.opt_local.foldmethod = "marker" + vim.opt_local.foldlevel = 0 + + vim.api.nvim_buf_create_user_command(0, "TagAdd", function(arg) + require("notmuch.tag").thread_add_tag(arg.args) + end, { + complete = require("notmuch.completion").comp_tags, + nargs = "+", + }) + vim.api.nvim_buf_create_user_command(0, "TagRm", function(arg) + require("notmuch.tag").thread_rm_tag(arg.args) + end, { + complete = require("notmuch.completion").comp_tags, + nargs = "+", + }) + vim.api.nvim_buf_create_user_command(0, "TagToggle", function(arg) + require("notmuch.tag").thread_toggle_tag(arg.args) + end, { + complete = require("notmuch.completion").comp_tags, + nargs = "+", + }) + vim.api.nvim_buf_create_user_command(0, "FollowPatch", function() + local line = vim.api.nvim_win_get_cursor(0)[1] + require("notmuch.attach").follow_github_patch(line) + end, {}) + + vim.keymap.set("n", "U", function() require("notmuch.attach").get_urls_from_cursor_msg() end, { buffer = true }) + vim.keymap.set("n", "a", function() require("notmuch.attach").get_attachments_from_cursor_msg() end, { buffer = true }) + vim.keymap.set("n", "r", function() require("notmuch.refresh").refresh_thread_buffer() end, { buffer = true }) + vim.keymap.set("n", "C", function() require("notmuch.send").compose() end, { buffer = true }) + vim.keymap.set("n", "R", function() require("notmuch.send").reply() end, { buffer = true }) + vim.keymap.set("n", "q", function() require("notmuch.util").quit_or_bwipeout() end, { buffer = true }) + + vim.keymap.set("n", "+", ":TagAdd", { buffer = true }) + vim.keymap.set("n", "-", ":TagRm", { buffer = true }) + vim.keymap.set("n", "=", ":TagToggle", { buffer = true }) + + vim.keymap.set("n", "", "zj", { buffer = true, silent = true }) + vim.keymap.set("n", "", "zk", { buffer = true, silent = true }) + vim.keymap.set("n", "", "za", { buffer = true, silent = true }) +end diff --git a/ftplugin/mail.vim b/ftplugin/mail.vim deleted file mode 100644 index 2852d54..0000000 --- a/ftplugin/mail.vim +++ /dev/null @@ -1,23 +0,0 @@ - -if match(bufname("%"), "^thread:") != -1 - setlocal foldmethod=marker - setlocal foldlevel=0 - - command -buffer -complete=customlist,v:lua.require'notmuch.completion'.comp_tags -nargs=+ TagAdd :call v:lua.require('notmuch.tag').msg_add_tag("") - command -buffer -complete=customlist,v:lua.require'notmuch.completion'.comp_tags -nargs=+ TagRm :call tag.msg_rm_tag("") - command -buffer -complete=customlist,v:lua.require'notmuch.completion'.comp_tags -nargs=+ TagToggle :call tag.msg_toggle_tag("") - command -buffer FollowPatch :call v:lua.require('notmuch.attach').follow_github_patch(getline('.')) - - nnoremap U call v:lua.require('notmuch.attach').get_urls_from_cursor_msg() - nnoremap zj - nnoremap zk - nnoremap za - nnoremap a call v:lua.require('notmuch.attach').get_attachments_from_cursor_msg() - nnoremap r call v:lua.require('notmuch.refresh').refresh_thread_buffer() - nnoremap C call v:lua.require('notmuch.send').compose() - nnoremap R call v:lua.require('notmuch.send').reply() - nnoremap q bwipeout - nnoremap + :TagAdd - nnoremap - :TagRm - nnoremap = :TagToggle -endif diff --git a/ftplugin/notmuch-attach.lua b/ftplugin/notmuch-attach.lua new file mode 100644 index 0000000..78b2d49 --- /dev/null +++ b/ftplugin/notmuch-attach.lua @@ -0,0 +1,4 @@ +vim.keymap.set("n", "q", function() require("notmuch.util").quit_or_bwipeout() end, { buffer = true }) +vim.keymap.set("n", "v", function() require("notmuch.attach").view_attachment_part() end, { buffer = true }) +vim.keymap.set("n", "o", function() require("notmuch.attach").open_attachment_part() end, { buffer = true }) +vim.keymap.set("n", "s", function() require("notmuch.attach").save_attachment_part(nil, true) end, { buffer = true }) diff --git a/ftplugin/notmuch-attach.vim b/ftplugin/notmuch-attach.vim deleted file mode 100644 index c5ce4e9..0000000 --- a/ftplugin/notmuch-attach.vim +++ /dev/null @@ -1,5 +0,0 @@ -let attach = v:lua.require('notmuch.attach') -nnoremap q bwipeout -nnoremap v call attach.view_attachment_part() -nnoremap o call attach.open_attachment_part() -nnoremap s lua require('notmuch.attach').save_attachment_part(nil, true) diff --git a/ftplugin/notmuch-hello.lua b/ftplugin/notmuch-hello.lua new file mode 100644 index 0000000..d760e84 --- /dev/null +++ b/ftplugin/notmuch-hello.lua @@ -0,0 +1,12 @@ +-- welcome screen displaying all tags available to search +local keymaps = { + { "", function() require("notmuch.notmuch").search_terms("tag:" .. vim.api.nvim_get_current_line()) end}, + { "c", function() require("notmuch.notmuch").count("tag:" .. vim.api.nvim_get_current_line()) end}, + { "q", function() require("notmuch.util").quit_or_bwipeout() end}, + { "r", function() require("notmuch.refresh").refresh_hello_buffer() end}, + { "C", function() require("notmuch.send").compose() end}, + { "%", function() require("notmuch.sync").sync_maildir() end}, +} +for _, keymap in ipairs(keymaps) do + vim.keymap.set("n", keymap[1], keymap[2], { buffer = true }) +end diff --git a/ftplugin/notmuch-hello.vim b/ftplugin/notmuch-hello.vim deleted file mode 100644 index cf30cf0..0000000 --- a/ftplugin/notmuch-hello.vim +++ /dev/null @@ -1,10 +0,0 @@ -" welcome screen displaying all tags available to search -let nm = v:lua.require('notmuch') -let r = v:lua.require('notmuch.refresh') -let s = v:lua.require('notmuch.sync') -nnoremap call nm.search_terms("tag:" .. getline('.')) -nnoremap c echo nm.count("tag:" .. getline('.')) -nnoremap q bwipeout -nnoremap r call r.refresh_hello_buffer() -nnoremap C call v:lua.require('notmuch.send').compose() -nnoremap % call s.sync_maildir() diff --git a/ftplugin/notmuch-threads.lua b/ftplugin/notmuch-threads.lua new file mode 100644 index 0000000..22cc407 --- /dev/null +++ b/ftplugin/notmuch-threads.lua @@ -0,0 +1,50 @@ +vim.opt_local.wrap = false + +vim.api.nvim_buf_create_user_command(0, "DelThread", function(arg) + local line1, line2 = arg.line1, arg.line2 + require("notmuch.tag").thread_add_tag("del", line1, line2) + require("notmuch.tag").thread_rm_tag("inbox", line1, line2) + vim.opt_local.modifiable = true + vim.api.nvim_buf_set_lines(0, math.min(line1, line2) - 1, math.max(line1, line2), true, {}) + vim.opt_local.modifiable = false +end, { + range = true, +}) +vim.api.nvim_buf_create_user_command(0, "TagAdd", function(arg) + require("notmuch.tag").thread_add_tag(arg.args, arg.line1, arg.line2) +end, { + complete = require("notmuch.completion").comp_tags, + range = true, + nargs = "+", +}) +vim.api.nvim_buf_create_user_command(0, "TagRm", function(arg) + require("notmuch.tag").thread_rm_tag(arg.args, arg.line1, arg.line2) +end, { + complete = require("notmuch.completion").comp_tags, + range = true, + nargs = "+", +}) + +vim.keymap.set("n", "", function() require("notmuch.notmuch").show_thread() end, { buffer = true }) +vim.keymap.set("n", "r", function() require("notmuch.refresh").refresh_search_buffer() end, { buffer = true }) +vim.keymap.set("n", "q", function() require("notmuch.util").quit_or_bwipeout() end, { buffer = true }) +vim.keymap.set("n", "%", function() require("notmuch.sync").sync_maildir() end, { buffer = true }) +vim.keymap.set("n", "C", function() require("notmuch.send").compose() end, { buffer = true }) +vim.keymap.set("n", "+", ":TagAdd", { buffer = true }) +vim.keymap.set("x", "+", ":TagAdd", { buffer = true }) +vim.keymap.set("n", "-", ":TagRm", { buffer = true }) +vim.keymap.set("x", "-", ":TagRm", { buffer = true }) +vim.keymap.set("n", "=", ":TagToggle", { buffer = true }) +vim.keymap.set("x", "=", ":TagToggle", { buffer = true }) +vim.keymap.set("n", "a", "TagToggle inboxj", { buffer = true }) +vim.keymap.set("x", "a", ":TagToggle inbox", { buffer = true }) +vim.keymap.set("n", "A", "TagRm inbox unreadj", { buffer = true }) +vim.keymap.set("x", "A", ":TagRm inbox unread", { buffer = true }) +vim.keymap.set("n", "x", "TagToggle unread", { buffer = true }) +vim.keymap.set("x", "x", ":TagToggle unread", { buffer = true }) +vim.keymap.set("n", "f", "TagToggle flaggedj", { buffer = true }) +vim.keymap.set("x", "f", ":TagToggle flagged", { buffer = true }) +vim.keymap.set("n", "dd", "DelThread", { buffer = true }) +vim.keymap.set("x", "d", ":DelThread", { buffer = true }) +vim.keymap.set("n", "D", function() require("notmuch.delete").purge_del() end, { buffer = true }) +vim.keymap.set("n", "o", function() require("notmuch.notmuch").reverse_sort_threads() end, { buffer = true }) diff --git a/ftplugin/notmuch-threads.vim b/ftplugin/notmuch-threads.vim deleted file mode 100644 index 60beda3..0000000 --- a/ftplugin/notmuch-threads.vim +++ /dev/null @@ -1,35 +0,0 @@ -setlocal nowrap - -let nm = v:lua.require('notmuch') -let r = v:lua.require('notmuch.refresh') -let s = v:lua.require('notmuch.sync') -let tag = v:lua.require('notmuch.tag') - -command -buffer -range -complete=customlist,v:lua.require'notmuch.completion'.comp_tags -nargs=+ TagAdd :call tag.thread_add_tag(, , ) -command -buffer -range -complete=customlist,v:lua.require'notmuch.completion'.comp_tags -nargs=+ TagRm :call tag.thread_rm_tag(, , ) -command -buffer -range -complete=customlist,v:lua.require'notmuch.completion'.comp_tags -nargs=+ TagToggle :call tag.thread_toggle_tag(, , ) -command -buffer -range DelThread :call tag.thread_add_tag("del", , ) | :call tag.thread_rm_tag("inbox", , ) - -nnoremap call nm.show_thread() -nnoremap r call r.refresh_search_buffer() -nnoremap q bwipeout -nnoremap % call s.sync_maildir() -nnoremap + :TagAdd -xnoremap + :TagAdd -nnoremap - :TagRm -xnoremap - :TagRm -nnoremap = :TagToggle -xnoremap = :TagToggle -nnoremap a TagToggle inboxj -xnoremap a :TagToggle inbox -nnoremap A TagRm inbox unreadj -xnoremap A :TagRm inbox unread -nnoremap x TagToggle unread -xnoremap x :TagToggle unread -nnoremap f TagToggle flaggedj -xnoremap f :TagToggle flagged -nnoremap C call v:lua.require('notmuch.send').compose() -nnoremap dd DelThreadj -xnoremap d :DelThread -nnoremap D lua require('notmuch.delete').purge_del() -nnoremap o call nm.reverse_sort_threads()