Skip to content

Latest commit

 

History

History
227 lines (146 loc) · 7.1 KB

README.md

File metadata and controls

227 lines (146 loc) · 7.1 KB

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 hoogle) 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

To install HIE

git clone https://github.com/haskell/haskell-ide-engine
cd haskell-ide-engine
stack install

Installation using Nix

Alternatively, given that you have Nix installed:

$ stack install --nix

Using HIE with vscode

Make sure HIE is installed (see above) and directory stack put the hie binary in is in your path (usually ~/.local/bin on linux)

git clone https://github.com/alanz/vscode-hie-server
cd vscode-hie-server
npm install .

Open vscode-hie-server/ in Visual Studio Code and press F5 to open a new window with the extension loaded.

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', { 'do': ':UpdateRemotePlugins' }

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.

Hoogle Docs on hover

HIE supports fetching docs from hoogle on hover. It can use the Hoogle database for your user, or a project specific database.

To generate a global hoogle database for your user from hackage, run

$ hoogle generate

To generate a project specific database for a stack project, run

$ stack hoogle
$ stack build

To generate a project specific database for a sandboxed cabal project, run

$ cabal install --enable-documentation --haddock-hoogle
$ hoogle generate --database=hiehoogledb.hoo --local=.

in the root dir of your cabal project

If you don't have the dependencies built with haddock/documentation enabled, you need to remove the sandbox and build everything again before running the commands given above

$ cabal sandbox delete
$ cabal sandbox init

To generate a project specific database for a non-sandboxed cabal project, run

$ cabal install
$ hoogle generate --local --database=hiehoogledb.hoo

If HIE detects a project specific hoogle DB, it will use it over the global db.

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.