Skip to content

Instantly share code, notes, and snippets.

@dysinger
Last active January 16, 2021 19:30
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dysinger/63b7cd03f77ac0125356051b23f47a37 to your computer and use it in GitHub Desktop.
Save dysinger/63b7cd03f77ac0125356051b23f47a37 to your computer and use it in GitHub Desktop.
Private spacemacs layer to try out Chris Done's Intero mode for haskell
;; 1. place this in ~/.emacs.d/private/intero/packages.el
;; 2. add intero, syntax-checking and auto-completion to your
;; ~/.spacemacs layer configuration & remove the haskell layer
;; if you were using that before
;; 3. make sure you have stack installed http://haskellstack.org
;; 4. fire up emacs & open up a stack project's source files
(defconst intero-packages
'(company
flycheck
haskell-mode
hindent
(intero :location (recipe
:repo "chrisdone/intero"
:fetcher github
:files ("elisp/intero.el")))))
(defun intero/init-company-mode ()
(use-package company-mode))
(defun intero/init-hindent ()
(use-package hindent))
(defun intero/init-haskell-mode ()
(use-package haskell-mode))
(defun intero/post-init-haskell-mode ()
(add-hook 'haskell-mode-hook 'hindent-mode)
(add-hook 'haskell-mode-hook 'intero-mode))
(defun intero/init-intero ()
(use-package intero))
(defun intero/post-init-intero ()
(flycheck-add-next-checker 'intero '(warning . haskell-hlint)))
@meditans
Copy link

meditans commented Jun 2, 2016

When you issue the command C-c C-t to get the type under point, is the type message in the echo area quickly shadowed by a Wrote /path/to/file message?

EDIT: See below for (partial) solution.

@meditans
Copy link

meditans commented Jun 2, 2016

The problem I mentioned above is created when the layer syntax-checking is enabled along with the intero layer, probably because intero ships it's own version of flycheck.

For a quick patch, one could remove the syntax-checking layer from .spacemacs, or disabling it locally via SPC t s. This last option has the unwanted consequence of disabling the features of flycheck that are shipped with intero.

@rybern
Copy link

rybern commented Jun 2, 2016

I put this file in my .emacs.d/private/intero folder, added the new layers and removed haskell, and removed a hook to haskell-mode. When I try opening a stack source file, intero is built and then a buffer containing the following pops up:

**Usage: stack ghci [TARGET] [--ghc-options OPTION] [--with-ghc GHC] [--no-load]
[--package ARG] [--main-is TARGET]
Run ghci in the context of project(s) (experimental)


This is the buffer where Emacs talks to intero. It's normally hidden,
but a problem occcured.

It may be obvious if there is some text above this message
indicating a problem.

The process ended. Here is the reason that Emacs gives us:

exited abnormally with code 1

For troubleshooting purposes, here are the arguments used to launch intero:

stack ghci --with-ghc intero --docker-run-args=--interactive=true --tty=false --no-load --no-build --ghci-options "-odir=/tmp/intero368i4W" --ghci-options "-hidir=/tmp/intero368i4W" curses-irc-reader

After fixing this problem, you could switch back to your code and
run M-x intero-restart to try again.

You can kill this buffer when you're done reading it.**

I tried running the given stack command from the shell, and got the same "Usage" error. It looks like the stack command arguments are somehow incorrect.

Am I doing something wrong?

@gregwebs
Copy link

gregwebs commented Jun 3, 2016

@rybern are you running the latest version of stack?

@meditans I am running into the same problem. I certainly don't want to disable the amazing fly checking as I type feature. Let me know if you come up with any work-arounds

@polux
Copy link

polux commented Jun 3, 2016

@gregwebs if you remove it from the layers in your .spacemacs it doesn't seem to disable it (and I suppose that's because intero ships with its own flycheckin or something like that). But it will disable flycheck for other languages.

@TimoFreiberg
Copy link

Worked well for me, but the intero repl behaved like a pure text buffer instead of a command-line - maybe the shell-mode was not enabled?

@chrisdone
Copy link

chrisdone commented Jun 6, 2016

@gregwebs @meditans I merged in a patch which gets rid of the "Wrote buffer .." message: chrisdone-archive/intero#54

@magthe
Copy link

magthe commented Jun 6, 2016

I'm guessing this on first start after activating this:

Compiling file /home/magnus/.emacs.d/elpa/intero-20160606.926/intero.el at Mon Jun  6 09:56:19 2016
intero.el:50:1:Error: Cannot open load file: no such file or directory, flycheck

Emacs 24.5 on Arch Linux, and the syntax-checking layer is activated.

@agrafix
Copy link

agrafix commented Jun 7, 2016

@magthe yeah, I got the same error

@gregwebs
Copy link

gregwebs commented Jun 8, 2016

@chrisdone thanks, that patch works! I just had to go into the elpa package list and update intero.

@Tehnix
Copy link

Tehnix commented Jun 14, 2016

Any thoughts on what keybindings this could run under? Perhaps SPC m .. like the current haskell layer uses, since it's not meant to be mixed?

@abailly
Copy link

abailly commented Jun 6, 2017

I am trying to expand on this layer to add keybindings that are consistent with other spacemacs layers, e.g. using SPC m as leader key and mapping other commands with mnemonic but I cannot it work even with the simplest example:

(defun intero/init-intero ()
  (use-package intero
    :config
    (progn
      (spacemacs/set-leader-keys-for-major-mode 'intero-mode "ml" 'intero-repl-load))
    ))

I am a total noob with spacemacs... Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment