This is a Language Server Protocol VSCode plugin for the Dhall programming language.
The Dhall language integration consists of the following parts:
The "official" releases can be installed as follows:
cabal install dhall-lsp-server
.Note The versions of vscode-dhall-lsp-server and dhall-lsp-server need not necessarily match: an older client version will simply not expose all commands available in the backend, while an older server might not implement all commands exposed in the UI.
vscode-dhall-lsp-server
git@github.com:dhall-lang/vscode-dhall-lsp-server.git
into a folder under ~/.vscode-oss/extensions/
(or ~/.vscode/extensions/
if you VSCode rather than VSCodium).npm install
to fetch any dependencies.dhall-lsp-server
git@github.com:dhall-lang/dhall-haskell.git
.stack install dhall-lsp-server
.Diagnostics Every time you save a Dhall file it is parsed and typechecked, and any errors are marked. You can hover over the offending code to see the error message; to see a detailed explanation in the case of type errors, click the Explain link in the hover box.
Clickable imports As long as the file parses successfully, all (local file and remote) imports will be underlined and clickable.
Type on hover
You can hover over any part of the code and it will tell you the type of the subexpression at that point – if you highlight an identifier you see its type; if you highlight the ->
in a function you will see the type of the entire function. This feature only works if the code passes the typechecker!
Code completion As you type you will be offered completions for:
ident1.ident2
[.ident3...
])This is the only feature that works even when the file does not parse (or typecheck).
Formatting and Linting Right click and select "Format Document" to run the file through the Dhall formatter. The command "Lint and Format" can be selected via the Command Palette (Ctrl+Shift+P); this will run the linter over the file, removing unused let bindings and formatting the result.
Annotate lets
Right-click the bound identifier in a let
binding and select "Annotate Let binding with its type" to do exactly that.
Freeze imports Right-click an import statement and select "Freeze (refreeze) import" to add (or update) a semantic hash annotation to the import. You can also select "Freee (refreeze) all imports" from the Command Palette to freeze all imports at once.
Note that this feature behaves slightly differently from the dhall freeze
command in that the hash annotations are inserted without re-formatting the rest of the code!
dhall-lsp-server
stack build dhall-lsp-server
and point vscode-dhall-lsp-server.executable
in the VSCode/ium settings to the stack build directory, to avoid overriding the installed version of the LSP server.Debug.Trace
/putStrLn
debugging; the output will show up in the "Output" panel in VSCode/ium.vscode-dhall-lsp-server.trace.server
to verbose
in VSCode/ium.vscode-dhall-lsp-server
~/vscode-oss/extensions/...
directly, you can open a clone of the git repository in VSCode/ium and use the built-in debugging capabilities for extensions: press F5 (or click the green play button in the debugging tab) to launch a new VSCode/ium window with the modified extension (potentially shadowing the installed version).npm install -g vsce
to install the vsce executable. I recommend running npm config set prefix '~/.local'
first to have npm install the executable in ~/.local/bin
; this avoids having to use sudo and polluting the rest of the system.vsce package
inside the git repo to package the extension, resulting in a file vscode-dhall-lsp-server-x.x.x.vsix
..vsix
file from within VSCod/ium.