aardappel / lobster

The Lobster Programming Language
http://strlen.com/lobster
2.25k stars 119 forks source link

Small LSP setup issue #329

Open lesleyrs opened 2 weeks ago

lesleyrs commented 2 weeks ago

In order to get LSP to work in https://github.com/helix-editor/helix I had to make these changes in order to return early and use lobster as exe:

-const defaultSettings: LobsterSettings = { executable: '', imports: [], experimental: false };
+const defaultSettings: LobsterSettings = { executable: 'lobster', imports: [], experimental: false };

 export class LSPInstance {
     connection: Connection;
@@ -80,7 +80,7 @@ export class LSPInstance {
     }

     async getDocumentSettings(uri: URI): Promise<LobsterSettings> {
-        if (!this.hasConfigurationCapability) {
+        if (this.hasConfigurationCapability) {
             return Promise.resolve(this.globalSettings);
         }

Otherwise it fails on readConfiguration:

            if (c.executable.length == 0)
                return throwError("Lobster executable path is not set.");

Not sure if that is for vscode in specific or something? This is the config I was using, you need to create languages.toml in helix config dir and add this:

[language-server.lobster]
command = "node"
args = ["lobster_lsp.js", "--stdio"]

[[language]]
name = "lobster"
language-servers = ["lobster"]
scope = "source.lobster"
file-types = ["lobster"]
comment-tokens = ["//"]
block-comment-tokens = [{ start = "/*", end = "*/" }]

You can see stdout errors inside helix with :log-open. This requires to have the exe and lsp in same dir as you run hx, could also use this batchfile and change the command+first arg above to whatever you save it as:

@echo off

node "%~dp0lobster_lsp.js" %*
lesleyrs commented 2 weeks ago

@ewoudje