-
Notifications
You must be signed in to change notification settings - Fork 206
Implement the HIE Bios #1126
Implement the HIE Bios #1126
Changes from 250 commits
b054fe9
3ff19ba
f163539
fac0e95
4231b0b
8fe05bb
3e907c8
ab595a0
94eaa52
0f0c250
671d5ef
19a106d
e001a1b
8cd96b1
5180d25
973d4a2
ed9fefa
4ec8a13
3b41a98
9e7af09
0f507e6
e132d54
5373788
b9ebbec
ca06bd6
4f886df
daf0be5
8e44c14
30fb1e7
5ab587c
40342a0
cd882b6
ca53013
6f905aa
a305239
580b188
2c8b51b
0438ac0
9c7365f
c5f7d28
775eca2
d25984c
2bd16d8
f5a0308
94c3bcf
092c7a2
805961d
0d3af55
2feab0a
c619b66
3d96c12
a78b6a3
1b1bf14
1cbae78
0bfd54f
fb61925
373a474
a112dbb
6d8bd90
65d700b
7eb37df
2e36879
c243b50
98d8668
e83022e
6d9df0f
0738eb4
4031ac6
03473c9
5a5648d
5e09ef9
9039bcf
e631b58
c401bb2
4ff9a38
df764c3
50f4fe9
1cc08c4
6df6c64
46a986a
52601c9
80270ff
f91070d
f41edf2
d7403d2
54becfd
07f1dcd
3fb0985
4c96f82
3f84a89
794aa9a
bc5ff6f
57737df
4afb084
3752ac9
a7ec5fc
568cca1
7fbacf7
db18602
dd9cbdd
15037a4
48d29b1
10355fe
fdb4696
3be0213
40b6073
2505e45
c1824ed
f9756db
87eb220
5642252
9e3a4e0
5b56c15
2f006c7
fa65724
4f61966
eb3d32e
48958d8
c52a982
2ff3893
8dae303
172a557
f561472
582ff05
1cf6ab7
3dcedf8
89f8d83
52940fb
26d0ddd
a1bac07
294c401
52b60ba
ae844a0
7def514
799bfd6
408b0b5
2fdcb3a
c41eed0
2ffb17e
b72e606
91a56b0
b28e944
c84b33f
ed6d66b
83c5090
cc40b6f
7e7bd1d
92add4e
c45714e
0517eaa
97e6617
b775f13
b4f2326
9ceec1e
4309653
9ee8156
232e7d6
e1da603
3ed7833
a19ff9c
4a80ec3
d79e033
6a9b727
52691a6
e3fa438
3bfd965
e0a30bf
d109948
e8b4bee
b0a01e7
9fc2dcc
73fcf4b
702a5f5
1ca4e0a
d228c02
523da4d
dc8dab1
714f42a
dcf81a1
3795616
532aa60
61b6ba8
d30d058
32a6739
c2e4bfc
c6e7f31
924de7c
d467264
a0296ae
58c4019
8c3c350
4c5308b
7541d1e
7c206de
c983469
4bd1e75
90e1444
7681038
e212df1
d3d8ac2
41b9cab
8701f8b
9f5ef1b
fea7271
62267a5
361f6ef
ec3d362
b0b0c95
16f2580
31209a6
9ce648a
a173297
25bcde6
43cf0d1
bc079e9
bd40ac3
03d9bf2
0d44704
3ff767e
0effcf4
305b2d5
67d0903
8e91d80
9819903
ae8aa22
b7dfd2b
1b9767d
8e0241c
49582c2
3476f19
1a05e42
501cb28
cd0d1eb
a79ec33
c5b8a4b
b1363df
c4c04ce
89fe99d
20255f2
84e645c
c94b45e
cd3cd02
c193254
df1ac8a
6cbadc7
5dfc446
6f1c220
8e9bb3d
58ac672
bfedd03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,6 @@ _build/ | |
# stack 2.1 stack.yaml lock files | ||
stack*.yaml.lock | ||
shake.yaml.lock | ||
|
||
# ignore hie.yaml's for testdata | ||
test/**/*.yaml | ||
Comment on lines
+78
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably want to ignore any hie.yaml There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we automatically generate the hie.yaml files again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the tests. The tests need a |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,20 +10,12 @@ | |
# rm -rf path_to_submodule | ||
|
||
|
||
[submodule "submodules/HaRe"] | ||
path = submodules/HaRe | ||
# url = https://github.com/bubba/HaRe.git | ||
url = https://github.com/alanz/HaRe.git | ||
|
||
[submodule "submodules/cabal-helper"] | ||
path = submodules/cabal-helper | ||
# url = https://github.com/arbor/cabal-helper.git | ||
url = https://github.com/alanz/cabal-helper.git | ||
# url = https://github.com/DanielG/cabal-helper.git | ||
# Change this back once https://github.com/DanielG/cabal-helper/pull/85/ merged | ||
url = https://github.com/bubba/cabal-helper.git | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these still the right remotes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, we could look at DanielG c-h directly. |
||
|
||
[submodule "submodules/ghc-mod"] | ||
path = submodules/ghc-mod | ||
# url = https://github.com/arbor/ghc-mod.git | ||
# url = https://github.com/bubba/ghc-mod.git | ||
url = https://github.com/alanz/ghc-mod.git | ||
|
||
url = https://github.com/fendor/ghc-mod.git | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need an issue which details what to do to remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, we want to subsume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moreover, if we take There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did discuss that with @DanielG , he is happy for us to move it elsewhere, possibly as a sub-project inside haskell-ide-engine. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,16 +30,18 @@ we talk to clients.__ | |
- [Windows-specific pre-requirements](#windows-specific-pre-requirements) | ||
- [Download the source code](#download-the-source-code) | ||
- [Building](#building) | ||
- [Install via cabal](#install-via-cabal) | ||
- [Install specific GHC Version](#install-specific-ghc-version) | ||
- [Multiple versions of HIE (optional)](#multiple-versions-of-hie-optional) | ||
- [Configuration](#configuration) | ||
- [Explicit Configuration](#explicit-configuration) | ||
- [Editor Integration](#editor-integration) | ||
- [Using HIE with VS Code](#using-hie-with-vs-code) | ||
- [Using VS Code with Nix](#using-vs-code-with-nix) | ||
- [Using HIE with Sublime Text](#using-hie-with-sublime-text) | ||
- [Using HIE with Vim or Neovim](#using-hie-with-vim-or-neovim) | ||
- [Coc](#Coc) | ||
- [LanguageClient-neovim](#LanguageClient-neovim) | ||
- [Coc](#coc) | ||
- [LanguageClient-neovim](#languageclient-neovim) | ||
- [vim-plug](#vim-plug) | ||
- [Clone the LanguageClient-neovim repo](#clone-the-languageclient-neovim-repo) | ||
- [Sample `~/.vimrc`](#sample-vimrc) | ||
|
@@ -104,7 +106,7 @@ we talk to clients.__ | |
|
||
 | ||
|
||
- Renaming via HaRe | ||
- Renaming via HaRe (NOTE: HaRe it's not available temporary) | ||
fendor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
 | ||
|
||
|
@@ -228,17 +230,16 @@ stack ./install.hs stack-install-cabal | |
|
||
##### Install specific GHC Version | ||
|
||
Install **Nightly** (and hoogle docs): | ||
Install hie for the latest available and supported GHC version (and hoogle docs): | ||
|
||
```bash | ||
stack ./install.hs hie-8.6.4 | ||
stack ./install.hs build-data | ||
stack ./install.hs build | ||
``` | ||
|
||
Install **LTS** (and hoogle docs): | ||
Install hie for a specific GHC version (and hoogle docs): | ||
|
||
```bash | ||
stack ./install.hs hie-8.4.4 | ||
stack ./install.hs hie-8.6.5 | ||
stack ./install.hs build-data | ||
``` | ||
|
||
|
@@ -303,6 +304,100 @@ There are some settings that can be configured via a `settings.json` file: | |
- VS Code: These settings will show up in the settings window | ||
- LanguageClient-neovim: Create this file in `$projectdir/.vim/settings.json` or set `g:LanguageClient_settingsPath` | ||
|
||
## Explicit Configuration | ||
|
||
**For a full explanation of possible configuration, we refer to [hie-bios/README](https://github.com/mpickering/hie-bios/blob/master/README.md).** | ||
|
||
The user can place a `hie.yaml` file in the root of the workspace which | ||
describes how to setup the environment. For example, to explicitly state | ||
that you want to use `stack` then the configuration file would look like: | ||
|
||
```yaml | ||
cradle: {stack} | ||
fendor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
If you use `cabal` then you probably need to specify which component you want | ||
to use. | ||
|
||
```yaml | ||
cradle: | ||
cabal: | ||
component: "lib:haskell-ide-engine" | ||
``` | ||
|
||
Or you can explicitly state the program which should be used to collect | ||
the options by supplying the path to the program. It is interpreted | ||
relative to the current working directory if it is not an absolute path. | ||
|
||
```yaml | ||
cradle: | ||
bios: | ||
program: ".hie-bios" | ||
``` | ||
|
||
The complete configuration is a subset of | ||
|
||
```yaml | ||
cradle: | ||
cabal: | ||
component: "optional component name" | ||
stack: | ||
bazel: | ||
obelisk: | ||
bios: | ||
program: "program to run" | ||
dependency-program: "optional program to run" | ||
direct: | ||
arguments: ["list","of","ghc","arguments"] | ||
default: | ||
none: | ||
|
||
dependencies: | ||
- someDep | ||
``` | ||
fendor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
There is also support for multiple cradles in a single `hie.yaml`. An example configuration for Haskell IDE Engine: | ||
|
||
```yaml | ||
cradle: | ||
multi: | ||
- path: ./test/dispatcher/ | ||
config: | ||
cradle: | ||
cabal: | ||
component: "test:dispatcher-test" | ||
- path: ./test/functional/ | ||
config: | ||
cradle: | ||
cabal: | ||
component: "test:func-test" | ||
- path: ./test/unit/ | ||
config: | ||
cradle: | ||
cabal: | ||
component: "test:unit-test" | ||
- path: ./hie-plugin-api/ | ||
config: | ||
cradle: | ||
cabal: | ||
component: "lib:hie-plugin-api" | ||
- path: ./app/MainHie.hs | ||
config: | ||
cradle: | ||
cabal: | ||
component: "exe:hie" | ||
- path: ./app/HieWrapper.hs | ||
config: | ||
cradle: | ||
cabal: | ||
component: "exe:hie-wrapper" | ||
- path: ./ | ||
config: | ||
cradle: | ||
cabal: | ||
component: "lib:haskell-ide-engine" | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the lightweight-cabal syntax here I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it should show how to define multi-cradles. Mutli-Cabal version is a bit above |
||
|
||
## Editor Integration | ||
|
||
Note to editor integrators: there is now a `hie-wrapper` executable, which is installed alongside the `hie` executable. When this is invoked in the project root directory, it attempts to work out the GHC version used in the project, and then launch the matching `hie` executable. | ||
|
@@ -545,10 +640,10 @@ Or you can set the environment variable `HIE_HOOGLE_DATABASE` to specify a speci | |
### Planned Features | ||
|
||
- [x] Multiproject support | ||
- [x] New-build support | ||
- [ ] Project wide references | ||
- [ ] Cross project find definition | ||
- [ ] New-build support | ||
- [ ] HaRe refactorings | ||
- [ ] More HaRe refactorings | ||
- [ ] More code actions | ||
- [ ] Cross project/dependency Find Definition | ||
- [ ] Case splitting, type insertion etc. | ||
|
@@ -644,18 +739,43 @@ Delete any `.ghc.environment*` files in your project root and try again. (At the | |
#### Otherwise | ||
Try running `cabal update`. | ||
|
||
### Nix: cabal-helper, No such file or directory | ||
### Liquid Haskell | ||
|
||
Liquid Haskell requires an SMT solver on the path. We do not take care of installing one, thus, Liquid Haskell will not run until one is installed. | ||
The recommended SMT solver is [z3](https://github.com/Z3Prover/z3). To run the tests, it is also required to have an SMT solver on the path, otherwise the tests will fail for Liquid Haskell. | ||
|
||
### Profiling `haskell-ide-engine`. | ||
|
||
An error on stderr like | ||
If you think `haskell-ide-engine` is using a lot of memory then the most useful | ||
thing you can do is prepare a profile of the memory usage whilst you're using | ||
the program. | ||
|
||
1. Add `profiling: True` to the cabal.project file of `haskell-ide-engine` | ||
2. `cabal new-build hie` | ||
3. (IMPORTANT) Add `profiling: True` to the `cabal.project` file of the project you want to profile. | ||
4. Make a wrapper script which calls the `hie` you built in step 2 with the additional options `+RTS -hd -l-au` | ||
5. Modify your editor settings to call this wrapper script instead of looking for `hie` on the path | ||
6. Try using `h-i-e` as normal and then process the `*.eventlog` which will be created using [`eventlog2html`](http://hackage.haskell.org/package/eventlog2html). | ||
7. Repeat the process again using different profiling options if you like. | ||
|
||
#### Using `ghc-events-analyze` | ||
|
||
`haskell-ide-engine` contains the necessary tracing functions to work with [`ghc-events-analyze`](http://www.well-typed.com/blog/2014/02/ghc-events-analyze/). Each | ||
request which is made will emit an event to the eventlog when it starts and finishes. This way you | ||
can see if there are any requests which are taking a long time to complete or are blocking. | ||
|
||
1. Make sure that `hie` is linked with the `-eventlog` option. This can be achieved by adding the flag | ||
to the `ghc-options` field in the cabal file. | ||
2. Run `hie` as normal but with the addition of `+RTS -l`. This will produce an eventlog called `hie.eventlog`. | ||
3. Run `ghc-events-analyze` on the `hie.eventlog` file to produce the rendered SVG. Warning, this might take a while and produce a big SVG file. | ||
|
||
The default options for `ghc-events-analyze` will produce quite a wide chart which is difficult to view. You can try using less buckets in order | ||
to make the chart quicker to generate and faster to render. | ||
|
||
``` | ||
cabal-helper-wrapper: /home/<...>/.cache/cabal-helper/cabal-helper<...>: createProcess: runInteractiveProcess: | ||
exec: does not exist (No such file or directory) | ||
ghc-events-analyze hie.eventlog -b 100 | ||
``` | ||
|
||
can happen because cabal-helper compiles and runs above executable at runtime without using nix-build, which means a Nix garbage collection can delete the paths it depends on. Delete ~/.cache/cabal-helper and restart HIE to fix this. | ||
This support is similar to the logging capabilities [built into GHC](https://www.haskell.org/ghc/blog/20190924-eventful-ghc.html). | ||
|
||
### Liquid Haskell | ||
|
||
Liquid Haskell requires an SMT solver on the path. We do not take care of installing one, thus, Liquid Haskell will not run until one is installed. | ||
The recommended SMT solver is [z3](https://github.com/Z3Prover/z3). To run the tests, it is also required to have an SMT solver on the path, otherwise the tests will fail for Liquid Haskell. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,9 @@ import Data.Semigroup | |
import Data.List | ||
import Data.Foldable | ||
import Data.Version (showVersion) | ||
import qualified GhcMod.Monad as GM | ||
import qualified GhcMod.Monad.Types as GM | ||
import qualified GhcMod.Types as GM | ||
import HIE.Bios | ||
import Haskell.Ide.Engine.MonadFunctions | ||
import Haskell.Ide.Engine.Cradle (findLocalCradle) | ||
import Haskell.Ide.Engine.Options | ||
import Haskell.Ide.Engine.Plugin.Base | ||
import qualified Language.Haskell.LSP.Core as Core | ||
|
@@ -23,6 +22,7 @@ import System.Environment | |
import qualified System.Log.Logger as L | ||
import System.Process | ||
import System.Info | ||
import System.FilePath | ||
|
||
-- --------------------------------------------------------------------- | ||
|
||
|
@@ -73,15 +73,13 @@ run opts = do | |
logm $ "Current directory:" ++ d | ||
logm $ "Operating system:" ++ os | ||
|
||
-- Get the cabal directory from the ghc-mod cradle | ||
(mcr,_) <- GM.runGhcModT GM.defaultOptions GM.cradle | ||
dir <- case mcr of | ||
Left err -> error (show err) | ||
Right cr -> return $ GM.cradleRootDir cr | ||
-- Get the cabal directory from the cradle | ||
cradle <- findLocalCradle (d </> "File.hs") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure this will work well with multi-cradle projects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wont, we have to tackle it in hie-bios There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I manually tested and documented how I intend it to work in https://github.com/mpickering/haskell-ide-engine/blob/hie-bios/hie-plugin-api/Haskell/Ide/Engine/Cradle.hs#L256 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this will work in a best effort manner, imo. |
||
let dir = cradleRootDir cradle | ||
logm $ "Cradle directory:" ++ dir | ||
setCurrentDirectory dir | ||
|
||
ghcVersion <- getProjectGhcVersion | ||
ghcVersion <- getProjectGhcVersion cradle | ||
logm $ "Project GHC version:" ++ ghcVersion | ||
|
||
let | ||
|
Uh oh!
There was an error while loading. Please reload this page.