c3c icon indicating copy to clipboard operation
c3c copied to clipboard

"First party" LSP written in C3

Open giuliano-macedo opened this issue 2 months ago • 2 comments

I saw that in #1456 there is this bullet point:

High quality LSP

What is your opinion on implementing one in C3 by using the c3c lexer/parser, and adding to the c3c repo or another repo inside c3lang?

I'm asking this because one of the things I like about go is that gopls is maintained by the go team (thats what I call a "First party" LSP) and AFAIK it uses the same lexer/parser that that the go compiler uses, increasing its correctness.

I've never built an LSP myself, this is just my first thoughts about this, I would love to implement* like this if you think it is a good idea, but I am open to new ideas as well.

*: I can't promise though, it would be a lot of work I think.

I think it could start with these actions (that are the same that helix currently supports) because is a good subset of commonly used LSP actions:

  • must:
    • diagnostics → textDocument/publishDiagnostics (notification from server)
    • goto-definition → textDocument/definition
    • goto-declaration → textDocument/declaration
    • goto-type-definition → textDocument/typeDefinition
    • goto-reference → textDocument/references
    • goto-implementation → textDocument/implementation
    • format → textDocument/formatting
    • hover → textDocument/hover
    • textDocument/didChange for codecompletion/error reporting for each keystroke
  • nice to have:
    • document-symbols → textDocument/documentSymbol
    • workspace-symbols → workspace/symbol
    • rename-symbol → textDocument/rename
    • completion → textDocument/completion
    • signature-help → textDocument/signatureHelp
    • code-action → textDocument/codeAction
    • document-highlight → textDocument/documentHighlight
    • workspace-command → workspace/executeCommand
    • inlay-hints → textDocument/inlayHint

giuliano-macedo avatar Oct 18 '25 17:10 giuliano-macedo

I think a Language Native LSP would be very, very cool!

chrischtel avatar Oct 25 '25 07:10 chrischtel

I would not use the c3c parser, since you want something more lenient for an LSP: it should be caching information and work well with incomplete data and such.

lerno avatar Oct 25 '25 13:10 lerno