Skip to content
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

Language server #346

Closed
wants to merge 39 commits into from
Closed

Language server #346

wants to merge 39 commits into from

Conversation

TimWhiting
Copy link
Collaborator

@TimWhiting TimWhiting commented Jul 20, 2023

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 TimWhiting force-pushed the lang-server2.0 branch 5 times, most recently from 447d0d0 to e3c0fd4 Compare July 25, 2023 06:21
@TimWhiting
Copy link
Collaborator Author

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
Copy link
Collaborator Author

TimWhiting commented Aug 22, 2023

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
Copy link
Collaborator Author

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

@TimWhiting TimWhiting changed the base branch from master to dev September 8, 2023 02:39
@TimWhiting
Copy link
Collaborator Author

TimWhiting commented Sep 21, 2023

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.

Copy link
Collaborator Author

@TimWhiting TimWhiting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @daanx

I've added a few comments to this PR, and did some cleanup. This PR should be a lot cleaner now. I believe the current approach in Compile.hs should make a lot more sense than my prior approach since I understand it better now, but I haven't used it as extensively yet. I believe the memory issues to be less of a problem than mentioned previously, though likely still present.

src/Common/Syntax.hs Show resolved Hide resolved
src/Compiler/Compile.hs Show resolved Hide resolved
src/Compiler/Compile.hs Show resolved Hide resolved
src/Compiler/Compile.hs Outdated Show resolved Hide resolved
src/Compiler/Compile.hs Show resolved Hide resolved
src/LanguageServer/Handler/Commands.hs Outdated Show resolved Hide resolved
src/Lib/Printer.hs Show resolved Hide resolved
src/Syntax/Parse.hs Show resolved Hide resolved
src/Type/Infer.hs Show resolved Hide resolved
src/Type/Pretty.hs Show resolved Hide resolved
@TimWhiting TimWhiting force-pushed the lang-server2.0 branch 2 times, most recently from 1852cb2 to 4a65beb Compare October 23, 2023 22:15
@TimWhiting
Copy link
Collaborator Author

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
Copy link
Collaborator Author

TimWhiting commented Dec 3, 2023

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

  • Even when compiling a file results in an error, all of the successfully compiled module results are kept around
  • All modules are only typechecked and not fully compiled until you request a full compilation (by for example running a main function)
  • When generating output it will use the typechecked version and just perform the rest of the compilation

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 TimWhiting force-pushed the lang-server2.0 branch 2 times, most recently from 04a4cf8 to d2654d0 Compare December 5, 2023 01:01
@TimWhiting
Copy link
Collaborator Author

Moving to lang-server2.1 branch

@TimWhiting TimWhiting closed this Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants