Closed nikpivkin closed 2 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.
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).
In that case, I would analyze what's cheaper to implement:
tliron/glsp
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
}
}
@pherrymason It's gonna be great
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
}
}
Implemented in v0.3.0
Currently, searching for definitions for symbols from
stdlib
is not supported (TextDocumentDefinition
andTextDocumentDeclaration
handlers). I don't mind helping to implement this functionality. I see the following steps for implementation:stdlib
, add ranges and document uri to all definitionsstdlib
at LSP server startupstdlib
stdlib
, then load its module and resolve the absolute file path.Let me know if I missed something.