koka-lang / koka

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

Updated Language Server #338

Closed TimWhiting closed 11 months ago

TimWhiting commented 1 year ago

What the title says, updated to latest dev branch, and got it working, with a couple of improvements.

There is less configuration required now. You can still explicitly specify the Koka executable path, but by default it searches in three locations. First it looks for the Koka repo in the users home directory and looks for the most recent stack build. Then it looks in ~/local/bin, finally it looks for it in the system path. It also selects the current workspace folder as the default folder to be the cwd, and the language server is turned on by default.

It also uses the virtual file system now, using the contents from the client which includes unsaved changes/edits. This allows for the parse / type errors to show up as you are typing, rather than only when you save.

After this PR or until it gets merged I'll can work on some tests.

Additionally I want to add support for generating standard methods like show / ==. Probably based on my progress in #335 (but unlike that PR not inserted automatically which can be difficult to catch all of the cases with generics & kinds)

Steps:

Debug configuration is here (add to .vscode/launch.json)

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
        "args": [
            "--extensionDevelopmentPath=${workspaceFolder}/support/vscode/koka.language-koka"
        ],
        "name": "Launch Extension",
        "outFiles": [
            "${workspaceFolder}/support/vscode/koka.language-koka/out/**/*.js"
        ],
        "request": "launch",
        "type": "extensionHost"
    }
]
}
TimWhiting commented 1 year ago

@CaramelFur I'm not sure how to get your commits to be fully verified here? I cherry picked them onto the dev branch, and added my commits on top.

Edit, it looks like I caused this issue by doing a rebase. I guess I'll have to go back and do some git stuff to fix this.

TimWhiting commented 1 year ago

Update, I've added support to run koka files. You can create a run configuration (just executes koka -e -i{vscodeWorkspaceDirectory}, and pipes the result to the debug console). It also provides codeLenses, so you can run any koka file directly from a hint above the main function.