Skip to content

Commit 5ef5777

Browse files
committed
Merge branch 'hlint-tests' of https://github.com/jneira/haskell-language-server into hlint-tests
2 parents ebd9445 + 132d1c0 commit 5ef5777

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+712
-433
lines changed

Diff for: .github/workflows/hackage.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
"hls-splice-plugin", "hls-tactics-plugin",
2222
"hls-call-hierarchy-plugin",
2323
"haskell-language-server"]
24-
ghc: ["8.10.7", "8.8.4", "8.6.5"]
24+
ghc: ["9.0.1", "8.10.7", "8.8.4", "8.6.5"]
2525

2626
steps:
2727

@@ -119,6 +119,7 @@ jobs:
119119
path: ${{ steps.generate-dist-tarball.outputs.path }}
120120

121121
upload-candidate:
122+
if: ${{ !contains(github.head_ref, 'check') }}
122123
needs: check-and-upload-tarballs
123124
runs-on: ubuntu-latest
124125
steps:

Diff for: .github/workflows/test.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ defaults:
44
run:
55
shell: bash
66

7+
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
8+
concurrency:
9+
group: ${{ github.head_ref }}-${{ github.workflow }}
10+
cancel-in-progress: true
11+
712
on:
813
pull_request:
914
branches:
@@ -19,19 +24,14 @@ jobs:
1924
- id: skip_check
2025
uses: fkirc/[email protected]
2126
with:
22-
cancel_others: true
23-
paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", "install/**", "**.nix", "flake.lock", "**/README.md", "FUNDING.yml"]'
27+
cancel_others: false
28+
paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", "install/**", "**.nix", "flake.lock", "**/README.md", "FUNDING.yml", ".circleci/**"]'
2429
# If we only change ghcide downstream packages we have not test ghcide itself
2530
- id: skip_ghcide_check
2631
uses: fkirc/[email protected]
2732
with:
33+
cancel_others: false
2834
paths_ignore: '["hls-test-utils/**", "plugins/**", "src/**", "exe/**", "test/**", "shake-bench/**"]'
29-
- if: steps.skip_check.outputs.should_skip == 'true'
30-
name: Skip circleci
31-
uses: marocchino/sticky-pull-request-comment@v2
32-
with:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
message: We are gonna [skip circleci]
3535

3636
test:
3737
if: needs.pre_job.outputs.should_skip != 'true'
@@ -148,7 +148,7 @@ jobs:
148148
# run the tests without parallelism to avoid running out of memory
149149
run: cabal test ghcide --test-options="-j1 --rerun-update" || cabal test ghcide --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test ghcide --test-options="-j1 --rerun"
150150

151-
- if: matrix.test && !(matrix.os == 'windows-latest' && matrix.ghc == '9.0.1')
151+
- if: matrix.test
152152
name: Test func-test suite
153153
env:
154154
HLS_TEST_EXE: hls

Diff for: cabal-ghc901.project

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ write-ghc-environment-files: never
5858
index-state: 2021-10-04T02:41:06Z
5959

6060
constraints:
61-
-- These plugins don't work on GHC9 yet
62-
haskell-language-server -brittany -class -stylishhaskell -tactic
61+
-- These plugins don't work on GHC9 yet
62+
haskell-language-server +ignore-plugins-ghc-bounds -brittany -class -stylishhaskell -tactic
6363

6464
allow-newer:
6565
floskell:base,

Diff for: cabal-ghc921.project

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ write-ghc-environment-files: never
5454
index-state: 2021-09-29T21:38:47Z
5555

5656
constraints:
57-
-- These plugins doesn't work on GHC9 yet
58-
haskell-language-server -brittany -class -fourmolu -splice -stylishhaskell -tactic -refineImports -callhierarchy -retrie
59-
57+
-- These plugins doesn't work on GHC92 yet
58+
haskell-language-server +ignore-plugins-ghc-bounds -brittany -class -fourmolu -splice -stylishhaskell -tactic -refineImports -callhierarchy -retrie
6059

6160
allow-newer:
6261
Cabal,

Diff for: docs/configuration.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ For example, there are protocol methods for highlighting matching identifiers th
2121
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.
2222
So your editor can provide a setting to turn this on or off globally, for any language server you might use.
2323

24-
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).
24+
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).
2525

2626
### Generic editor options
2727

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

31-
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).
31+
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).
3232

3333
### Language-specific server options
3434

@@ -48,7 +48,7 @@ Here is a list of the additional settings currently supported by `haskell-langua
4848
- Hlint (`haskell.hlintOn`, default true): whether to enable Hlint support. *Deprecated* as it is equivalen to `haskell.plugin.hlint.globalOn`
4949
- Max completions (`haskell.maxCompletions`, default 40): maximum number of completions sent to the LSP client.
5050
- Check project (`haskell.checkProject`, default true): whether to typecheck the entire project on load. As it is activated by default could drive to bad perfomance in large projects.
51-
- Check parents (`haskell.checkParents`, default `CheckOnSaveAndClose`): when to typecheck reverse dependencies of a file; one of `NeverCheck`, `CheckOnClose`, `CheckOnSaveAndClose`, or `AlwaysCheck`.
51+
- Check parents (`haskell.checkParents`, default `CheckOnSaveAndClose`): when to typecheck reverse dependencies of a file; one of `NeverCheck`, `CheckOnClose`, `CheckOnSaveAndClose`, or `AlwaysCheck`.
5252

5353
#### Generic plugin configuration
5454

@@ -57,7 +57,7 @@ Plugins have a generic config to control their behaviour. The schema of such con
5757
- `haskell.plugin.${pluginName}.globalOn`: usually with default true. Whether the plugin is enabled at runtime or it is not. That is the option you might use if you want to disable completely a plugin.
5858
- Actual plugin names are: `ghcide-code-actions-fill-holes`, `ghcide-completions`, `ghcide-hover-and-symbols`, `ghcide-type-lenses`, `ghcide-code-actions-type-signatures`, `ghcide-code-actions-bindings`, `ghcide-code-actions-imports-exports`, `eval`, `moduleName`, `pragmas`, `refineImports`, `importLens`, `class`, `tactics` (aka wingman), `hlint`, `haddockComments`, `retrie`, `splice`.
5959
- So to disable the import lens with an explicit list of module definitions you could set `haskell.plugin.importLens.globalOn: false`
60-
- `haskell.plugin.${pluginName}.${lspCapability}On`: usually with default true. Whether a concrete plugin capability is enabled.
60+
- `haskell.plugin.${pluginName}.${lspCapability}On`: usually with default true. Whether a concrete plugin capability is enabled.
6161
- Capabilities are the different ways a lsp server can interact with the editor. The current available capabilities of the server are: `callHierarchy`, `codeActions`, `codeLens`, `diagnostics`, `hover`, `symbols`, `completion`, `rename`.
6262
- Note that usually plugins don't provide all capabilities but some of them or even only one.
6363
- So to disable code changes suggestions from the `hlint` plugin (but no diagnostics) you could set `haskell.plugin.hlint.codeActionsOn: false`
@@ -78,7 +78,7 @@ Plugins have a generic config to control their behaviour. The schema of such con
7878
This reference of configuration can be outdated at any time but we can query the `haskell-server-executable` about what configuration is effectively used:
7979
- `haskell-language-server generate-default-config`: will print the json configuration with all default values. It can be used as template to modify it.
8080
- `haskell-language-server vscode-extension-schema`: will print a json schema used to setup the haskell vscode extension. But it is useful to see what range of values can an option take and a description about it.
81-
81+
8282
Settings like this are typically provided by the language-specific LSP client support for your editor, for example in Emacs by `lsp-haskell`.
8383

8484
### Client options
@@ -90,11 +90,11 @@ Settings like this are typically be provided by the language-specific LSP client
9090
## Configuring your project build
9191

9292
`haskell-language-server` has to compile your project in order to give you diagnostics, which means that it needs to know how to do so.
93-
This is handled by the [`hie-bios`](https://github.com/mpickering/hie-bios) project.
93+
This is handled by the [hie-bios](https://github.com/mpickering/hie-bios) project.
9494

95-
**For a full explanation of how `hie-bios` determines the project build configuration, and how to configure it manually, refer to the [`hie-bios` README](https://github.com/mpickering/hie-bios/blob/master/README.md).**
95+
**For a full explanation of how `hie-bios` determines the project build configuration, and how to configure it manually, refer to the [hie-bios README](https://github.com/mpickering/hie-bios/blob/master/README.md).**
9696

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

9999
*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`
100100

@@ -104,7 +104,7 @@ For that you need to know what *components* your project has, and the path assoc
104104
So you will need some knowledge about
105105
[stack](https://docs.haskellstack.org/en/stable/build_command/#components) or [cabal](https://cabal.readthedocs.io/en/latest/cabal-commands.html?#cabal-v2-build) components.
106106

107-
You also can use [this utility](https://github.com/Avi-D-coder/implicit-hie) to automatically generate `hie.yaml` files for
107+
You also can use [implicit-hie](https://github.com/Avi-D-coder/implicit-hie) to automatically generate `hie.yaml` files for
108108
the most common stack and cabal configurations
109109

110110
For example, to state that you want to use `stack` then the configuration file
@@ -351,7 +351,7 @@ it may also be helpful to also specify root markers:
351351
let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml']
352352
```
353353

354-
Further configuration can be done by pointing the [`g:LanguageClient_settingsPath`](https://github.com/autozimu/LanguageClient-neovim/blob/0e5c9546bfddbaa2b01e5056389c25aefc8bf989/doc/LanguageClient.txt#L221)
354+
Further configuration can be done by pointing the `g:LanguageClient_settingsPath` [option](https://github.com/autozimu/LanguageClient-neovim/blob/0e5c9546bfddbaa2b01e5056389c25aefc8bf989/doc/LanguageClient.txt#L221)
355355
variable to the file in which you want to keep your LSP settings.
356356

357357
### Atom

Diff for: docs/contributing/contributing.md

+21-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Haskell tooling dream is near, we need your help!
1010
- Join the [haskell-tooling channel](https://matrix.to/#/#haskell-tooling:matrix.org) in [matrix](https://matrix.org/).
1111
- Visit [the project GitHub repo](https://github.com/haskell/haskell-language-server) to view the source code, or open issues or pull requests.
1212

13-
## Building haskell-language-server
13+
## Building
1414

1515
Clone the repository:
1616
```shell
@@ -19,26 +19,18 @@ $ git clone https://github.com/haskell/haskell-language-server
1919

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

22-
haskell-language-server can also be used with itself. We provide preset samples of `hie.yaml` for Cabal and Stack.
23-
24-
Note: the `./install/` folder is not directly tied to the project so it has dedicated `./install/hie.yaml.[cbl|stack]`
25-
templates.
26-
2722
### Using Cabal
2823

2924
```shell
30-
$ cp hie-cabal.yaml hie.yaml
31-
$ cp install/hie-cabal.yaml install/hie.yaml
25+
# If you have not run `cabal update` in a while
26+
$ cabal update
27+
# Then
28+
$ cabal build
3229
```
3330

3431
### Using Stack
3532

3633
```shell
37-
$ cp hie-stack.yaml hie.yaml
38-
$ cp install/hie-stack.yaml install/hie.yaml
39-
$ cp ghcide/hie-stack.yaml ghcide/hie.yaml
40-
$ stack build --test --no-run-tests
41-
$ cd install
4234
$ stack build
4335
```
4436

@@ -119,26 +111,39 @@ An alternative, which only recompiles when tests (or dependencies) change:
119111
$ cabal run haskell-language-server:func-test -- -p "hlint enables"
120112
```
121113

122-
### Test your hacked HLS in your editor
114+
## Using HLS on HLS code
115+
116+
[HLS project configuration guidelines](../configuration.md#configuring-your-project-build) also apply to the HLS project itself.
117+
118+
Note: HLS implicitly detects HLS codebase as a Stack project (see [hie-bios implicit configuration documentation](https://github.com/haskell/hie-bios/blob/master/README.md#implicit-configuration)).
119+
If you want HLS to use Cabal, you need to create an `hie.yaml` file:
120+
```yaml
121+
cradle:
122+
cabal:
123+
```
124+
125+
Also note that the `install/` subdirectory is a different project, so if you want to work on this part of the code, you may also have to create an `install/hie.yaml` file.
123126

127+
### Manually testing your hacked HLS
124128
If you want to test HLS while hacking on it, follow the steps below.
125129

126130
To do once:
127131

128-
- Open some codebase on which you want to test your hacked HLS in your favorite editor
132+
- Open some codebase on which you want to test your hacked HLS in your favorite editor (it can also be HLS codebase itself: see previous section for configuration)
129133
- Configure this editor to use your custom HLS executable
130134
- With Cabal:
131135
- On Unix systems: `cabal exec which haskell-language-server`
132136
- On Windows: `cabal exec where haskell-language-server`
133137
- With Stack: `$(stack path --dist-dir)/build/haskell-language-server/haskell-language-server`
134138

135-
To do every time you changed code and want to test it:
139+
To do every time you change HLS code and want to test it:
136140

137141
- Build HLS
138142
- With Cabal: `cabal build exe:haskell-language-server`
139143
- With Stack: `stack build haskell-language-server:exe:haskell-language-server`
140144
- Restart HLS
141145
- With VS Code: `Haskell: Restart Haskell LSP Server`
146+
- With Emacs: `lsp-workspace-restart`
142147

143148
## Style guidelines
144149

Diff for: docs/troubleshooting.md

+25-8
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,30 @@ Example with `tasty-discover`:
2121

2222
This returns an error in HLS if 'tasty-discover' is not in the path: `could not execute: tasty-discover`.
2323

24-
## Common issues
25-
26-
### Difficulties with Stack and `Paths_` modules
24+
### Problems with multi component (tests suites, executables, benchmarks) support using stack
2725

28-
These are known to be somewhat buggy at the moment: <https://github.com/haskell/haskell-language-server/issues/478>.
29-
This issue should be fixed in Stack versions >= 2.5.
26+
Due to some limitations in the interaction between HLS and stack, there are some issues in projects with a main library and executables, test suites or benchmarks:
27+
- The stack project has to be built succesfully *before* loading it with HLS to get components other than the library work.
28+
- Changes in the library are not automatically propagated to other components, especially in the presence of errors in the library, so you have to restart HLS to get those components correctly loaded. The usual symptom is the editor showing errors like `Could not load module ...` or `Cannot satisfy -package ...`
29+
- See https://github.com/haskell/haskell-language-server/issues/366 for more info about.
30+
## Common issues
3031

3132
### Problems with dynamic linking
3233

3334
As haskell-language-server prebuilt binaries are statically linked, they don't play well with projects using dynamic linking.
3435
An usual symptom is the presence of errors containing `unknown symbol` and it is typical in arch linux, where a dynamically linked version of ghc is used.
3536

36-
The workaround is to use a version of haskell-language-server compiled from source with `-dynamic` enabled`. See more details [here](https://github.com/haskell/haskell-language-server/issues/1160#issuecomment-756566273).
37+
The workaround is to use a version of haskell-language-server compiled from source with the ghc option `-dynamic` enabled. See more details [here](https://github.com/haskell/haskell-language-server/issues/1160#issuecomment-756566273).
38+
39+
### Problems with Template Haskell
40+
41+
Due to how Template Haskell code is evaluated at compile time and some limitations in the interaction between HLS and GHC, the loading of modules using TH can be problematic.
42+
43+
The errors thrown are usually related to linking and usually make HLS crash: `Segmentation fault`, `GHC runtime linker: fatal error`, etc
44+
45+
A workaround which has helped in some cases is to compile HLS from source with the ghc option `-dynamic` enabled, as in the previous issue.
46+
47+
We have a [dedicated label](https://github.com/haskell/haskell-language-server/issues?q=is%3Aissue+is%3Aopen+label%3A%22type%3A+template+haskell+related%22) in the issue tracker and an [general issue](https://github.com/haskell/haskell-language-server/issues/1431) tracking support for TH.
3748

3849
## Troubleshooting the server
3950

@@ -56,11 +67,17 @@ sent, or if there are any errors.
5667

5768
To get a more verbose, also pass `--debug` to the executable.
5869

70+
### Identify which plugin could be the cause of the issue.
71+
72+
Sometimes the issue is produced by one of the plugins included in HLS. To diagnose that and help to trace the final cause one possible strategy is simple disable all plugins, check if the issue is gone and then enable them selectively until the issue is reproduced again.
73+
74+
There is a configuration json snippet which disables all plugins [here](https://github.com/haskell/haskell-language-server/issues/2151#issuecomment-911397030).
75+
5976
## Troubleshooting the client
6077

6178
Many clients provide diagnostic information about a LSP session.
6279
In particular, look for a way to get the status of the server, the server stderr, or a log of the messages that the client has sent to the server.
6380
For example, `lsp-mode` provides all of these (see its [troubleshooting page](https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/) for details).
81+
For vscode you can read how to access the lsp session log [here])https://github.com/haskell/vscode-haskell#investigating-and-reporting-problems).
6482

65-
The most common client-related problem is the client simply not finding the server executable, so make sure that you have the right `PATH` and you have configured
66-
it to look for the right executable.
83+
The most common client-related problem is the client simply not finding the server executable or the tools needed to load Haskell code (`ghc`, `cabal`, or `stack`). So make sure that you have the right `PATH` and you have configured the client to look for the right executables.

Diff for: ghcide/.hlint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
# Things that are unsafe in Haskell base library
134134
- {name: unsafeInterleaveIO, within: [Development.IDE.LSP.LanguageServer]}
135135
- {name: unsafeDupablePerformIO, within: []}
136-
- {name: unsafeCoerce, within: [Ide.Plugin.Eval.Code]}
136+
- {name: unsafeCoerce, within: [Ide.Plugin.Eval.Code, Development.IDE.Types.Shake]}
137137
# Things that are a bit dangerous in the GHC API
138138
- {name: nameModule, within: []}
139139

Diff for: ghcide/exe/Main.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Development.IDE (Priority (Debug, Info),
1414
action)
1515
import Development.IDE.Core.OfInterest (kick)
1616
import Development.IDE.Core.Rules (mainRule)
17+
import Development.IDE.Core.Tracing (withTelemetryLogger)
1718
import Development.IDE.Graph (ShakeOptions (shakeThreads))
1819
import qualified Development.IDE.Main as Main
1920
import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde
@@ -39,7 +40,7 @@ ghcideVersion = do
3940
<> gitHashSection
4041

4142
main :: IO ()
42-
main = do
43+
main = withTelemetryLogger $ \telemetryLogger -> do
4344
let hlsPlugins = pluginDescToIdePlugins GhcIde.descriptors
4445
-- WARNING: If you write to stdout before runLanguageServer
4546
-- then the language server will not work
@@ -55,6 +56,7 @@ main = do
5556

5657
Main.defaultMain arguments
5758
{Main.argCommand = argsCommand
59+
,Main.argsLogger = Main.argsLogger arguments <> pure telemetryLogger
5860

5961
,Main.argsRules = do
6062
-- install the main and ghcide-plugin rules

Diff for: ghcide/ghcide.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ library
7777
rope-utf16-splay,
7878
safe,
7979
safe-exceptions,
80-
hls-graph ^>= 1.5,
80+
hls-graph ^>= 1.5.1,
8181
sorted-list,
8282
sqlite-simple,
8383
stm,

0 commit comments

Comments
 (0)