Skip to content

Hlint refactor #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
types: [created]

jobs:

build:
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -156,9 +155,41 @@ jobs:
with:
name: haskell-language-server-wrapper-${{ runner.OS }}${{env.EXE_EXT}}.${{ steps.compress_wrapper_binary.outputs.extension }}
path: ${{ steps.compress_wrapper_binary.outputs.path }}

# generates a custom tarball with sources, used by `ghcup compile hls`
src-tar:
needs: build
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: "Create source tarball"
run: |
mkdir src-dist
git archive --prefix=haskell-language-server-${{ github.event.release.tag_name }}/ \
--format=tar.gz \
-o src-dist/haskell-language-server.tar.gz \
HEAD

- uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: src-dist/haskell-language-server.tar.gz
asset_name: haskell-language-server-${{ github.event.release.tag_name }}-src.tar.gz
asset_content_type: application/gzip

# this generates .gz tarfiles containing all the GHC versions for
# macOS and Linux, used by ghcup
- uses: actions/upload-artifact@v2
with:
name: haskell-language-server-${{ github.event.release.tag_name }}-src.tar.gz
path: src-dist/haskell-language-server.tar.gz

# this generates .gz tarfiles containing binaries for all GHC versions and OS's
# used by `ghcup install hls`
tar:
needs: build
runs-on: ubuntu-18.04
Expand Down Expand Up @@ -198,7 +229,7 @@ jobs:
path: bin/haskell-language-server.tar.gz

sha256sum:
needs: tar
needs: [tar, src-tar]
runs-on: ubuntu-18.04
steps:
- uses: actions/download-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ jobs:
name: Test hls-ormolu-plugin
run: cabal test hls-ormolu-plugin --test-options="-j1 --rerun-update" || cabal test hls-ormolu-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-ormolu-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
name: Test hls-fourmolu-plugin
run: cabal test hls-fourmolu-plugin --test-options="-j1 --rerun-update" || cabal test hls-fourmolu-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-fourmolu-plugin --test-options="-j1 --rerun"

Expand Down
12 changes: 3 additions & 9 deletions cabal-ghc901.project
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packages:
-- ./plugins/hls-tactics-plugin
-- ./plugins/hls-brittany-plugin
-- ./plugins/hls-stylish-haskell-plugin
-- ./plugins/hls-fourmolu-plugin
./plugins/hls-fourmolu-plugin
-- ./plugins/hls-class-plugin
./plugins/hls-eval-plugin
./plugins/hls-explicit-imports-plugin
Expand Down Expand Up @@ -53,19 +53,13 @@ source-repository-package
subdir: dependent-sum-template
-- https://github.com/obsidiansystems/dependent-sum/pull/59

-- benchmark dependency
source-repository-package
type: git
location: https://github.com/HeinrichApfelmus/operational
tag: 16e19aaf34e286f3d27b3988c61040823ec66537

write-ghc-environment-files: never

index-state: 2021-09-16T07:00:23Z
index-state: 2021-10-04T02:41:06Z

constraints:
-- These plugins don't work on GHC9 yet
haskell-language-server -brittany -class -fourmolu -stylishhaskell -tactic
haskell-language-server -brittany -class -stylishhaskell -tactic

allow-newer:
floskell:base,
Expand Down
8 changes: 1 addition & 7 deletions cabal-ghc921.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ source-repository-package
tag: b6245884ae83e00dd2b5261762549b37390179f8
-- https://github.com/lspitzner/czipwith/pull/2

-- benchmark dependency
source-repository-package
type: git
location: https://github.com/HeinrichApfelmus/operational
tag: 16e19aaf34e286f3d27b3988c61040823ec66537

-- Head of hiedb
source-repository-package
type: git
Expand All @@ -57,7 +51,7 @@ source-repository-package

write-ghc-environment-files: never

index-state: 2021-09-16T07:00:23Z
index-state: 2021-09-29T21:38:47Z

constraints:
-- These plugins doesn't work on GHC9 yet
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ package *

write-ghc-environment-files: never

index-state: 2021-09-16T07:00:23Z
index-state: 2021-10-04T02:41:06Z

constraints:
hyphenation +embed
Expand Down
15 changes: 8 additions & 7 deletions configuration-ghc-901.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ let

ormolu = hself.ormolu_0_2_0_0;

operational = hself.callCabal2nix "operational" (pkgs.fetchFromGitHub {
owner = "HeinrichApfelmus";
repo = "operational";
rev = "16e19aaf34e286f3d27b3988c61040823ec66537";
sha256 = "P+aocEcqCN8klnW3IMrmIqq6ztBZJxk4sBp1ewN6YaA=";
}) { };

diagrams-core = hself.diagrams-core_1_5_0;

diagrams-lib = hself.diagrams-lib_1_4_4;
Expand All @@ -77,6 +70,14 @@ let

monoid-extras = hself.monoid-extras_0_6;

# Released on hackage, but not in nixpkgs yet
operational = hself.callCabal2nix "operational" (pkgs.fetchFromGitHub {
owner = "HeinrichApfelmus";
repo = "operational";
rev = "2b33e0055066cf92a302ee2c32058dfa44ac8882";
sha256 = "sha256-nwB4vssm4wUTkVryjQVb3peOwR6js7vdekkbaWedHNI=";
}) { };

# Re-generate HLS drv excluding some plugins
haskell-language-server =
hself.callCabal2nixWithOptions "haskell-language-server" ./.
Expand Down
36 changes: 33 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ For example, there are protocol methods for highlighting matching identifiers th
This is a capability which any server can implement, so the client can decide generically whether to ask the server to do it or not.
So your editor can provide a setting to turn this on or off globally, for any language server you might use.

Settings like this are typically provided by the generic LSP client support for your editor, for example in Emacs by `lsp-mode`.
Settings like this are typically provided by the generic LSP client support for your editor, for example in Emacs by [`lsp-mode`](https://github.com/emacs-lsp/lsp-mode).

### Generic editor options

Your editor may provide some settings that affect how the information from the language server is used.
For example, whether popups are shown, or whether code lenses appear by default.

Settings like this are typically provided by the generic LSP client support for your editor, for example in Emacs by `lsp-mode`.
Settings like this are typically provided by the generic LSP client support for your editor, for example in Emacs by [`lsp-mode`](https://github.com/emacs-lsp/lsp-mode).

### Language-specific server options

Expand Down Expand Up @@ -96,7 +96,9 @@ This is handled by the [`hie-bios`](https://github.com/mpickering/hie-bios) proj

At the moment, `haskell-language-server` has support to automatically detect your project build configuration to handle most use cases.

However, if the automatic detection fails you can configure `hie-bios` using a `hie.yaml` file in the root of the workspace.
*So using a explicit `hie.yaml` file will not likely fix your ide setup*. It will do it almost only if you see an error like `Multi Cradle: No prefixes matched`

If the automatic detection fails with that error you can configure `hie-bios` using a `hie.yaml` file in the root of the workspace.
A `hie.yaml` file **explicitly** describes how to setup the environment to compile the various parts of your project.
For that you need to know what *components* your project has, and the path associated with each one.
So you will need some knowledge about
Expand Down Expand Up @@ -194,6 +196,34 @@ dependencies:
- someDep
```

### How to show local documentation on hover

Haskell Language Server can display Haddock documentation on hover and completions if the project and
its dependencies have been built with the `-haddock` GHC flag.

- For cabal:

- Add to your global config file (e.g. `~/.cabal/config`):

```yaml
program-default-options
ghc-options: -haddock
```

- Or, for a single project, run `cabal configure --ghc-options=-haddock`

- For stack, add to global `$STACK_ROOT\config.yaml`, or project's `stack.yaml`:

```yaml
ghc-options:
'$everything': -haddock
```

Note that this flag will cause compilation errors if a dependency contains invalid Haddock markup,
until GHC 9.0 which [will report warnings](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2377)
instead.


## Configuring your editor

Most editors provide a Haskell-specific extension that provides support for launching `haskell-language-server` and talking to it, as well as [exposing configuration options](#configuring-haskell-language-server).
Expand Down
8 changes: 7 additions & 1 deletion docs/contributing/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ The Haskell tooling dream is near, we need your help!
- Follow the [Haskell IDE team twitter account](https://twitter.com/IdeHaskell) for updates and help.
- Join the [#haskell-tooling channel](https://discord.com/channels/280033776820813825/505370075402862594/808027763868827659) in the Functional Programming discord server. You can join the server via [this invitation](https://discord.gg/9spEdTNGrD).
- Join the [haskell-tooling channel](https://matrix.to/#/#haskell-tooling:matrix.org) in [matrix](https://matrix.org/).
- Visit [the project GitHub repo](https://github.com/haskell/haskell-language-server) to view the source code, or open issues or pull requests.

## Building haskell-language-server

The project can be built with both `cabal build` and `stack build`.
Clone the repository:
```shell
$ git clone https://github.com/haskell/haskell-language-server
```

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

haskell-language-server can also be used with itself. We provide preset samples of `hie.yaml` for Cabal and Stack.

Expand Down
47 changes: 24 additions & 23 deletions docs/contributing/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,24 @@ only one wrapper binary is created per platform, and it should be built with the
most recent GHC version.

### ghcup
It also creates a `haskell-language-server-${os}-${hlsVersion}.tar.gz` tarball with
the binaries for *all* supported ghc versions, to help downstream publishers in
the distribution of the release. The most prominent publisher using them is `ghcup`.
The `tar` job in the workflow file automates the creation of this.

Once all these binaries are present
It creates a `haskell-language-server-${os}-${hlsVersion}.tar.gz` tarball with
the binaries for *all* supported ghc versions and a custom source tarball to help
downstream publishers in the distribution of the release.

The most prominent publisher using them is `ghcup`.

### checksums

The sha256 checksum of all artifacts are listed in the `SHA256SUMS` release file.

## Distributable binaries

In order to compile a hls binary on one machine and have it run on another, you
need to make sure there are **no hardcoded paths or data-files**.

### ghc libdir

One noteable thing which cannot be hardcoded is the **GHC libdir** – this is
a path to `/usr/local/lib/ghc` or something like that, which was previously
baked in at compile-time with ghc-paths. Note that with static binaries we
Expand All @@ -78,22 +84,24 @@ Therefore, hie-bios provides `getGhcRuntimeLibDir` to obtain this path on the fl
by consulting the cradle.

### Static binaries

We use the word "distributable" here because technically only the Linux builds
are static. They are built by passing `--enable-executable-static` to cabal.
Static binaries don't really exist on macOS, and there are issues with
proprietary code being linked in on Windows. However, the `.dylib`s linked on
macOS are all already provided by the system:

```
```bash
$ objdump -macho --dylibs-used haskell-language-server
haskell-language-server:
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
/usr/lib/libcharset.1.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
/usr/lib/libcharset.1.dylib (compatibility version 2.0.0, current version 2.0.0)
```

## The GitHub Actions workflow

It just kicks off a matrix of jobs varying across GHC versions and OSs, building
the binaries with Cabal and extracting them from the dist-newstyle directory.
The binaries are built with -O2.
Expand All @@ -120,19 +128,12 @@ its secure distribution using their hashes. We should only add new ones.*

To manually upload a new binary we should:

- Add the new tar/zip following the name conventions of existing ones
- `haskell-language-server-${os}-${ghcVersion}.gz` for `Linux` and `macOS` and `haskell-language-server-Windows-${ghcVersion}.exe.zip` for `Windows`
- the binary inside the gz file is named `haskell-language-server-${ghcVersion}` (with the `.exe` extension for `Windows`). Note that the binary name does not contain the `${os}` part.
- Add the executable to the existing tar `haskell-language-server-${os}-${ghcVersion}.tar.gz` *locally* and upload it under a new name `haskell-language-server-${os}-${ghcVersion}-rev${n}.tar.gz` following the same schema for the binary as the previous one.
- `-rev${n}` is the next revision number of the tarball, starting at 1.
- we should contact users of the tarball (particularly ghcup) to notify the change

### Windows
Currently building HLS with GHC 8.8.x on Windows is very flakey and so
is not included by default in the GitHub Actions build matrix. Instead
they need to be built and uploaded manually. See [this
PR](https://github.com/haskell/haskell-language-server/issues/276) for
more details
* Add the new tar/zip following the name conventions of existing ones
* `haskell-language-server-${os}-${ghcVersion}.gz` for `Linux` and `macOS` and `haskell-language-server-Windows-${ghcVersion}.exe.zip` for `Windows`
* the binary inside the gz file is named `haskell-language-server-${ghcVersion}` (with the `.exe` extension for `Windows`). Note that the binary name does not contain the `${os}` part.
* Add the executable to the existing tar `haskell-language-server-${os}-${ghcVersion}.tar.gz` *locally* and upload it under a new name `haskell-language-server-${os}-${ghcVersion}-rev${n}.tar.gz` following the same schema for the binary as the previous one.
* `-rev${n}` is the next revision number of the tarball, starting at 1.
* we should contact users of the tarball (particularly ghcup) to notify the change

## Hackage release workflow

Expand Down
42 changes: 21 additions & 21 deletions docs/features.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# Features

- Code evaluation codelens ([Tutorial](https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-eval-plugin/README.md)):
- Warning and error diagnostics from GHC
- Type information and documentation on hover, [including your own comments](./configuration.md#how-to-show-local-documentation-on-hover).
- Jump to definition: [for now only for local code definitions](https://github.com/haskell/haskell-language-server/issues/708)
- Document symbols
- Highlight references in document
- Code completion
- Formatting via Brittany, Floskell, Fourmolu, Ormolu or Stylish Haskell
- Code evaluation (Haskell Language Server), see ([Tutorial](https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-eval-plugin/README.md))

![Eval Demo](https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-eval-plugin/demo.gif)
![Eval Demo](https://raw.githubusercontent.com/haskell/haskell-language-server/master/plugins/hls-eval-plugin/demo.gif)

- Type information and documentation on hover. Note that currently, in order for docs to be displayed for dependencies, they must have been built with GHC's `-haddock` flag:
- Integration with [retrie](https://hackage.haskell.org/package/retrie)

- For cabal:
- Add to your global config file (e.g. `~/.cabal/config`):
![Retrie Demo](https://i.imgur.com/Ev7B87k.gif)

```
program-default-options
ghc-options: -haddock
```
- Code lenses for explicit import lists

- Or, for a single project, run `cabal configure --ghc-options=-haddock`
![Imports code lens Demo](https://imgur.com/pX9kvY4.gif)

- For stack, add to global `$STACK_ROOT\config.yaml`, or project's `stack.yaml`:
- Generate functions from type signatures, and intelligently complete holes using [Wingman (tactics)](https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-tactics-plugin)

```
ghc-options:
"$everything": -haddock
```
![Wingman Demo](https://user-images.githubusercontent.com/307223/92657198-3d4be400-f2a9-11ea-8ad3-f541c8eea891.gif)

This will cause compilation errors if a dependency contains invalid Haddock markup, though from GHC version 9.0, [these will be demoted to warnings](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2377).
- Integration with [hlint](https://github.com/ndmitchell/hlint) to show diagnostics and apply hints via [apply-refact](https://github.com/mpickering/apply-refact)

- Integration with [retrie](https://hackage.haskell.org/package/retrie)
![Hlint Demo](https://user-images.githubusercontent.com/54035/110860028-8f9fa900-82bc-11eb-9fe5-6483d8bb95e6.gif)

![Retrie](https://i.imgur.com/Ev7B87k.gif)
- Module name suggestions for insertion or correction

- Code lenses for explicit import lists
![Module Name Demo](https://user-images.githubusercontent.com/54035/110860755-78ad8680-82bd-11eb-9845-9ea4b1cc1f76.gif)

![Imports code lens](https://imgur.com/pX9kvY4.gif)
- Call hierarchy support

- Many more (TBD)
![Call Hierarchy in VSCode](https://github.com/haskell/haskell-language-server/raw/2857eeece0398e1cd4b2ffb6069b05c4d2308b39/plugins/hls-call-hierarchy-plugin/call-hierarchy-in-vscode.gif)
Loading