Chris Stryczynski

Software Developer / Consultant

Quick start for Spacemacs Haskell

This quick 5/10 minute reference aimed towards new users to Spacemacs specifically with Haskell. It’s also used for my own reference.

Terms:

  • Project - any directory with a git repository it seems
  • Helm - the line dialog interface / plugin
  • Intero - A emacs plugin for Haskell
  • Haskell-mode - Another alternative emacs plugin for Haskell

File / Project navigation:

  • Navigate to recently used file SPC f r
  • Navigate to recently used file in project SPC p r
  • Navigate to file (fuzzy search) SPC p f
  • Switch / select a project (fuzzy search) SPC p p
  • Show and navigate to file browser - SPC f T

Searching:

Search for text in all files in project (you need to enter at least 3 chars) SPC / Search using word under cursor (just like the above SPC /SPC *

Haskell functionality:

  • Add type annotation to expression under cursor SPC m h T
  • Restart intero - (if you modified the cabal file, it’ll fix old config errors being reported) SPC m i r
  • Reformat code in current buffer SPC m f
  • Rename an identifier in the current file SPC s e
  • Go to definition (you may need to generate a TAGS file) SPC m g g
  • Auto format the buffer SPC SPC hindent-reformat-buffer (requires hindent to be installed)

Useful tips:

  • Smaller windows / frames / views seem much more responsive. With that in mind, instead of using ‘internal’ splitting for windows I instead make a ‘frame’ SPC w F (essentially another window) which I can then handle more conveniently  with a windows tiling manager. 
  • The default theme seems much more laggy than then alternatives SPC T s.
  • The little circle with a number in it (bottom left) is the window number. Press SPC N where N in is the number to navigate to that window.
  • If you find Emacs ‘frozen’ or busy working on some operation - I usually have a lot of luck cancelling any action with C-G (control g), which is the default Emacs keybinding to cancel an operation (like ESC in Vim).