Skip to content

colonelpanic8/haskell-ide-engine

 
 

Repository files navigation

Haskell IDE Engine

License BSD3

This project aims to be the universal interface to a growing number of Haskell tools, providing a full-featured and easy to query backend for editors and IDEs that require Haskell-specific functionality.

We are currently focusing on using the Language Server Protocol as the interface via which we talk to clients.

Features

  • Supports plain GHC projects, cabal projects(sandboxed and non sandboxed) and stack projects

  • Fast due to caching of compile info

  • Uses LSP, so should be easy to integrate with a wide selection of editors

  • Diagnostics via hlint and GHC warnings/errors

    Diagnostics

  • Code actions and quick fixes via apply-refact

    Apply Refact

  • Type information and documentation(via haddock) on hover

    Hover

  • Jump to definition

    Find Def

  • List all top level definitions

    Doc Symbols

  • Highlight references in document

    Doc Highlight

  • Completion

    Completion

  • Formatting via brittany

    Formatting

  • Renaming via HaRe

    Renaming

Installation

Note: The version on branch hie-0.1.0.0 supports GHC 8.0.2. This is not supported in master.

On linux derivatives you will need to do the equivalent of before building

sudo apt install libicu-dev libtinfo-dev

Getting the source for GHC 8.2.1, 8.2.2, 8.4.2

HIE builds from source code, so first,

$ git clone https://github.com/haskell/haskell-ide-engine --recursive
$ cd haskell-ide-engine

Getting the source for GHC 8.0.2

HIE builds from source code, so first,

$ git clone https://github.com/haskell/haskell-ide-engine
$ cd haskell-ide-engine
$ git checkout hie-0.1.0.0
$ git submodule update --init

Installation with stack

To install HIE, you need Stack version >= 1.7.1

To install all supported GHC versions, and name them as expected by the vscode plugin, and also build a local hoogle database, do

make build-all

Then add

"languageServerHaskell.useHieWrapper": true

to VSCode user settings.

Otherwise, do one of the following.

For GHC 8.4.2

Using master

stack install

For GHC 8.2.2

Using master

stack --stack-yaml=stack-8.2.2.yaml install

Using branch hie-0.1.0.0

stack install

For GHC 8.2.1

stack --stack-yaml=stack-8.2.1.yaml install

For GHC 8.0.2 (only via branch hie-0.1.0.0)

stack --stack-yaml=stack-8.0.2.yaml install

Installation on Windows

In order to avoid problems with long paths you can do the following:

  1. Edit the group policy: set "Enable Win32 long paths" to "Enabled". Works only for Windows 10

  2. Clone the haskell-ide-engine to the root of your logical drive (e.g. to E:\hie)

Installation with Nix

Follow the instructions at https://github.com/domenkozar/hie-nix

ArchLinux

An haskell-ide-engine-git package is available on the AUR.

Using Aura:

# aura -A haskell-ide-engine-git

Editor Integration

All of the editor integrations assume that you have already installed HIE (see above) and that stack put the hie binary in your path (usually ~/.local/bin on linux and macOS).

Using HIE with VS Code

Install from the VSCode marketplace, or manually from the repository vscode-hie-server.

Using HIE with Sublime Text

  • Make sure HIE is installed (see above) and that the directory stack put the hie binary in is in your path
    • (usually ~/.local/bin on unix)
  • Install LSP using Package Control
  • From Sublime Text, press Command+Shift+P and search for Preferences: LSP Settings
  • Paste in these settings. Make sure to change the command path to your hie
"clients": {
  "haskell-ide-engine": {
    "command": ["hie", "--lsp"],
    "scopes": ["source.haskell"],
    "syntaxes": ["Packages/Haskell/Haskell.sublime-syntax"],
    "languageId": "haskell",
  },
},

Now open a haskell project with Sublime Text. You should have these features available to you:

  1. Errors are underlined in red
  2. LSP: Show Diagnostics will show a list of hints and errors
  3. LSP: Format Document will prettify the file

Using HIE with Neovim

As above, make sure HIE is installed. Install and load the neovim plugin LanguageClient. If you use vim-plug, then you can do this by e.g. including the following line in the Plug section of your init.vim:

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': './install.sh'
    \ }

and issuing a :PlugInstall command within neovim.

Finally, make sure that hie is included as the language server source for haskell:

let g:LanguageClient_serverCommands = {
    ...
    \ 'haskell': ['hie', '--lsp'],
    ...
    \ }

For asynchronous auto-completion, follow the setup instructions on LanguageClient.

Using HIE with Atom

Make sure HIE is installed, then install the two Atom packages atom-ide-ui and ide-haskell-hie,

$ apm install language-haskell atom-ide-ui ide-haskell-hie

Using HIE with Emacs

Install HIE along with the following emacs packages:

lsp-mode lsp-ui lsp-haskell

Make sure to follow the instructions in the README of each of these packages.

Docs on hover/completion

HIE supports fetching docs from haddock on hover. It will fallback on using a hoogle db(generally located in ~/.hoogle on linux) if no haddock documentation is found.

To generate haddock documentation for stack projects:

$ cd your-project-directory
$ stack haddock --keep-going

To enable documentation generation for cabal projects, add the following to your ~/.cabal/config

documentation: True

To generate a hoogle database that hie can use

$ cd haskell-ide-engine
$ stack --stack-yaml=<stack.yaml you used to build hie> exec hoogle generate

Contributing

Planned Features

  • Multiproject support
  • Project wide references
  • Cross project find definition
  • New-build support
  • HaRe refactorings
  • More code actions
  • Cross project/dependency Find Definition
  • Case splitting, type insertion etc.

This is not yet another ghc-mod or ide-backend project

Both the ghc-mod and ide-backend maintainers have agreed to contribute code to this new repository and then rebase the old repos on this. The reason we're using a new repo instead of modifying one of the existing ones is so that the existing projects experience no disruption during this migration process. If this was a new set of people starting a new project without support from existing projects, I'd agree with you. But Alan's reached out to existing players already, which is an important distinction.

This project is not started from scratch:

  1. See why we should supersede previous tools
  2. Check the list of existing tools and functionality
  3. See more other tools and IDEs for inspiration

It's time to join the project!

❤️ Haskell tooling dream is near, we need your help! ❤️

Development

Apart from stack you need cask for the emacs tests. You can install it using

curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python

Architecture

Below you find a short overview of the main architectural layers of haskell-ide-engine. For more info have a look in the docs folder at the root of this project, especially:

1. BIOS layer

ghc-mod stays an AGPL project, and is used for its "awesome sauce" in terms of the BIOS functions that it does so well. This interface is straightforward to use, and if a license-constrained user wants to do something else it is also easy to replace, if there is strong control of the operating environment.

2. Plugin layer

A layer providing a point to integrate tools and existing functions, probably including ghci.

3. IDE interfacing layer

The focus is currently on LSP as the protocol we use to interface with IDEs.

Existing transports are still functional for the time being.

Documentation

All the documentation is in the docs folder at the root of this project.

About

The engine for haskell ide-integration. Not an IDE

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haskell 99.0%
  • Makefile 1.0%