I'm using the haskellmode-vim plugin. Unfortunately it doesn't seem to work very well with cabal-dev (apparently it invokes GHC directly). Now I'm wondering if there's some way to get haskellmode to work in a project managed by cabal-dev (ideally, without a lot of project specific setup?). Searching for this I only found something pointing at ghcmod, and I'm not really sure how that'd help in this case.
Asked
Active
Viewed 199 times
1 Answers
1
I just figured this out for myself with some considerable help from #haskell
on freenode.
In your .vimrc you should have the following lines (probably already if you have hdevtools and cabal-dev setup)
Taken from http://lpaste.net/94999 original author unknown. Slightly edited here to remove a deprecation warning.
function! FindCabalSandboxRoot()
return finddir('.cabal-sandbox', './;')
endfunction
function! FindCabalSandboxRootPackageConf()
return glob(FindCabalSandboxRoot().'/*-packages.conf.d')
endfunction
let g:hdevtools_options = '-g-ilib -g-isrc -g-i. -g-idist/build/autogen -g-Wall -g-package-db='.FindCabalSandboxRootPackageConf()
The documentation of haskellmode-vim recommends the following lines in your .vimrc
:
au Bufenter *.hs compiler ghc
Reading the haskellmode-vim plugin source, the options to ghc are stored in a buffer variable called ghc_staticoptions, so now we know everything we need to know to make cabal-dev work.
au Bufenter *.hs let b:ghc_staticoptions = '-ilib -isrc -i. -idist/build/autogen -Wall -package-db='.FindCabalSandboxRootPackageConf()
However, as mentioned in this SO question haskellmode-vim is not quite dead but resting. So you may want to look into a different plugin.

Community
- 1
- 1

OmnipotentEntity
- 16,531
- 6
- 62
- 96