-
-
Notifications
You must be signed in to change notification settings - Fork 391
Auto detect added dependencies #1113
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
Comments
This is super easy to add on the ghcide side once we get the necessary information out of |
Trickier part will be to report when cradle can't build as per #710 |
@ndmitchell is there some kind of watching api for file changes in ghcide or did you plan to use notify? |
@domenkozar there is an LSP API for file watching which we should use. |
bump (this would be really helpful) |
Now that hie-bios provides the information about cradle dependencies (haskell/hie-bios#35), can someone implement this? Some editor plugins can stop/restart the LSP server but others don't, and it's really annoying to quit and restarting the editor whenever this happens. |
Should be easy to implement when someone has the time. Patch welcome, but otherwise it's waiting for someone to have this at the top of their queue. I also requested restarting in #979, I agree it would be super useful. |
Agreed that #979 would be quite useful as an escape hatch. Can you give me some hints on how this can be implemented? I have a vague idea that the file watching should be used (either using the LSP API if the client supports it, or ghcide's own support otherwise), and then the language server must be restarted somehow if a file being watched is updated or created. But I'm not quite sure how/where it should be hooked into existing code. |
I think the approach would involve the code at https://github.com/digital-asset/ghcide/blob/master/exe/Main.hs#L204-L207. You get a cradle back, then in the |
Thanks, Neil! I'll give it a shot. |
@ndmitchell , when you said Or did you mean something else? |
I just mean the normal Development.Shake.need. It's possible that those are better because they get tracking through the file watching, but I'm not familiar enough to know if they'd work better. |
Using So it seems we need a way to invalidate the memoization cache. Whenever any dependency files change, we invalidate the cache, and call |
Ah, good point - you probably need to switch from memoIO to Unfortunately, there's an issue around newCacheIO which is why I went for memoIO in the first place ndmitchell/shake#725. Maybe it needs to be lifted into an oracle? I suspect these complexities were why I didn't do it last time I thought about it... |
Hm.. Not only that. Now I realize that we need to restart the whole language server when files like Which means we need to add a way to stop the current language server and restart it. This is getting out of hand 😱 |
No need to restart the language server - you just have to move the setting up of |
All right. Following what you suggested, I made it work barring a few problems. Let me clean it up and hopefully I can send a PR soon. |
I think this can be closed now. |
Thanks for your work on this @jinwoo |
Currently
ghcide
doesn't notice when I update eitherpackage.yaml
or*.cabal
; so I need to restart it, up till now I've been closing and re-opening my editor, but now I just runkillall ghcide
; it picks up on the changes when it restarts.It'd be nice if it could detect changes to those files and restart itself automagically.
Thanks for all the work you do!
The text was updated successfully, but these errors were encountered: