Gmail Labs has released a new feature “Advanced IMAP Controls,” that lets you fine-tune your Gmail IMAP experience. You can choose which labels to sync in IMAP -- useful if you find your mail client choking on a big [Gmail]/All Mail folder.
After enabling, just go to the Labels tab under Settings. You'll see a new 'Show in IMAP' checkbox next to each of your labels. Uncheck the box and the corresponding folder will disappear from IMAP. There are also some more obscure options for those of you who want to make Gmail's IMAP work more like traditional IMAP providers: you can turn off auto-expunge or trash messages when they're no longer visible through IMAP.
In standard IMAP implementation, when a message is marked as deleted, Gmail either deletes or auto-expunges it from the folder right away. If you want the two-stage delete process, after you've enabled this Lab, just select 'Do not automatically expunge messages' under the 'Forwarding and POP/IMAP' tab in Settings.
Similarly, most IMAP systems don't share Gmail's concept of archiving messages (sending messages to the [Gmail]/All Mail folder rather than [Gmail]/Trash). If you'd prefer that deleted messages not remaining in any other visible IMAP folders are sent to [Gmail]/Trash instead, Advanced IMAP Controls lets you set your preferences this way. In the 'IMAP Access:' section of the 'Forwarding and POP/IMAP' tab, find the 'When a message is deleted from the last visible IMAP folder:' option. Select 'Move the message to the Gmail Trash.' If you want to take it one step further, you can select 'Immediately delete the message forever.'