c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Language Server support

Open jb-perrier opened this issue 3 years ago • 13 comments

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:

  • Using the compiler as a static lib, with little modification we should be able to access the whole ast
  • Outputting the AST in a specific format. ( The language server would have to read / parse the outputted file, performance drop here )

Feels free to express your ideas below.

jb-perrier avatar Sep 13 '22 07:09 jb-perrier

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 avatar Sep 13 '22 07:09 lerno

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

lerno avatar Sep 13 '22 07:09 lerno

--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 avatar Sep 13 '22 07:09 jb-perrier

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 avatar Sep 13 '22 08:09 jb-perrier

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.

jb-perrier avatar Sep 13 '22 09:09 jb-perrier

What's the state of this?

lerno avatar Jun 10 '23 14:06 lerno

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 avatar Jun 29 '23 06:06 jb-perrier

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

jb-perrier avatar Jun 29 '23 06:06 jb-perrier

I'm looking forward to it!

lerno avatar Jul 01 '23 17:07 lerno

Hi, any news on this? :eyes:

Akselmo avatar Dec 04 '23 08:12 Akselmo

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.

jb-perrier avatar Dec 04 '23 09:12 jb-perrier

Do you know what issue that was?

lerno avatar Dec 04 '23 09:12 lerno

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.

resolritter avatar Jun 13 '24 22:06 resolritter