Fair warninhg that Gmail doesn't play well with IMAP. It technically works. But it causes a mess due to Gmail's use of labels instead of folders.
IMAP only understands folders, I.e. each email can only be stored in a single folder.
Gmail's labels though function more like tags where you can assign multiple labels to each email. Even if you don't use custom labels, you're still using the built-in labels.
Inbox, All Mail, Spam, Trash, etc are all labels in Gmail. When you receive a new email, it likely is going to both Inbox and All Mail. When you Archive an email, all you're doing is removing the Inbox label. Marking something as Spam just adds the Spam label and removes the Inbox and All Mail labels. (All Mail filters out emails labelled as Spam or Trash).
When you try to pair Gmail with IMAP (which is necessary for using third-party email clients), the Label-Folder mismatch is "fixed" by duplicating your emails into multiple folders.
So new emails will get two copies, one to your Inbox Folder and one to your All Mail folder.
This means a lot of duplicate emails and it gets worse the more Gmail labels you use. The duplication will cause storage bloat and performance issues from having to sync more emails. It gets really confusing and error prone, especially if you're using custom folders.
Some people choose not to sync their All Mail folder, but this doesn't actually solve the organizational problem on the server side of things. The emails are still there. They just don't see them.
Like other Google products that break standards, this creates an organizational nightmare in the long run.