jonnyboyC / kos-language-server

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

[Feature] Emacs Support #55

Open LeonardMH opened 5 years ago

LeonardMH commented 5 years ago

I would like to see some support for Emacs, either as a full major mode (syntax highlighting, minor-mode configuration, code completion) or just for code completion (perhaps as a company-mode backend).

I have been hacking away at my own major mode (with some additional language extensions) ksx-mode. This would probably be a good starting point, it is derived from quite liberally from @jarpy's ks-mode which was otherwise the most complete kOS major mode I could find.

It has satisfying enough syntax highlighting, but semantic completions would be very much appreciated.

example

jonnyboyC commented 5 years ago

Thanks for the request, glad you found the repo! I haven't truly used emacs but the major mode you linked to will definitely be a good start. I'll try to evaluate what would be the best approach to incorporating this project into emacs and keep this request posted as progress is made.

LeonardMH commented 5 years ago

Sounds good, I'm happy to work on this, esp on the emacs side. I'm just not all that familiar with js/ts so am not sure of the best way to start on this.

jonnyboyC commented 5 years ago

Some general links on language servers if you're interested!

Ideally we should be able to leverage an existing emacs language server client incorporate this project's capabilities. A cursory search brings up this project as a potentially language client. This section make it appear that it might not be too difficult, but I don't know lisp so it's hard for me to say.

I'm not sure what the best approach would be for syntax highlighting. But my vscode and atom clients have they syntax highlighting defined by this file

LeonardMH commented 5 years ago

Nice, lsp-mode does look promising, good find. I'm not too worried about syntax highlighting at the moment as what I have is already 'good enough', a solid semantic completion engine is what I'm really interested in.

Just looking at a couple of the lsp modes they have defined in the repo it does look like it would be pretty easy to define a client for your language server. The lsp-client.el shows like 8 different language clients being defined in less than 400 lines. Even for the more complicated clients the majority of the file is taken up with defining configuration variables (so users can tweak behavior) or helper functions (so users can trigger actions), but the actual work of getting the client running seems to be pretty simple.

I'll hopefully be able to start on this soon, but probably not before next week. Unless you have a better suggestion I'm thinking I will do this in a separate repo initially, then if you want to include it here you can link it in as a submodule like what you have done for the atom client. I don't know that it makes sense to contribute this to lsp-mode itself since KerboScript is a relatively niche language...

jonnyboyC commented 5 years ago

I agree on the syntax highlight the screenshot you have posted above seems complete enough. If you feel up to looking at the emacs client by all means go ahead! I currently have the server as an npm package, but I want to make sure the installation process can be completed with npm install -g kos-language-server and be done. So I'll continue to focus there, if you want to take up the client.

We could potentially post an issue indicating our interest to incorporate, but if not we can always fork the project. My guess is they will be hesitant to fork the project to include support for a language that may have a few hundred using it somewhat regularly.