pherrymason / c3-lsp

Language Server for C3 Language
https://pherrymason.github.io/c3-lsp/
GNU General Public License v3.0
75 stars 10 forks source link

Add search definition and declaration for symbols from stdlib #47

Closed nikpivkin closed 2 months ago

nikpivkin commented 3 months ago

Currently, searching for definitions for symbols from stdlib is not supported (TextDocumentDefinition and TextDocumentDeclaration handlers). I don't mind helping to implement this functionality. I see the following steps for implementation:

Let me know if I missed something.

pherrymason commented 3 months ago

That is a good solution, but it will require the user to have the spurces of the stdlib.

There is another option and is to include the stdlib with the lsp server and use the functionality 'virtual document' of the lsp proto ol. Haven't look at the specification deeply, but as I understood the lsp can deliver a reference to a document+ the document itself and the editor should display it.

nikpivkin commented 3 months ago

A future 3.18 version of LSP will add a workspace/textDocumentContent method that provides document content. Another option is to add a custom handler to return virtual documents, but the github.com/tliron/glsp package doesn't allow registering custom handlers (but there is a PR for adding this).

pherrymason commented 3 months ago

In that case, I would analyze what's cheaper to implement:

pherrymason commented 2 months ago

I'm implementing a config file by project, and though I could add there the path to the stdlib sources. This would help with this feature.

{
    "send-crash-reports": true,
    "log-path": "./c3-lsp.log",
    "C3": {
        "version": "0.6.2",
        "path": "c3c",
        "stdlib": {
            "path": "/path/to/stdlib/sources"
        }
    },
    "Diagnostics": {
        "enabled": true,
        "delay": 2000
    }
}
nikpivkin commented 2 months ago

@pherrymason It's gonna be great

pherrymason commented 2 months ago

Implemented in branch file-config.

Create a c3lsp.json file in your c3 project:

{
    "C3": {
        "version": "0.6.1",
        "stdlib-path": "<YOUR PATH TO STDLIB>/c3c/lib/std"
    },
    "Diagnostics": {
        "enabled": true,
        "delay": 2000
    }
}
pherrymason commented 2 months ago

Implemented in v0.3.0