#---- Mail setup ----
set from = "alexis@praga.dev"
set realname = "Alexis Praga"
set mbox_type = Maildir # an we avoid that ?
set folder = "~/mail"
set sendmail = "msmtp"

# notmuch
set nm_default_url = "notmuch:///home/alex/mail"
set virtual_spoolfile=yes                          # enable virtual folders
virtual-mailboxes \
    "INBOX"     "notmuch://?query=tag:new"\
    "Archives"     "notmuch://?query=tag:archive"\
    "Unread"    "notmuch://?query=tag:unread"\
    "Starred"   "notmuch://?query=tag:*"\
    "Sent"      "notmuch://?query=tag:sent"        # sets up queries for virtual folders
# notmuch bindings
macro index s "<vfolder-from-query>"              # looks up a hand made query
macro index a "<modify-labels>+archive -unread -new<enter>"        # tag as Archived
bind index g noop
bind pager g noop
macro index,pager gi      "<change-vfolder>!<enter>"                  "Go to Inbox"
macro index,pager ga      "<change-vfolder>Archives<enter>"                  "Go to Inbox"
macro index,pager gs      "<change-vfolder>Sent<enter>"                  "Go to Inbox"
macro index d "<modify-labels-then-hide>-new -unread +deleted<enter>" # tag as Junk mail
macro index + "<modify-labels>+*<enter><sync-mailbox>"               # tag as starred
macro index - "<modify-labels>-*<enter><sync-mailbox>"               # tag as unstarred
macro index - "<modify-labels>-*<enter><sync-mailbox>"               # tag as unstarred

# Adress completion
set query_command = "notmuch address %s"
set query_format = "%5c %t %a %n %?e?(%e)?"
bind editor <Tab> complete-query

# mailbox settings
set spoolfile = +INBOX
set postponed = +Drafts
set record = +Sent
set trash = +Trash

# cache settings
set header_cache = "~/.cache/mutt/infomaniak/header_cache"
set message_cachedir = "~/.cache/mutt/infomaniak/message_cache"

# synchronization settings ['s' to sync]
macro index S "<shell-escape>mbsync -a<enter>" "sync email"

#---- Esthetic setup ----
# set sidebar_visible = yes

# Better sort
set sort = 'threads'
set sort_aux = 'reverse-date-received'

# view html automatically
auto_view text/html
alternative_order text/plain text/enriched text/html

# Catppuccin mocha
color normal		  default default         # Text is "Text"
color index		    color2 default ~N       # New Messages are Green
color index		    color1 default ~F       # Flagged messages are Red
color index		    color13 default ~T      # Tagged Messages are Red
color index		    color1 default ~D       # Messages to delete are Red
color attachment	color5 default          # Attachments are Pink
color signature	  color8 default          # Signatures are Surface 2
color search		  color4 default          # Highlighted results are Blue

color indicator		default color8          # currently highlighted message Surface 2=Background Text=Foreground
color error		    color1 default          # error messages are Red
color status		  color15 default         # status line "Subtext 0"
color tree        color15 default         # thread tree arrows Subtext 0
color tilde       color15 default         # blank line padding Subtext 0

color hdrdefault  color13 default         # default headers Pink
color header		  color13 default "^From:"
color header	 	  color13 default "^Subject:"

color quoted		  color15 default         # Subtext 0
color quoted1		  color7 default          # Subtext 1
color quoted2		  color8 default          # Surface 2
color quoted3		  color0 default          # Surface 1
color quoted4		  color0 default
color quoted5		  color0 default

color body		color2 default		[\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+               # email addresses Green
color body	  color2 default		(https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+        # URLs Green
color body		color4 default		(^|[[:space:]])\\*[^[:space:]]+\\*([[:space:]]|$) # *bold* text Blue
color body		color4 default		(^|[[:space:]])_[^[:space:]]+_([[:space:]]|$)     # _underlined_ text Blue
color body		color4 default		(^|[[:space:]])/[^[:space:]]+/([[:space:]]|$)     # /italic/ text Blue

color sidebar_flagged   color1 default    # Mailboxes with flagged mails are Red
color sidebar_new       color10 default   # Mailboxes with new mail are Green