Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Sublime Text 2/3 plugin for Haskell. Features cabal building, error and warning highlighting, smart completion and ghc-mod integration.
Python Haskell JavaScript
Failed to load latest commit information.
Commands Restructured a bit.
Completions Restructured a bit.
Keymaps Restructured a bit.
Menus Restructured a bit.
Settings Restructured a bit.
Snippets Added Double import snippet
Syntaxes Merge github.com:wrossmck/literate-haskell-bird-style into feature/li…
.gitignore Showing messages with show_sublime_message_process
.hgignore Ignore Sublime files.
.no-sublime-package Unzip this package
CabalInspector.hs CabalInspector: collect info about tests
Cubicle.tmTheme Leave theme in the toplevel.
LICENSE.txt Renamed the license file, which was inexplicably called README.
Makefile Add Makefile with check target to be run before commits
ModuleInspector.hs Ignore docs for pictures (fixes build with haddock 2.14)
README.md README: Update tags section
TODO.txt Fixed TODO, removed logs
autobuild.py Revert "autobuild: Guard against view.window() being None. Affects #140"
autocomplete.py fixing missing quick panel 'Select imported module' by calling sublim…
cabalbuild.py Fixed #110
cache.py New setting 'cache_path' to override the default path used for the Ca…
fix_syntax.py Forgot the comment.
ghci.py Fixed browse module for module in sources, catching OSError in hdevto…
ghcmod.py Fix for #144
haskell_docs.py Migrated to Sublime Text 3
haskell_type.py README: described hotkeys for next/prev errors; Fixed insert type com…
hdevtools.py Fix some whitespace
hdocs.py Checking if hdevtools enabled
hsdev.py Fixed setting declaration locations
parseoutput.py Strip \r from output messages, if applicable
stylishhaskell.py fixed a typo in error message
sublime_haskell_common.py fix ghc-mod command
symbols.py fixed 'object has no attribute by_source/by_cabal' issues
util.py Go to declaration: allow qualified decl in current module

README.md

README

Requirements

Necessary:

  • ghc and a recent Haskell Platform (>= 2012 should do fine)
  • cabal
  • Cabal packages: base, bytestring, aeson, haskell-src-exts (== 1.14.*), haddock (cabal install aeson haskell-src-exts haddock)
  • If you are using GHC 7.6, you might have trouble with too new versions of haddock; in that case, try cabal install haddock --constraint=haddock==2.13.2.1

Optional, but useful:

  • ghc-mod (for import and LANGUAGE completions and type inference, cabal install ghc-mod)
  • stylish-haskell (for code prettification, cabal install stylish-haskell)
  • cabal-dev if you want to use it
  • haskell-docs (for documentation in 'Symbol info' command, cabal install haskell-docs)
  • hdevtools (or fork for windows) (for type inference, cabal install hdevtools)

Binaries:

  • If your cabal, ghc-mod, ghc etc. are not installed in a system PATH, you have to adjust SublimeHaskell's add_to_PATH setting.

Installation

  1. Get Sublime Text 2: http://www.sublimetext.com/
  2. Install the Sublime Package Control package: http://wbond.net/sublime_packages/package_control/installation
  3. Use Package Control to install this package (SublimeHaskell)

Usage

In short: Press Shift-Ctrl-P and type haskell to explore all commands.

When editing Haskell source files that are part of a Cabal project, automatic error highlighting and enhanced auto-completion are available.

Each time you save, any errors in your program will be listed at the bottom of the window and highlighted in the source code.

All source files in the project are scanned when the change. Any symbols that they export are provided in the auto-complete suggestions.

To use cabal-dev instead of cabal, set use_cabal_dev to true (or use command "Switch Cabal/Cabal-Dev") and specify cabal-dev absolute path. Completion list will be rescanned and build will use cabal-dev.

Stylish-haskell can be used to stylish file or selected text.

Use Ctrl-Shift-R to go to declaration and Ctrl-K-I to show symbol info with documentation. These command are also available through context menu with right-click.

Command 'SublimeHaskell: Browse module' is similar to ghci's browse command

To show inferred types use Show type (ctrl-k ctrl-h ctrl-t) command.

To insert inferred type use Insert type (ctrl-k ctrl-h ctrl-i).

You can jump between the errors and warnings with F4 and Shift-F4. To show hidden error output, use command Show error panel (ctrl-alt-e)

Build Systems

You don't have to use SublimeHaskell's built-in build functionality.

If you prefer, you can disable them in the settings, and use plain Sublime Build Systems:

cabal

Save this to your ~/.config/sublime-text-2/Packages/User/cabal-custom.sublime-build to make a custom cabal build system:

{
  "cmd": ["cabal build --ghc-options='-O0 -hidir o0 -odir o0'"],  // append lib:myPackage or myexecutable here to only build certain cabal targets
  "shell": true,
  "file_regex": "^(\\S*?):(\\d+):(\\d+):$"  // this matches the output of ghc
}

For more options, look here.

hdevtools

Save this to your ~/.config/sublime-text-2/Packages/User/hdevtools.sublime-build to make hdevtools a build system:

{
  "cmd": ["/home/USERNAME/.cabal/bin/hdevtools", "check", "-g", "-Wall", "$file"],
  "file_regex": "^(.*?):(\\d+):(\\d+):",
  "selector": "source.haskell"
}

Using build system results

You can then build with Ctrl-B and jump between the errors with (Shift-)F4.

It is also useful to add this to your key bindings to redisplay the error panel at any time:

  { "keys": ["ctrl+alt+b"], "command": "show_panel", "args": {"panel": "output.exec"} }

Using other useful projects with SublimeText

Jump-to-definition

There are two kinds of jump-to-definition: Inside your project and outside your project. In any case, install the Sublime CTags package via Package Control, and cabal install hasktags.

CTags expects the extended exuberant ctags format.

Inside your project: hasktags

  • In your project, hasktags --ctags --extendedctag .
  • You can now jump to definitions inside your project (Ctrl-T, Ctrl-T is the default keybinding)

Inside and outside your project: codex

codex allows you to use ctags to jump to definitions that are declared in your cabal dependencies.

  • cabal install codex
  • Run codex set format sublime, that updates your ~/.codex file to Sublime's Ctags plugin's format
  • Change ~/.codex to tagsFileName: .tags
  • In your project, codex cache clean && codex update
  • You can now jump to the source code of definitions outside of your project.
  • The commands CTags: Show Symbols and CTags: Rebuild Tags currently don't work with codex

If the ModuleInspector takes too much time

The ModuleInspector is a program that looks at your Haskell environment to provide auto completion.

Depending on your environment, this may take very long.

You can disable it with the "inspect_modules": false setting.

Something went wrong with that request. Please try again.