-
Notifications
You must be signed in to change notification settings - Fork 155
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
Draft: Implement a language server #100
Conversation
Wow @fwcd -- this is great! Super happy to see this I will check it out soon and play with it. One request, can you base it of the latest Also, I see you moved to GHC 8.8 -- we can do that but I am a bit worried about pulling in new dependencies on dependent type extensions; can we work around that? Similarly for the "lens" library? (I would like to limit dependencies on intricate Haskell features as much as possible with an eye towards a future Koka version) Thanks again! |
Just to add: note in the documentation on https://koka-lang.github.io/koka/doc/book.html you can see the tooltips when hovering over checked code (with a green border): these tooltips are generated by the |
Hi @daanx, sure, I will rebase the branch! The LSP library unfortunately requires GHC 8.8 due to haskell/lsp#263 and pulls in these dependent type extensions (which had to be mentioned explicitly here, due to not being available on Stackage yet). Also, the lenses are mostly just a convenience, so not really needed, though the LSP library uses them internally if I recall correctly. Perhaps building the language server as a separate executable would be a better option? That would keep these dependencies more cleanly decoupled from the core compiler, though I am not sure how well that would fit into the current architecture. Generating hovers using the existing colorization seems like a great idea, I will have a look at that. :) |
Required to build the latest version of the lsp library
as Monad.fail was removed from GHC 8.8
Use 'error' for now
'vscode' is deprecated.
No problem, I have merged the |
Super! It is amazing that you were able to create this in less than a week! :-) I just tried it out -- it build correctly but then the It looks like this:
|
More generally, how does this work? I am surprised we still need typescript? I thought it was all Haskell with a single executable. I saw it needed a ton more libraries etc than plain Koka -- I think it is indeed best to make this a separate executable; what do you think is the best way forward? I thought:
Anyway, cannot wait to get this running :-) Will it work on macOS as well? |
Ooh, it just built.. :-) |
Ah, there seemed to be some inconsistency with the declared VSCode dependency. Re-running The TypeScript/JavaScript part is a little bit of glue code that tells VSCode where to find and how to run the language server executable. Everything else is implemented in Haskell though. The entire language server source code in located in Also, sure, it runs on macOS and Linux just fine (I've tested it on both). :) |
It works! Amazing! I need to play with it more but this is incredible. Very cool! Some quick question:
Very fun -- thanks for starting this project! |
Signature help (also context-aware completion) is a bit more difficult to implement than regular completion as it involves working with the 'broken' AST as the user types. I haven't looked into it that much yet, but that would definitely be nice to have. Ideally, the language server should recompile on every keystroke, possibly with a short debouncer/delay, so it can show errors and warnings in real-time. This would, however, require passing the source text directly to the compiler rather than just the file paths, since the file contents might not have been saved to disk (The |
Both the language and the compiler are very fun to experiment with, so thank you for all the work that went into it! Also, the approach of declaring effects rather than using monad transformers seems really interesting to me. :) |
What's the status of this? Would be nice to have a LSP for Koka! |
Thanks, cool work! Really happy to see this being picked up again. It has been a while since I've worked on this, so I am afraid I can't comment much on the code, but that sounds pretty good. |
This branch contains some experimental work on implementing the proposed language server. In particular, it uses the
lsp
library and adds a new mode that can be invoked by runningAdditionally, the VSCode extension now supports talking to the language server, provided that the appropriate paths have been configured (this is done through a VSCode setting,
koka.languageServer.command
andkoka.languageServer.enabled
).Implemented LSP features:
...
Screenshots:
See more
Development
To set up VSCode for language server development, do the following:
stack build
<repo>/support/vscode/koka.language-koka
and run:npm install
to install the dependenciesnpm run build
to compile the extension (or, alternatively,npm run watch
to continuously recompile it in the background)<repo>/.vscode/launch.json
with the following:settings.json
: