haskell-lsp

A Claude Code plugin providing comprehensive Haskell development support through:
- haskell-language-server (HLS) integration for IDE-like features
- Automated hooks for formatting, linting, and code quality
- Haskell toolchain integration (hlint, ormolu/fourmolu, cabal/stack)
Quick Setup
# Run the setup command (after installing the plugin)
/setup
Or manually:
# Install GHC and cabal via ghcup (recommended)
ghcup install ghc latest
ghcup install cabal latest
ghcup install hls latest
# Install development tools
cabal install hlint
cabal install ormolu
# Or alternatively: cabal install fourmolu
Features
LSP Integration
The plugin configures haskell-language-server for Claude Code via .lsp.json:
{
"haskell": {
"command": "haskell-language-server-wrapper",
"args": ["--lsp"],
"extensionToLanguage": {
".hs": "haskell",
".lhs": "haskell"
},
"transport": "stdio"
}
}
Capabilities:
- Go to definition / references
- Hover documentation with type information
- Code actions and refactoring
- Workspace symbol search
- Real-time type checking and diagnostics
- Import management
Automated Hooks
All hooks run afterWrite and are configured in hooks/hooks.json.
Core Haskell Hooks
| Hook | Trigger | Description |
|---|
haskell-format-on-edit | **/*.hs | Auto-format with ormolu or fourmolu |
haskell-lint-on-edit | **/*.hs | Lint with hlint |
haskell-build-check | **/*.hs | Compile check with cabal/stack |
haskell-todo-fixme | **/*.hs | Surface TODO/FIXME comments |
Quality & Documentation
| Hook | Trigger | Description |
|---|
haskell-haddock-check | **/src/**/*.hs | Check Haddock documentation |
haskell-warnings | **/*.hs | Show GHC warnings |
Required Tools
Core
| Tool | Installation | Purpose |
|---|
ghcup | ghcup.haskell.org | Haskell toolchain manager |
ghc | ghcup install ghc | Haskell compiler |
cabal | ghcup install cabal | Build tool and package manager |
haskell-language-server | ghcup install hls | LSP server |
Recommended
| Tool | Installation | Purpose |
|---|
hlint | cabal install hlint | Linting and suggestions |
ormolu | cabal install ormolu | Code formatter (opinionated) |
fourmolu | cabal install fourmolu | Code formatter (configurable) |
stack | ghcup install stack | Alternative build tool |
Commands
/setup
Interactive setup wizard for configuring the complete Haskell development environment.
What it does:
- Checks for ghcup - Ensures ghcup is installed
- Installs GHC - Latest stable compiler
- Installs cabal - Build tool and package manager
- Installs HLS - Haskell Language Server
- Installs dev tools - hlint, ormolu/fourmolu
- Validates LSP config - Confirms
.lsp.json is correct
- Verifies hooks - Confirms hooks are properly loaded
Usage:
/setup
Quick install command (from the wizard):
ghcup install ghc latest && \
ghcup install cabal latest && \
ghcup install hls latest && \
cabal update && \
cabal install hlint ormolu
| Command | Description |
|---|
/setup | Full interactive setup for HLS and all tools |
Configuration
Formatter Selection
By default, hooks use ormolu for formatting. To use fourmolu instead:
- Install fourmolu:
cabal install fourmolu
- Edit
hooks/hooks.json and change ormolu to fourmolu
Customizing Hooks
Edit hooks/hooks.json to:
- Disable hooks by setting
"enabled": false
- Adjust output limits (
head -N)
- Modify matchers for different file patterns
- Add project-specific hooks
Example - use fourmolu:
{
"name": "haskell-format-on-edit",
"event": "afterWrite",
"hooks": [
{
"type": "command",
"command": "command -v fourmolu >/dev/null && fourmolu -i $FILE || true"
}
],
"matcher": "**/*.hs"
}
Project Structure