Haskell Vim IDE
In less than ten minutes your Vim will transform into a beautiful
Haskell paradise. (Don't worry, it backs up your original
configuration to ~/.vimrc.yearmonthdate_time
.) It also builds all necessary support binaries
including codex
, hscope
, ghc-mod
, hasktags
, hoogle
and more.
No more wading through plugins trying to make them all work together. In ten minutes you will have a fully functional Vim that looks great and lets you
- inspect types
- evaluate Haskell
- lint and check
- manipulate tags
- hoogle lookup
- pointfree refactor
- tab complete
- unicode symbols
- highlight DSLs
- work with git
Installation
One command does it all:
bash <(curl -sL http://git.io/haskell-vim-now)
Keybindings and commands
The commands are organized into logical groups to help you remember them.
Types, autocomplete, and linting
<Tab> | Autocomplete with words in file |
<C-space> | Autocomplete with symbols in your Cabal sandbox |
,ht | Show type of expression under cursor |
,hT | Insert type of expression into previous line |
,hl | Run Haskell linter on file |
,hc | Run Haskell compile check on file |
,<cr> | Clear type selection |
Hoogle
,hh | Run Hoogle on the word under the cursor |
,hH | Run Hoogle and prompt for input |
,hi | Run Hoogle for detailed information on word under cursor |
,hI | Run Hoogle for detailed information and prompt for input |
,hz | Close the Hoogle search window |
GHCI repl
If you open a tmux terminal alongside MacVim then you can send Vim selections to it. This works well for evaluating things in GHCI.
,rs | Send selected text to tmux |
,rv | Change tmux session, window, and pane attachment |
Git
,g? | Last-committed files (Monday morning key) |
,gs | Git status (fugitive) |
,gg | Git grep |
,gl | Git log (extradition) |
,gd | Git diff |
,gb | Git blame |
Commenting
gc | Comment / Uncomment selection |
Aligning
,a= | Align on equal signs |
,a, | Align on commas |
,a| | Align on vertical bar |
,ap | Align on character of your choice |
Splits and find file
,<space> | Fuzzy file find (CtrlP) |
,f | Toggle file browser, find file |
,F | Toggle file browser |
,sj | Open split below |
,sk | Open split above |
,sh | Open split leftward |
,sl | Open split rightward |
Tags
,tg | Generate tags with codex |
,tt | Open/close the tag bar |
C-] | Jump to definition of symbol (codex + hasktags) |
C-\ | Show uses of symbol (hscope) |
Conversions
,h. | Transform visual selection to pointfree style |
,h> | Transform visual selection to pointed style |
Buffers
,bp | Previous buffer |
,bn | Next buffer |
,b<space> | Buffer fuzzy finder |
,bd | Delete buffer, keep window open (bbye) |
,bo | Close all buffers except the current one |
Misc
,ma | Enable mouse mode (default) |
,mo | Disable mouse mode |
,ig | Toggle indentation guides |
,u | Interactive undo tree |
,ss | Enable spell checking |
,e | Open file prompt with current path |
,<cr> | Clear search highlights |
,r | Redraw screen |
C-h | Move cursor to leftward pane |
C-k | Move cursor to upward pane |
C-j | Move cursor to downward pane |
C-l | Move cursor to rightward pane (redraw is `,r` instead) |
gq | Format selection using `stylish-haskell` for haskell buffers (`par` for others) |
,y | Yank to OS clipboard |
,d | Delete to OS clipboard |
,p | Paste from OS clipboard |
(If you prefer to restore the default screen redraw action of C-l
then add unmap <c-l>
to your .vimrc.local)
Customizing
After installing this configuration, your .vimrc
and .vim
will
be under version control. Don't alter these files. Instead, add your
own settings to ~/.vimrc.local
and ~/.vim.local/bundles.vim
.
Adding Custom Bundles
Vundle requires all Bundle statements to be given at once. To accommodate
this restriction, .vimrc
sources ~/.vim.local/bundles.vim
immediately
after its own Bundle statements.
Bundle statements made elsewhere are not recognized.
Docker image
If you are into developing with Docker, you can use the image.
docker build -t haskell-vim .
docker run --rm -i -t haskell-vim /bin/bash
If instead you want to extract the vim setup from the image that is easy enough
docker build -t haskell-vim .
mkdir ~/.haskell-vim-now
cd ~/.haskell-vim-now
docker run --rm haskell-vim tar -cz -C /root/.haskell-vim-now . > haskell-vim-now.tgz
tar -xzf haskell-vim-now.tgz
However, some things (for example the hoogle database) use absolute paths and don't work correctly.
Troubleshooting
See this wiki page for tips on fixing installation problems.