This extension adds language support for Haskell, powered by the Haskell Language Server.
As almost all features are provided by the server you might find interesting read its documentation.
You can watch demos for some of these features here.
- Warning and error diagnostics from GHC
- Type information and documentation on hover, including your own comments.
- Jump to definition: for now only for local code definitions
- Document symbols
- Highlight references in document
- Code completion
- Show documentation and sources in hackage
- Formatting via Brittany, Floskell, Fourmolu, Ormolu or Stylish Haskell
- Multi-root workspace support
- Code evaluation, see its Tutorial
- Integration with retrie, a powerful, easy-to-use codemodding tool
- Code lenses for explicit import lists
- Generate functions from type signatures, and intelligently complete holes using Wingman (tactics)
- Integration with hlint, the most used haskell linter, to show diagnostics and apply hints via apply-refact
- Module name suggestions for insertion or correction
- Call hierarchy support
- For standalone
.hs
/.lhs
files, ghc must be installed and on the PATH. The easiest way to install it is with ghcup or Chocolatey on Windows. - For Cabal based projects, both ghc and cabal-install must be installed and on the PATH. It can also be installed with ghcup or Chocolatey on Windows.
- For Stack based projects, stack must be installed and on the PATH.
- If you are installing from an offline VSIX file, you need to install language-haskell too after installation (either from the marketplace or offline).
For a general picture about the server configuration, including the project setup, you can consult the server documentation about the topic.
If your server is manually installed and not on your path, you can also manually set the path to the executable.
"haskell.serverExecutablePath": "~/.local/bin/haskell-language-server"
There are a few placeholders which will be expanded:
~
,${HOME}
and${home}
will be expanded into your users' home folder.${workspaceFolder}
and${workspaceRoot}
will expand into your current project root.
The option has resource
scope so it can be changed per workspace.
This supposes it could be used to execute arbitrary programs adding a .vscode/settings.json
in the workspace folder including this option with the appropiate path.
For this reason its scope will be changed to machine
so users only will be able to change it globally.
See #387 for more details.
This extension will download haskell-language-server
binaries to a specific location depending on your system. If you find yourself running out of disk space, you can try deleting old versions of language servers in this directory. The extension will redownload them, no strings attached.
Platform | Path |
---|---|
macOS | ~/Library/Application\ Support/Code/User/globalStorage/haskell.haskell/ |
Windows | %APPDATA%\Code\User\globalStorage\haskell.haskell |
Linux | $HOME/.config/Code/User/globalStorage/haskell.haskell |
Note that if haskell-language-server-wrapper
/haskell-language-server
is already on the PATH, then the extension will launch it directly instead of downloading binaries.
These are the versions of GHC that there are binaries of haskell-language-server
for. Building from source may support more versions!
GHC | Linux | macOS | Windows |
---|---|---|---|
9.0.1 (limited) | ✓ | ✓ | ✓ |
8.10.7 | ✓ | ✓ | ✓ |
8.10.6 | ✓ | ✓ | ✓ |
8.10.5 | ✓ | ✓ | ✓ |
8.10.4 | ✓ | ✓ | ✓ |
8.10.3 | ✓ | ✓ | ✓ |
8.10.2 | ✓ | ✓ | ✓ |
8.8.4 | ✓ | ✓ | ✓ |
8.8.3 | ✓ | ✓ | |
8.6.5 | ✓ | ✓ | ✓ |
8.6.4 | ✓ | ✓ | ✓ |
The exact list of binaries can be checked in the last release of haskell-language-server: https://github.com/haskell/haskell-language-server/releases/latest
You can check the current GHC versions support status and the policy followed for deprecations here.
First, check out what multi-root workspaces are. The idea of using multi-root workspaces, is to be able to work on several different Haskell projects, where the GHC version or stackage LTS could differ, and have it work smoothly.
The language server is now started for each workspace folder you have in your multi-root workspace, and several configurations are on a resource (i.e. folder) scope, instead of window (i.e. global) scope.
- Go to extensions and right click
Haskell Language Server
and chooseExtensions Settings
- Scroll down to
Haskell › Trace: Server
and set it tomessages
- Set
Haskell › Trace: Client
todebug
- Restart vscode and reproduce your problem
- Go to the main menu and choose
View -> Output
(Ctrl + Shift + U
) - On the new Output panel that opens on the right side in the drop down menu choose
Haskell (<your project>)
Please include the output when filing any issues on the haskell-language-server issue tracker.
- Sometimes the language server might get stuck in a rut and stop responding to your latest changes. Should this occur you can try restarting the language server with Ctrl shift P/⌘ shift P > Restart Haskell LSP Server.
- Usually the error or unexpected behaviour is already reported in the haskell language server issue tracker. Finding the issue could be useful to help resolve it and sometimes includes a workaround for the issue.
If you want to help, get started by reading Contributing for more details.
See the Changelog for more details.