IntelliJ plugin for Haskell
Go to file
Rik van der Kleij 5269de3ed3 Fix issue #496
2020-02-15 17:04:11 +01:00
docs Add slides talk A'dam Haskell meetup. 2019-09-23 15:22:10 +02:00
gen/intellij/haskell Improve parser. 2020-02-09 17:27:41 +01:00
intellij-haskell Set since-build 2020-02-12 19:32:36 +01:00
logo Add plugin logo 2016-12-29 15:43:02 +08:00
project Update sbt idea plugin 2019-12-22 18:46:52 +01:00
src Fix issue #496 2020-02-15 17:04:11 +01:00
.gitignore Ignore all jflex jars. 2019-04-04 12:50:07 +02:00
build.sbt Bump version. 2020-02-09 20:07:38 +01:00
CONTRIBUTING.md Update CONTRIBUTING.md 2020-01-30 20:22:14 +01:00
LICENSE 2018 -> 2019 2019-06-02 21:27:41 +02:00
README.md Fix README 2020-01-01 15:22:42 +01:00

logo IntelliJ plugin for Haskell

Join the chat at https://gitter.im/intellij-haskell/Lobby

When I was learning Haskell, I missed the nice features of IntelliJ IDEA. My first approach was to use default way of creating an IntelliJ plugin by defining a grammar and a lexer according to Haskell report. That didn't work out because I could not define all the recursion. Then I decided to use grammar and lexer definitions only for tokenizing and parsing Haskell code, and not for syntax checking the code. This is needed for syntax highlighting, all kinds of navigation and so on. Further Haskell language support is provided with the help of external tools.

This plugin depends mainly on Stack. It can create new Stack projects and import existing Stack projects.

GHC 8.2 and later is supported.

Any feedback is welcomed!!

Installing the plugin

You can install this plugin using the Jetbrains plugin repository: Settings/Plugins/Browse repositories/Intellij-Haskell

Installing latest beta of the plugin

To try out the latest beta version one can install the plugin by adding https://plugins.jetbrains.com/plugins/alpha/8258 as Custom plugin repository in Settings/Plugins/Browse repositories/Manage repositories.

Alternative way to install the latest beta version is to download intellij-haskell.zip from releases and apply Install plugin from disk in Settings/Plugins.

Features

  • Syntax highlighting;
  • Error/warning highlighting;
  • Haskell Problems View. This tool window displays GHC messages for the currently edited files;
  • Find usages of identifiers;
  • Resolve references to identifiers;
  • Code completion;
  • In-place rename identifiers;
  • View type info from (selected) expression;
  • View sticky type info;
  • View expression info;
  • View quick documentation;
  • View quick definition;
  • Structure view;
  • Goto to declaration (called Navigate>Declaration in IntelliJ menu);
  • Navigate to declaration (called Navigate>Class in IntelliJ menu);
  • Navigate to identifier (called Navigate>Symbol in IntelliJ menu);
  • Goto instance declaration (called Navigate>Instance Declaration in IntelliJ menu);
  • Navigate to declaration or identifier powered by Hoogle (called Navigate>Navigation by Hoogle in IntelliJ menu);
  • Inspection by HLint;
  • Quick fixes for HLint suggestions;
  • Show error action to view formatted message. Useful in case message consists of multiple lines (Ctrl-F10, Meta-F10 on Mac OSX);
  • Intention actions to add language extension (depends on compiler error), add top-level type signature (depends on compiler warning);
  • Intention action to select which module to import if identifier is not in scope;
  • Code formatting with hindent, stylish-haskell, or both together. hindent can also be used to format a selected code block.
  • Code completion for project module names, language extensions and package names in Cabal file;
  • Running REPL, tests and executables via Run Configurations;
  • Smart completion on typed holes (since GHC 8.4);

Usage with hindent

When used with hindent, intellij-haskell automatically sets --indent-size as a command-line option in hindent from the Indent option in your project code style settings. It also automatically sets the --line-length command-line option from your Hard wrap at code style setting. This means that any .hindent.yaml files used for configuration will have these options overridden and may not fully work.

Getting started

  • If you don't already have IntelliJ, download it - the Community Edition is sufficient.
  • Install this plugin using the Jetbrains plugin repository: Settings/Plugins/Browse repositories/Intellij-Haskell. Make sure no other Haskell plugin is installed in IntelliJ;
  • Install latest version of Stack; use stack upgrade to confirm you are on the latest version.
  • Setup the project:
    • Make sure your Stack project builds without errors. Preferably by using: stack build --test --haddock --no-haddock-hyperlink-source;
    • After your project is built successfully, import an existing project by:
      • Inside IntelliJ use File>New>Project from Existing Sources... from the IntelliJ menu;
      • In the Welcome to IntelliJ IDEA dialog use Import Project;
    • In the New Project wizard select Import project from external model and check Haskell Stack;
    • In next page of wizard configure Project SDK by configuring Haskell Tool Stack with selecting path to stack binary, e.g. /usr/local/bin/stack;
    • Finish wizard and project will be opened;
    • Wizard will automatically configure which folders are sources, test and which to exclude;
    • Plugin will automatically build Haskell Tools (HLint, Hoogle, Hindent and Stylish Haskell) to prevent incompatibility issues
    • Check Project structure>Project settings>Modules which folders to exclude (like .stack-work and dist) and which folders are Source and Test (normally src and test);
    • Plugin will automatically download library sources. They will be added as source libraries to module(s).
    • After changing the Cabal file and/or stack.yaml use Haskell>Haskell>Update Settings and Restart REPLs to download missing library sources and update the project settings;
    • The Event Log will display what's going on in the background. Useful when something fails. It's disabled by default. It can be enabled by checking Haskell Log checkbox in the Event Log>Settings or Settings>Appearance & Behavior>Notifications;

Remarks

  1. IntelliJ's Build action is not (yet) implemented. Project is built when project is opened and when needed, e.g. library code is changed and user navigates to test code;
  2. About Haskell Project in Help menu shows which Haskell GHC/tools are used by plugin for project;
  3. GHC depends on libtinfo-dev. On Ubuntu you can install it with sudo apt-get install libtinfo-dev;
  4. Haskell tools depends on libgmp3-dev zlib1g-dev. On Ubuntu you can install them with sudo apt-get install libgmp3-dev zlib1g-dev;
  5. Cabal's internal libraries are not (yet) supported;
  6. Cabal's common stanzas are not (yet) supported;
  7. The Haskell tools are built in a IntelliJ sandbox with LTS-13. So they have no dependency with Stackage resolvers in your projects. After Stackage LTS-13 minor updates one can use Haskell>Update Haskell tools;
  8. Stack REPLs are running in the background. You can restart them by Haskell>Update Settings and Restart REPLs.

If you want to contribute to this project, read the contributing guideline.