c3lang / c3c

Compiler for the C3 language
https://c3-lang.org
GNU Lesser General Public License v3.0
2.69k stars 163 forks source link

Language Server support #567

Open jb-perrier opened 2 years ago

jb-perrier commented 2 years ago

Having a language server for all famous IDE is a key step for spreading C3 into the programming world.

This issue will enable us to track the needs, how it can be done and anything related to this subject.

For now, --test mode enable us to get error reports, in order to have auto completion and any feature AST related we need to access the AST generated in parsing part of c3c.

Few solutions comes to my mind rn:

Feels free to express your ideas below.

lerno commented 2 years ago

C3 used to have an AST printer, but such a format was more informative than intended for LSPs. It's also the concern that the AST is sometimes rewriting things from the concrete tree and as such might not correctly match the LSP output. But a starting point should probably be trying to create a LSP-format AST printing function.

lerno commented 2 years ago

The error can then be taken from the --test output. Create a --lsp mode similar to --test

jb-perrier commented 2 years ago

--lsp totally make sense to me. Are we talking about a binary format or smth like json ? We can maybe use an option to output human readable JSON or a BSON if it's read by a third party program. In case these formats are too heavy to parse we can write a specific binary format.

jb-perrier commented 2 years ago

After some reflexion, we should probably not use lsp because it means Language server protocol, it's a rpc json format that enable IDEs to query the language server about request like Go to definition, Completion, ect .. Maybe something more simple like --ast

jb-perrier commented 2 years ago

Atfer discord discussion, the --lsp will take an LSP request in stdin and respond to it, in the stdout. We will start by supporting very basic request.

lerno commented 1 year ago

What's the state of this?

jb-perrier commented 1 year ago

Hi @lerno, i should have a branch somewhere with basic communication using lsp protocol. I will get back to you when i will find it !

jb-perrier commented 1 year ago

Just found it : https://github.com/jb-perrier/c3c/tree/lsp Will put my head in it, i have more time now.

lerno commented 1 year ago

I'm looking forward to it!

Akselmo commented 10 months ago

Hi, any news on this? :eyes:

jb-perrier commented 10 months ago

Hi, any news on this? 👀

Unfortunately no, i was just stuck to an issue i wasn't able to fix for some reason. I had to switch to other things.

lerno commented 10 months ago

Do you know what issue that was?

resolritter commented 3 months ago

FYI there's a WIP language server implementation at https://github.com/pherrymason/c3-lsp. It was recently updated with the stdlib for 0.6.0.