diff --git a/README.md b/README.md
index ad733a8..623d828 100644
--- a/README.md
+++ b/README.md
@@ -2,13 +2,13 @@ hdevtools Vim Plugin
====================
Vim plugin for Haskell development powered by the lightning fast
-[hdevtools]() background server.
+[hdevtools]() background server.
About
-----
-[hdevtools]() is a command line program
+[hdevtools]() is a command line program
powered by the GHC API, that provides services for Haskell development.
hdevtools works by running a persistent process in the background, so that your
Haskell modules remain in memory, instead of having to reload everything each
@@ -19,25 +19,60 @@ editor.
This is the Vim plugin that integrates Vim with hdevtools.
-Installation
+Requirements
------------
-1. You must install the `hdevtools` command line program, It can be found
- here: , or from Hackage:
+The *vim-hdevtools* plugin requires a way to run `hdevtools`. Here are the
+ways to make `hdevtools` available to the plugin.
+
+### Global `hdevtools`
+
+Install the `hdevtools` command line program so that it is on your
+executable `$PATH`.
+
+Get it from Github:
+
+Or from Hackage:
+
+ $ cabal install hdevtools
+
+Or from Stackage:
+
+ $ stack install hdevtools
+
+Note that `hdevtools` must be built with the same version of GHC as the
+project which you will be editing.
- $ cabal install hdevtools
+### Local `hdevtools` with `stack`
-2. Install this plugin. [pathogen.vim]()
+If your project is built with [stack]() and
+if you run Vim from the directory that contains `stack.yaml`, then
+the *vim-hdevtools* plugin can employ `stack` to automatically install
+`hdevtools` built with the same version of GHC indicated by the resolver
+in your `stack.yaml`. This will not conflict with any other installations
+of `hdevtools` on your system.
+
+If you want the *vim-hdevtools* plugin to use `stack`,
+you have to enable this feature in your `.vimrc` like so:
+
+ let g:hdevtools_stack = 1
+
+
+Installation
+------------
+
+1. Install this plugin. [pathogen.vim]()
is the recommended way:
cd ~/.vim/bundle
git clone https://github.com/bitc/vim-hdevtools.git
-3. Configure your keybindings in your `.vimrc` file. I recommend something
+2. Configure your keybindings in your `.vimrc` file. I recommend something
like:
au FileType haskell nnoremap :HdevtoolsType
- au FileType haskell nnoremap :HdevtoolsClear
+ au FileType haskell nnoremap :HdevtoolsInfo
+ au FileType haskell nnoremap :HdevtoolsClear
Features
@@ -61,6 +96,9 @@ The type for the expression under the cursor will be printed, and the
expression will be highlighted. Repeated presses will expand the expression
that is examined.
+To get information from GHC about the identifier under cursor,
+execute `HdevtoolsInfo` (or press the `` key as configured above).
+
You can execute `HdevtoolsClear` to get rid of the highlighting.
Customization
@@ -79,6 +117,12 @@ appropriate (such as your project's `Session.vim`):
Make sure that each GHC option has its own `-g` prefix (don't group multiple
options like this: `"-g-isrc\ -Wall"`)
+I recommend setting the flag to
+[defer GHC type errors to runtime](),
+so that Haskell expressions can be typechecked even if type errors
+elsewhere in the project would otherwise prevent GHC from compiling.
+
+ let g:hdevtools_options = '-g-fdefer-type-errors'
Credits
-------
diff --git a/autoload/hdevtools.vim b/autoload/hdevtools.vim
index aca1e2f..b4bcb77 100644
--- a/autoload/hdevtools.vim
+++ b/autoload/hdevtools.vim
@@ -477,9 +477,7 @@ function! s:on_leave()
endfunction
function! hdevtools#build_command(command, args)
- let l:cmd = 'hdevtools'
- let l:cmd = l:cmd . ' ' . a:command . ' '
-
+ let l:cmd = g:hdevtools_exe . ' ' . a:command . ' '
let l:cmd = l:cmd . get(g:, 'hdevtools_options', '') . ' '
let l:cmd = l:cmd . a:args
return l:cmd
@@ -487,8 +485,7 @@ endfunction
" Does not include g:hdevtools_options
function! hdevtools#build_command_bare(command, args)
- let l:cmd = 'hdevtools'
- let l:cmd = l:cmd . ' ' . a:command . ' '
+ let l:cmd = g:hdevtools_exe . ' ' . a:command . ' '
let l:cmd = l:cmd . a:args
return l:cmd
endfunction
diff --git a/ftplugin/haskell/hdevtools.vim b/ftplugin/haskell/hdevtools.vim
index 1b2f241..4ac3323 100644
--- a/ftplugin/haskell/hdevtools.vim
+++ b/ftplugin/haskell/hdevtools.vim
@@ -6,7 +6,16 @@ let b:did_ftplugin_hdevtools = 1
if !exists('s:has_hdevtools')
let s:has_hdevtools = 0
- if !executable('hdevtools')
+ " For stack support, vim must be started in the directory containing stack.yaml
+ if exists('g:hdevtools_stack') && g:hdevtools_stack && filereadable("stack.yaml")
+ if !executable('stack')
+ call hdevtools#print_error('hdevtools: stack.yaml found, but stack is not executable!')
+ finish
+ endif
+ let g:hdevtools_exe = 'stack exec --silent --no-ghc-package-path --package hdevtools hdevtools --'
+ elseif executable('hdevtools')
+ let g:hdevtools_exe = 'hdevtools'
+ else
call hdevtools#print_error('hdevtools: hdevtools is not executable!')
finish
endif