Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Frontend

Andy Morris edited this page Jan 26, 2017 · 9 revisions

Frontend specific installation instructions

Emacs (native frontend)

Using the stable version

The Emacs front-end is available from stable MELPA. The stable version should always be compatible with the latest version of ghc-mod from hackage which is not true for plain MELPA!

You can also use a git checkout of the ghc-mod source repository as your source for the Elisp code if you prefer.

With ELPA

To use stable MELPA add this to your .emacs:

(require 'package)
(add-to-list 'package-archives
	     '("melpa" . "http://melpa-stable.milkbox.net/packages/"))
(package-initialize)

(add-hook 'haskell-mode-hook (lambda () (ghc-init)))

(See also http://www.emacswiki.org/emacs/ELPA)

With this configuration you can install the Emacs front using:

M-x package-refresh-contents RET
M-x package-install RET ghc RET

Note: the ELPA package is called ghc, not ghc-mod

Without ELPA

To install the ghc-mod Emacs frontend without ELPA you need to obtain the ghc-mod source code either through git or via a tarball and then add this to your .emacs:

(add-to-list 'load-path "<wherever>/ghc-mod/elisp")
(setq ghc-debug t) ; enable debug logging
(autoload 'ghc-init "ghc" nil t)
(autoload 'ghc-debug "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda () (ghc-init)))

You'll have to replace <wherever> by the location you chose to put the ghc-mod source directory in.

Make sure the source matches the version of the ghc-mod executables you installed otherwise you will run into all sorts of trouble.

You can check this by looking at the ghc-version variable:

M-x describe-variable RET ghc-version RET

This value should match the output of the following command:

$ ghc-mod --version

Vim (ghcmod-vim)

Since Vim didn't have a built-in package manager until version 8, there are numerous external ones written by members of the community. One of the newer ones is vim-plug, which the rest of this section will use. The most relevant features for this guide are that it can install packages straight from Git repositories, and can run a shell command such as make whenever a certain package is updated. Since vim-plug is more convenient, it is suggested to use it even with Vim 8.

Install vim-plug by putting a single file, plug.vim, into Vim's auto-load directory (~/.vim/autoload for normal Vim, or ~/.config/nvim/autoload for NeoVim).

Most features of ghc-mod are provided by the plugin ghcmod-vim. Name completion is handled by a separate package, neco-ghc, which provides support for Vim's built-in omni completion, and also Just Works with neocomplete or deoplete (deoplete is faster, but only works with NeoVim). If you decide to use neocomplete, then it depends on [vimproc] to load completions asynchronously.

An example .vimrc using vim-plug and neocomplete:

call plug#begin('~/.vim/plugged')

Plug 'eagletmt/ghcmod-vim', {'for': 'haskell'}
Plug 'Shougo/vimproc.vim', {'do': 'make'}
Plug 'Shougo/neocomplete.vim', {'for': 'haskell'}
Plug 'eagletmt/neco-ghc', {'for': 'haskell'}

call plug#end()

" Use neco-ghc for completion
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc

After editing, make Vim reread the file with :source %, and then install the plugins with :PlugInstall. You can update the plugins periodically with :PlugUpdate.

Atom (ide-haskell+haskell-ghc-mod)

To use ghc-mod with Atom you should install ide-haskell and the companion haskell-ghc-mod. Installation instructions can be found here: https://github.com/atom-haskell/ide-haskell.

Clone this wiki locally