[Haskell-cafe] Correctly setting up emacs + ghc-mod
Andras Slemmer
0slemi0 at gmail.com
Sat Apr 19 11:05:42 UTC 2014
If you're using several source directories then simply specify them in your
.cabal with hs-source-dirs. So for example if you have a library in src/lib
and a test-suite in src/test and your tests use your lib then you'd have
something like this in your .cabal
library
exposed-modules: Lib
hs-source-dirs: src/lib
test-suite sometest
type: exitcode-stdio-1.0
main-is: Test.hs
hs-source-dirs: src/test src/lib
On 18 April 2014 16:20, Arnaud Bailly <arnaud.oqube at gmail.com> wrote:
> Hello,
>
> I am struggling to get my emacs settings right for doing significant
> Haskell development, eg. something more involved than a bunch of source
> files in a single directory. The issue I am running in currently is that
> when trying to load files in the interpreter, most source paths are missing
> which means loading inevitably fails. This is especially annoying with
> tests: To get things working correctly I need to explicitly add in the
> console
>
> > :set -iwhere/my/src/are
>
> Is there any configuration I should be aware of in my cabal files or
> .emacs file that would correctly set the source roots? Am I missing
> something?
>
> Here is my .emacs configuration. Thanks for any help.
>
> ;; haskell coding
>
>
> (require 'auto-complete)
> (require 'haskell-mode)
> (require 'haskell-cabal)
>
> (autoload 'ghc-init "ghc" nil t)
>
> (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
>
> (eval-after-load "haskell-mode"
> '(progn
> (setq haskell-stylish-on-save t)
> (setq haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans"
> "--with-ghc=ghci-ng"))
>
> (define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left)
> (define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right)
> (define-key haskell-mode-map (kbd "C-c v c")
> 'haskell-cabal-visit-file)
> (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-compile)
> (define-key haskell-mode-map (kbd "C-x C-d") nil)
> (setq haskell-font-lock-symbols t)
>
> ;; Do this to get a variable in scope
>
>
> (auto-complete-mode)
>
> ;; from http://pastebin.com/tJyyEBAS
>
>
> (ac-define-source ghc-mod
> '((depends ghc)
> (candidates . (ghc-select-completion-symbol))
> (symbol . "s")
> (cache)))
>
> (defun my-ac-haskell-mode ()
> (setq ac-sources '(ac-source-words-in-same-mode-buffers
> ac-source-dictionary
> ac-source-ghc-mod)))
> (add-hook 'haskell-mode-hook 'my-ac-haskell-mode)
>
>
> (defun my-haskell-ac-init ()
> (when (member (file-name-extension buffer-file-name) '("hs" "lhs"))
> (auto-complete-mode t)
> (setq ac-sources '(ac-source-words-in-same-mode-buffers
> ac-source-dictionary
> ac-source-ghc-mod))))
> (add-hook 'find-file-hook 'my-haskell-ac-init)))
>
> (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
> (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
>
> (eval-after-load "which-func"
> '(add-to-list 'which-func-modes 'haskell-mode))
>
> (eval-after-load "haskell-cabal"
> '(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-compile))
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140419/b5de33b1/attachment-0001.html>
More information about the Haskell-Cafe
mailing list