jonnyboyC / kos-language-server

A language server for the Kerboscript (kOS) a language for Kerbal Space Program
MIT License
27 stars 6 forks source link

[Feature] add support for Sublime Text via LSP #200

Open trench8891 opened 1 year ago

trench8891 commented 1 year ago

Is your feature request related to a problem? Please describe. As an avid user of Sublime Text it is my editor of choice when writing KOS scripts, so it would be nice to be able to use it with the language server as well.

Describe the solution you'd like A provided example of how to configure the Sublime Text Language Server Protocol (LSP) package to use the language server.

Describe alternatives you've considered I've tried implementing it myself (and will continue to do so), but I have no previous experience with language servers and am mostly groping in the dark.

Additional context Ultimately my intention is to have a tool that I can use to quickly identify problems with KOS scripts without having to try to run them in-game. This language server seems to be the closest starting point but I'm not familiar enough yet with language servers to close the gap. I figure a good first step will be to be able to use it at all with an editor.

trench8891 commented 1 year ago

I was able to get it working with the following LSP.sublime-settings contents:

{
  "clients": {
    "kos": {
      "enabled": true,
      "command": [
        "kls",
        "--stdio"
      ],
      "selector": "source.kos",
      "env": {
        "PATH": "/Users/<username>/.nvm/versions/node/v12.18.2/bin"
      }
    }
  }
}

The selector part works thanks to the kOS syntax highlighting for Sublime Text 3, and without using that some other homespun file scoping would be required.

Also the subprocess needs to have a PATH (or Path for Windows, probably) environment variable to include the node (and coincidentally kls) executables.

Also although I've got sublime making use of the server, I'm getting a lot of unexpected errors. My guess is although I've got a ksconfig.json file in my project, it's not placed in a way that the server finds and uses it, so I need to do some experimenting with that.

trench8891 commented 1 year ago

Unfortunately no amount of experimentation on my part has yielded any result that looks like the server is actually finding/reading/respecting the ksconfig.json file, despite the fact that it looks like it certainly should. My best guess is that it's somehow similar to #167, even though the observed behavior there is somewhat different than in this case.