dhall-lsp-server: Language Server Protocol (LSP) server for Dhall

[ library, mit, program, unclassified ] [ Propose Tags ] [ Report a vulnerability ]

Modules

[Last Documentation]

  • Dhall
    • LSP
      • Backend
        • Dhall.LSP.Backend.Completion
        • Dhall.LSP.Backend.Dhall
        • Dhall.LSP.Backend.Diagnostics
        • Dhall.LSP.Backend.Formatting
        • Dhall.LSP.Backend.Freezing
        • Dhall.LSP.Backend.Linting
        • Dhall.LSP.Backend.Parsing
        • Dhall.LSP.Backend.ToJSON
        • Dhall.LSP.Backend.Typing
      • Dhall.LSP.Handlers
      • Dhall.LSP.Server
      • Dhall.LSP.State

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9, 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17, 1.0.18, 1.1.0, 1.1.1, 1.1.2, 1.1.3
Dependencies aeson (>=1.3.1.1 && <2.2), aeson-pretty (>=0.8.7 && <0.9), base (>=4.11 && <5), bytestring (>=0.10.8.2 && <0.13), containers (>=0.5.11.0 && <0.8), data-default (>=0.7.1.1 && <0.8), dhall (>=1.38.0 && <1.43), dhall-json (>=1.4 && <1.8), dhall-lsp-server, directory (>=1.2.2.0 && <1.4), filepath (>=1.4.2 && <1.6), hslogger (>=1.2.10 && <1.4), lens (>=4.16.1 && <5.2), lsp (>=1.2.0.0 && <1.5), megaparsec (>=7.0.2 && <10), mtl (>=2.2.2 && <2.3), network-uri (>=2.6.1.0 && <2.7), optparse-applicative, prettyprinter (>=1.7.0 && <1.8), rope-utf16-splay (>=0.3.1.0 && <0.5), text (>=1.2.3.0 && <2.2), transformers (>=0.5.5.0 && <0.6), unordered-containers (>=0.2.9.0 && <0.3), uri-encode (>=1.5.0.5 && <1.6) [details]
License MIT
Copyright 2019 panaeon
Author panaeon
Maintainer Gabriella Gonzalez
Revised Revision 1 made by GabrielGonzalez at 2024-09-29T13:35:08Z
Home page https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-lsp-server#readme
Bug tracker https://github.com/dhall-lang/dhall-haskell/issues
Source repo head: git clone https://github.com/dhall-lang/dhall-haskell
Uploaded by GabrielGonzalez at 2023-04-19T03:09:17Z
Distributions Arch:1.1.3
Executables dhall-lsp-server
Downloads 9243 total (67 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2023-04-19 [all 2 reports]

Readme for dhall-lsp-server-1.1.3

[back to package description]

Dhall language support in VSCode/ium

The Dhall language integration consists of the following parts:

  • The VSCode/ium plugin "Dhall Language Support" (vscode-language-dhall) adds syntax highlighting for Dhall files.
  • The VSCode/ium plugin "Dhall LSP Server" (vscode-dhall-lsp-server) implements the LSP client – yes, there is a naming issue here – that communicates with the backend via the LSP protocol to provide advanced language features like error diagnostics or type information, etc.
  • dhall-lsp-server, which is part of the dhall-haskell project, implements the actual LSP server (i.e. the backend) that implements those language features in an editor agnostic way, though at the moment only a VSCode/ium frontend exists.

Installation

The "official" releases can be installed as follows:

  • vscode-language-dhall should be installed directly from VSCode/ium via the extensions marketplace.
  • vscode-dhall-lsp-server can also be installed directly from the marketplace.
  • dhall-lsp-server can be installed from hackage with cabal install dhall-lsp-server. See the dhall-haskell README for pre-built binaries, as well as comprehensive installation and development instructions using cabal, stack or nix.

Installing the latest development versions

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

  1. You need to have npm installed (e.g. using your favourite package manager).
  2. Install the typescript compiler with npm install -g typescript. 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.
  3. Check out a copy of the vscode-dhall-lsp-server repository into the VSCode/ium extensions folder
    git clone git@github.com:dhall-lang/vscode-dhall-lsp-server.git ~/.vscode-oss/extensions/vscode-dhall-lsp-server
    
    (replace ~/.vscode-oss/ with ~/.vscode/ if you use VSCode instead of VSCodium).
  4. Run the remaining commands in the checked-out directory
    cd ~/.vscode-oss/extensions/vscode-dhall-lsp-server
    
  5. Run npm install to fetch all library dependencies.
  6. Run npm run compile to compile the typescript code to javascript.
  7. Start (restart) VSCode/ium.

dhall-lsp-server  For detailed instructions as well as instructions using cabal or nix, see dhall-haskell - README. To install dhall-lsp-server using stack:

  1. Clone git@github.com:dhall-lang/dhall-haskell.git.
  2. Inside the checked out repository run stack install dhall-lsp-server.

Usage / Features

  • 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:

    • environment variables
    • local imports
    • identifiers in scope (as well as built-ins)
    • record projections from 'easy-to-parse' records (of the form ident1.ident2[.ident3...])
    • union constructors from 'easy-to-parse' unions

    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.

The default formatting behavior is to infer the character set used in the file (Unicode/ASCII operators). This can be overriden by using the Dhall LSP settings. For example in VS Code's settings.json:

  • "vscode-dhall-lsp-server.character-set": "ascii" to always format using the ASCII character set

  • "vscode-dhall-lsp-server.character-set": "unicode" to always format using the Unicode character set

  • 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 "Freeze (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!

Developer notes

dhall-lsp-server  See dhall-haskell - README for general development instructions.

  • You can also build using 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 already installed version of the LSP server.
  • You can use standard Debug.Trace/putStrLn debugging; the output will show up in the "Output" panel in VSCode/ium.
  • To log all LSP communication set vscode-dhall-lsp-server.trace.server to verbose in VSCode/ium.

vscode-dhall-lsp-server

  • Instead of working in ~/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).
  • To package a release:
    1. Make sure you have npm and tsc installed.
    2. Use npm install -g vsce to install the vsce executable.
    3. Run vsce package inside the git repo to package the extension, resulting in a file vscode-dhall-lsp-server-x.x.x.vsix.
    4. You can install the packaged extension directly by opening the .vsix file from within VSCod/ium.

Integration tests

The dhall-lsp-server:tests testsuite depends on the dhall-lsp-server executable. Since stack isn't aware of this dependency, stack test dhall-lsp-server:tests may use an old executable version. Run these tests with

stack test dhall-lsp-server:tests dhall-lsp-server:dhall-lsp-server

to ensure that the executable is up-to-date.