I was thinking about my ideal haskell editing workflow:
- I open three terminals (split using iterm2).
- Terminal 1 runs vim for editing the haskell source files.
- Terminal 2 automatically runs hlint on the changed files whenenver a file in the current directory or subdirectory updates or is created
- Terminal 3 runs ghci, automatically loading/reloading the changed files.
Has anyone set up anything like this? The goal is to have hlint constantly watch my code for styling problems and for ghci be available for quick changes, without having to do anything other than saving the file in vim.
I was thinking of using something like watchr for the automation.
You can run arbitrary shell commands in vim using the
BufWriteautocommand:For example, put this in your
~/.vimrc:This will run
echo <CURRENT FILENAME> >> ~/saves.txtevery time you save a haskell file.So this is an easy way to trigger external scripts.
Now you can write some iterm scripts to relay commands to your other terminals. Something like:
So you can use the vim autocommand to trigger the appropriate iterm script (passing the current file name so the script can tell ghci and hlint which file to process).
You'll probably want to toggle this on and off (you may not want to do this for EVERY haskell file), so think about wrapping the functionality in a vim function that lets you toggle it (as well as set arguments for how iterm should find your ghci and hlint terminals).