A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://haskell-language-server.readthedocs.io/en/latest/contributing/contributing.html below:

Website Navigation


Contributing guidelines — haskell-language-server 2.11.0.0 documentation

Contributing guidelines

The Haskell tooling dream is near, we need your help!

How to contact the Haskell Language Server (HLS) team Building

Clone the repository:

$ git clone https://github.com/haskell/haskell-language-server

The project can then be built with both cabal build and stack build.

Building with Cabal
# If you have not run `cabal update` in a while
$ cabal update
# Then
$ cabal build
Building with Stack Building with Nix

The instructions below show how to set up a Cachix binary cache and open a Nix shell for local development.

$ cachix use haskell-language-server
$ nix-shell
$ cabal update
$ cabal build
Flakes support

If you are using Nix 2.4 style commands (enabled by experimental-features = nix-command), you can use nix develop instead of nix-shell to enter the development shell. To enter the shell with specific GHC versions:

If you are looking for a Nix expression to create haskell-language-server binaries, see https://github.com/haskell/haskell-language-server/issues/122

Testing

The tests make use of the Tasty test framework.

There are two test suites in the main haskell-language-server package, functional tests, and wrapper tests. Some of the wrapper tests expect stack to be present on the system, or else they fail. Other project packages, like the core library or plugins, can have their own test suite.

Testing with Cabal

Running all the tests

Running just the functional tests

Running just the wrapper tests

$ cabal test wrapper-test

Running just the tests for a specific plugin

$ cabal test hls-<plugin-name>-plugin-tests
# E.g.
$ cabal test hls-refactor-plugin-tests

Running a subset of tests

Tasty supports providing patterns as command line arguments, to select the specific tests to run.

$ cabal test func-test --test-option "-p hlint"

The above recompiles everything every time you use a different test option though. An alternative, which only recompiles when tests (or dependencies) change is to pass the TASTY_PATTERN environment variable:

$ TASTY_PATTERN='hlint' cabal test func-test
Using HLS on HLS code

Refer to the HLS project configuration guidelines as they also apply to the HLS project itself.

Note: HLS implicitly detects the HLS codebase as a Stack project (since there is a stack.yaml file). If you want HLS to use Cabal, create this hie.yaml file at the root of the project:

Manually testing your hacked HLS

If you want to test HLS while hacking on it (you can even test it on HLS codebase itself, see previous section), you need to:

  1. (Once) Find the path to the hacked HLS you build

  2. (Once) Configure your editor to use it

  3. (Every time you change the HLS code) Rebuild HLS

  4. (Every time you change the HLS code) Restart the LSP workspace

Find the path to your HLS build

Note that unless you change the GHC version or the HLS version between builds, the path should remain the same, this is why you need to set it only once.

Using Cabal

Run:

$ cabal build exe:haskell-language-server && cabal list-bin exe:haskell-language-server
[..]
<some long path>/haskell-language-server
Using Stack

Run:

$ echo $(pwd)/$(stack path --dist-dir)/build/haskell-language-server/haskell-language-server
[..]
<some long path>/haskell-language-server
Configuring your editor to use your HLS build Configuring VS Code

When using VS Code you can set up each project to use a specific HLS executable:

{
    "haskell.serverExecutablePath": "/path/to/your/hacked/haskell-language-server"
}
Configuring Emacs

There are several ways to configure the HLS server path:

((haskell-mode . ((lsp-haskell-server-path . "/path/to/your/hacked/haskell-language-server"))))
Rebuild HLS Restart the LSP workspace Style guidelines

The project includes a .editorconfig file with the editor basic settings used by the project. However, most editors will need some action to honour those settings automatically. For example VS Code needs to have installed a specific extension. Please, try to follow those basic settings to keep the codebase as uniform as possible.

Formatter pre-commit hook

We are using pre-commit to configure the git pre-commit hook for formatting. Although it is possible to format code manually, we recommend you to use the pre-commit hook as our CI checks if the hook was applied or not.

If you are using Nix or Gitpod, the pre-commit hook is automatically installed. Otherwise, follow the instructions on https://pre-commit.com/ to install the pre-commit tool. Then run the following command:

Why are some components excluded from automatic formatting? Plugin tutorial

See the tutorial on writing a plugin in HLS.

Measuring, benchmarking and tracing Benchmarks

If you are touching performance sensitive code, take the time to run a differential benchmark between HEAD and origin/master (see bench/README).

Run the benchmarks with cabal bench. The runtime is about 25 minutes and the results will be stored in the bench-results folder. To interpret the results, see the comments in the bench/Main.hs module.

Tracing

HLS records eventlog traces via opentelemetry. To generate the traces, build with -eventlog and run with +RTS -l. To visualize the traces, install Tracy and use eventlog-to-tracy to open the generated eventlog.

Adding support for a new editor

Adding support for new editors is fairly easy if the editor already has good support for generic LSP-based extensions. In that case, there will likely be an editor-specific support system (e.g., lsp-mode for Emacs). The support system will typically provide instructions for how to add support for new languages.

In some cases you may need to write a small bit of additional client support, or expose a way for the user to set the server’s configuration options and for them to configure how the server is started.

Building the documentation

The documentation is built with Sphinx and ReadTheDocs, the documentation of both is helpful.

You need to install some Python prerequisites. You can either pip install -r docs/requirements.txt, or simply enter a nix-shell.

Then to build and preview the documentation:

cd docs
make html
firefox _build/html/index.html

Alternatively, you can build the documentation as a Nix derivation from the Flake with nix build .#docs.

The documentation is also built and previewed on every PR, so you can check them from the PR status.

Working on code actions

To make HLS easier to maintain, please follow these design guidelines when adding or modifying code actions:

  1. Prefer ghc-exactprint to manual text parsing.

  2. Prefer ghc-exactprint to manual code generation.

  3. Code generating actions should not try to format the generated code. Assume that the user is also leveraging HLS for automated code formatting.

  4. Put new code actions in their own plugin unless they are very closely aligned with an existing code action.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4