Skip to content

Commit

Permalink
Add da-hls helper (digital-asset#13853)
Browse files Browse the repository at this point in the history
* Add haskell-language-server executable

* Add da-hls alias

* strip prefixes in da_haskell_libraries

* Remove dev-env-provided ghcide

* Update mentions of 'ghcide' to 'hls'

changelog_begin
changelog_end
  • Loading branch information
akrmn authored May 12, 2022
1 parent dade57a commit ad123f9
Show file tree
Hide file tree
Showing 14 changed files with 173 additions and 87 deletions.
3 changes: 3 additions & 0 deletions .hie-bios
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ hie_bios_flags() {
} else if (line == "+RTS") {
rts_opts = true
} else if (match(line, "-qg|-fexternal-interpreter")) {
} else if (match(line, "com_github_madler_zlib")) {
} else if (match(line, "grpc_haskell_core_cbits")) {
} else if (match(line, "-lmerged_cbits")) {
} else {
print line
}
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Autogenerated json files, which are not intended to be read by humans (and which shouldn't be formatted either).
maven_install.json
maven_install_2.13.json
ghcide_snapshot.json
hls_snapshot.json
stackage_snapshot_windows.json
stackage_snapshot.json
dev-env/windows/manifests/*.json
Expand Down
22 changes: 11 additions & 11 deletions BAZEL-haskell.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,20 @@ alias(

## Editor integration

The `daml` repository is configured to support [`ghcide`][ghcide] with Bazel
and the `ghcide` executable is provided by the `dev-env`. Take a look at the
[setup section][ghcide_setup] for example configurations for various editors.
`ghcide` has to be built with the same `ghc` as the project you're working on.
Be sure to either point your editor to the `dev-env` provided `ghcide` by
absolute path, or make sure that the `dev-env` provided `ghcide` is in `$PATH`
for your editor.

Note, `ghcide` itself is built by Bazel and to load a target into the editor
The `daml` repository is configured to support [`haskell-language-server`][hls]
with Bazel and the `da-hls` executable is provided by the `dev-env`. Take a look
at the [setup section][hls_setup] for example configurations for various
editors. `haskell-language-server` has to be built with the same `ghc` as the
project you're working on. Be sure to either point your editor to the
`dev-env`-provided `haskell-language-server` by absolute path, or make sure that
the `dev-env`-provided `haskell-language-server` is in `$PATH` for your editor.

Note, `hls` itself is built by Bazel and to load a target into the editor
some of its dependencies have to be built by Bazel. This means that start-up
may take some time if the required artifacts are not built or cached already.

[ghcide]: https://github.com/digital-asset/ghcide
[ghcide_setup]: https://github.com/digital-asset/ghcide#using-with-vs-code
[hls]: https://github.com/haskell/haskell-language-server
[hls_setup]: https://haskell-language-server.readthedocs.io/en/latest/configuration.html#vs-code

## Further reading:

Expand Down
10 changes: 5 additions & 5 deletions bazel-haskell-deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -663,18 +663,18 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"])
)

stack_snapshot(
name = "ghcide",
name = "hls",
extra_deps = {
"zlib": ["@com_github_madler_zlib//:libz"],
},
haddock = False,
local_snapshot = "//:ghcide-snapshot.yaml",
stack_snapshot_json = "//:ghcide_snapshot.json",
local_snapshot = "//:hls-snapshot.yaml",
stack_snapshot_json = "//:hls_snapshot.json",
packages = [
"ghcide",
"haskell-language-server",
],
components = {
"ghcide": ["lib", "exe"],
"haskell-language-server": ["lib", "exe"],
"attoparsec": [
"lib:attoparsec",
"lib:attoparsec-internal",
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ if [[ "$(uname)" != "Darwin" ]]; then
da-ghci --data yes //compiler/damlc:damlc -e ':main --help'
fi

# Test that ghcide at least builds starts, we don’t run it since it
# Test that hls at least builds, we don’t run it since it
# adds 2-5 minutes to each CI run with relatively little benefit. If
# you want to test it manually on upgrades, run
# ghcide compiler/damlc/exe/Main.hs.
ghcide --help
# da-hls compiler/damlc/exe/Main.hs.
da-hls --help
3 changes: 3 additions & 0 deletions compiler/daml-lf-proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ da_haskell_library(
"either",
"text",
],
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//compiler/daml-lf-ast",
Expand All @@ -43,6 +44,7 @@ da_haskell_library(
"text",
"vector",
],
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":daml-lf-util",
Expand Down Expand Up @@ -73,6 +75,7 @@ da_haskell_library(
"proto3-suite",
"unordered-containers",
],
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":daml-lf-util",
Expand Down
2 changes: 2 additions & 0 deletions compiler/damlc/stable-packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ da_haskell_library(
"containers",
"text",
],
src_strip_prefix = "lib",
visibility = ["//visibility:public"],
deps = [
"//compiler/daml-lf-ast",
Expand All @@ -32,6 +33,7 @@ da_haskell_binary(
"text",
],
main_function = "GenerateStablePackage.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":stable-packages-lib",
Expand Down
2 changes: 2 additions & 0 deletions daml-assistant/daml-helper/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ da_haskell_library(
"aeson-pretty",
"time",
],
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//:sdk-version-hs-lib",
Expand Down Expand Up @@ -74,6 +75,7 @@ da_haskell_binary(
"text",
],
main_function = "DA.Daml.Helper.Main.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":daml-helper-lib",
Expand Down
7 changes: 7 additions & 0 deletions dev-env/bin/da-hls
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash ../../shell.nix

set -euo pipefail

bazel build @hls-exe//haskell-language-server
exec ./bazel-bin/external/hls/haskell-language-server-1.7.0.0/_install/bin/haskell-language-server "$@"
7 changes: 0 additions & 7 deletions dev-env/bin/ghcide

This file was deleted.

19 changes: 0 additions & 19 deletions ghcide-snapshot.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions hls-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

resolver: lts-19.6
packages:
- haskell-language-server-1.7.0.0
- floskell-0.10.6
- ghcide-1.7.0.0
- heapsize-0.3.0.1
- hie-compat-0.2.1.1
- hiedb-0.4.1.0
- hls-alternate-number-format-plugin-1.1.0.0
- hls-call-hierarchy-plugin-1.0.3.0
- hls-change-type-signature-plugin-1.0.1.0
- hls-class-plugin-1.0.3.0
- hls-eval-plugin-1.2.2.0
- hls-explicit-imports-plugin-1.1.0.0
- hls-floskell-plugin-1.0.1.1
- hls-fourmolu-plugin-1.0.3.0
- hls-graph-1.7.0.0
- hls-haddock-comments-plugin-1.0.1.0
- hls-hlint-plugin-1.0.4.0
- hls-module-name-plugin-1.0.2.0
- hls-ormolu-plugin-1.0.2.1
- hls-plugin-api-1.4.0.0
- hls-pragmas-plugin-1.0.2.1
- hls-qualify-imported-names-plugin-1.0.1.0
- hls-refine-imports-plugin-1.0.2.0
- hls-rename-plugin-1.0.0.2
- hls-retrie-plugin-1.0.2.1
- hls-selection-range-plugin-1.0.0.0
- hls-splice-plugin-1.0.1.0
- implicit-hie-0.1.2.7
- implicit-hie-cradle-0.5.0.0
- monad-dijkstra-0.1.1.3
- retrie-1.1.0.0
Loading

0 comments on commit ad123f9

Please sign in to comment.