Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch email #13

Open
lyz-code opened this issue Nov 15, 2024 · 1 comment
Open

Fetch email #13

lyz-code opened this issue Nov 15, 2024 · 1 comment

Comments

@lyz-code
Copy link

Hi, I'd love to be able to fetch new emails from within vim for example with the r binding. I planned to do this with a custom binding, but the problem is that I don't know how to get the himalaya account name that is activated in the current buffer.

Can you please guide me on how to get the account name to run something like mbrsync account_name from a custom binding?

Thanks!

@lyz-code
Copy link
Author

lyz-code commented Nov 15, 2024

Until is supported I'm using the next snippet (in case it's of use to anyone)

return {
  {
    "pimalaya/himalaya-vim",
    keys = {
      -- Email refreshing bindings
      { "<leader>rj", ':lua FetchEmails("lyz")<CR>', desc = "Fetch [email protected]" },
    },
    config = function()
      function FetchEmails(account)
        vim.notify("Fetching emails for " .. account .. ", please wait...", vim.log.levels.INFO)
        vim.cmd("redraw")
        vim.fn.jobstart("mbsync " .. account, {
          on_exit = function(_, exit_code, _)
            if exit_code == 0 then
              vim.notify("Emails for " .. account .. " fetched successfully!", vim.log.levels.INFO)
            else
              vim.notify("Failed to fetch emails for " .. account .. ". Check the logs.", vim.log.levels.ERROR)
            end
          end,
        })
      end
    end,
  },
}

You still need to open again :Himalaya account_name as the plugin does not reload if there are new emails.

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

No branches or pull requests

1 participant