commercialhaskell / commercialhaskell/stack-ide
Update editor integration to new loading approach
- Dominant language
- Emacs Lisp
- Stars
- 96
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Opening this issue to notify interested users and authors of editor bindings to stack-ide. This update requires you to update both `stack` and `stack-mode`. `stack-ide` the binary itself has no changes, but you can update anyway if you like.
The way loading is done with stack-ide has changed now. Initially, it would work like this:
1. stack-ide is launched by stack, and stack sends the list of load targets (modules) to load.
2. stack-ide would then load these modules and report errors.
3. Your editor would send `RequestUpdateSession` with empty contents.
Now, it's like this:
1. `stack ide` is launched by the editor via `stack ide start ` (that can be acquired by `stack ide packages`).
2. Your editor should call `stack ide load-targets ` to get a list of modules that are in the project.
3. Your editor then sends `RequestUpdateSession` when it wants to load module(s):
``` json
{
"tag": "RequestUpdateSession",
"contents": [
{
"tag": "RequestUpdateTargets",
"contents": {
"tag": "TargetsExclude",
"contents": [
"src/Control/Concurrent/Execute.hs",
"src/Stack/Package.hs"
]
}
},
{
"tag": "RequestUpdateTargets",
"contents": {
"tag": "TargetsInclude",
"contents": [
"src/Stack/Package.hs"
]
}
}
]
}
```
This request will load everything necessary for `Stack.Package` and no more. The two target updates are monoidal, so the latter overrides the former (this is why you can specify Package.hs in both, a small convenience). This is much faster than the previous approach of loading everything every time. When you _do_ want to load everything, you can put the complete list of modules in `TargetsInclude` and omit `TargetsExclude` entirely.
Reference implementation in Emacs here: https://github.com/commercialhaskell/stack-ide/blob/master/stack-mode/stack-mode.el#L892-L911
In `stack-mode` this keybinding is now:
- C-c C-l - load the current module.
- C-c C-c - compile all modules.
This can be seen as analogous to `:l` in GHCi vs `cabal build`. The flycheck behaviour uses the `C-c C-l` case -- it only compiles the current module. When you want to check all modules, `C-c C-c` will trigger flycheck for all modules.
Pinging @lukexi ([stack-ide-sublime](https://github.com/lukexi/stack-ide-sublime) author).
Pinging @snoyberg @mgsloan @LukeHoersten @dysinger @CRogers.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.