Getting Gmail accounts to integrate nicely with Apple Mail has always had some difficulties as Gmail does not use a standard IMAP system and uses labels instead of folders and messages can have two labels. The concept of the All Mail label is effectively an archive and has caused confusion between a delete and an archive. Apple has been improving this interaction with Gmail (e.g. in iOS8) and in OSX it has steadily improved as OSX has evolved from Mountain Lion to Mavericks and now Yosemite. Unfortunately many of the settings and tips that were described for earlier version and are still easily found via search engines are no longer relevant in Yosemite and in some situation make the situation worse. Below are settings (click figures for enlarged view) which seem to work reliably both for @gmail.com and Google App @mydomain.com accounts.
1. In web interface for Gmail under the account settings > labels tab all the labels need to be exposed to IMAP by ticking the right hand column check boxes. (For previous version of OSX it was suggested not to select certain ones e.g. Bin or All Mail but this makes Yosemite worse).
2. In web interface for Gmail under the account settings > Forwarding -POP/IMAP tab set the auto-expunge settings as below, to be controlled by client. In the figure it shows messages moved to the bin and they will be deleted after 30 days - you can choose to delete them immediately if required. The settings on this tab need to be saved with button at the bottom of page unlike the settings for labels.
3. This assumes that a Gmail account has already been added in usual manner to Mail app on the Mac. With Mail app open on the Mac you need to open Preferences from the drop down menu of the Mail item in the menu bar at top of screen and then choose Accounts tab and from within Accounts select the Gmail account on left side (the second one in the screenshot) and choose Mailbox Behaviours tab. Set all the option boxes to be ticked as shown below. When set select another account and this will give you option to save the new settings. It is all pretty much done now but it is worth closing mail (Quitting with CMD-Q not just minimising) and then reopening. IT may take a little time to resynchronise the account. Sometimes it is worth selecting a mailbox and choosing to "Rebuild" from the Mailbox menu in the menu bar at the top.
4. After reopening Mail on the left hand side bar will now display as in the screenshot below. In this example there are four accounts and each has an entry in the submenu for Inbox, Drafts, Sent, Junk, Trash and Archive . Deleted messages from Gmail account will show in the relevant mailbox under Trash and under Archive it will show the Gmail "All Mail" label/folder mapped to the Archive as it should. However beware when working with the All Mail Archive folder as all GMail items will be present but may well exist in other folders if they have user labels and best to deal with this folder via Gmail web interface where all the labels for each message in the All Mail folder can be seen.
All the user defined labels/folders as opposed to these system labels can be seen uinder the individual accounts lower in the sidebar (providing the labels have been exposed to IMAP in settings)