koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.16k stars 151 forks source link

Language server #346

Closed TimWhiting closed 6 months ago

TimWhiting commented 11 months ago

I've reset the commit history here since this PR no longer looks much like the original PR. This PR is updated to the latest Haskell LSP libraries, uses the LSP library's virtual file system to support unsaved changes, and has support for VSCode run configuration of Koka files. Syntax errors are no longer immediately sent to stdout so that it doesn't mess with the server protocol.

I'll go through and make some comments in this PR or in the code for things to note.

TimWhiting commented 11 months ago

Several updates fixing a few bugs, reusing modules in memory that have already been typechecked, better completions based on types and better logging and compile & run support via language server.

TimWhiting commented 10 months ago

Updated the binary files for the sample release here, should be a lot more responsive, and has exception handling and some fixes so it no longer thinks it has a different file open when you are hovering: https://github.com/TimWhiting/koka/releases/tag/v2.4.2-language-server

TimWhiting commented 10 months ago

Updated extension with ability to pass in extra compiler arguments to the run/debug configuration

TimWhiting commented 9 months ago

An update:

For small projects, the language server works really well. For large projects or large files, the compiler is slow, and takes a ton of memory. I've run into some sort of memory leak. I'm not super familiar with debugging Haskell memory leaks - especially due to it's laziness. The memory leak might be in the existing compiler, but just doesn't manifest due to the short runtime of the process, I'm not sure where to go from here. I did look at how to configure the runtime options for Haskell to capture a heap profile, but for whatever reason, when I terminate the process it doesn't write it out - I'm probably sending the wrong signal.

TimWhiting commented 8 months ago

Latest prebundled release assets that I have generated: Several improvements since the last release.

https://github.com/TimWhiting/koka/releases/tag/v2.4.3-lang-server

TimWhiting commented 7 months ago

With the most recent changes, there are a lot of improvements, including some fixes for windows paths.

That being said, I'm sure there are still likely small bugs with it. It should not change the normal compilation process, and should not affect the interpreter, so you should always be able to fall back on that model of compilation. Additionally restarting the vscode window or the language server can get rid of many temporary issues. Please report issues as you find them though so we can get as many bugs worked out before releasing this.

Precompiled binaries and the vscode extension are currently available here: https://github.com/TimWhiting/koka/releases/tag/v2.4.3-lang-server7

I'm working with Daan to get the changes integrated in the next release, in addition to a few other fixes in recent PRs (which are included in the precompiled release linked above).

TimWhiting commented 6 months ago

Moving to lang-server2.1 branch