Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add search definition and declaration for symbols from stdlib #47

Closed
nikpivkin opened this issue Aug 16, 2024 · 7 comments
Closed

Add search definition and declaration for symbols from stdlib #47

nikpivkin opened this issue Aug 16, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@nikpivkin
Copy link
Contributor

nikpivkin commented Aug 16, 2024

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:

  • When indexing stdlib, add ranges and document uri to all definitions
  • Determine path to stdlib at LSP server startup
  • Allow users to override the path to stdlib
  • If the symbol is in stdlib, then load its module and resolve the absolute file path.

Let me know if I missed something.

@pherrymason
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Owner

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

  • A new option for the LSP to specify path to the stdlib sources.
  • Implement either the custom handler or workspace/textDocumentContent on top of tliron/glsp

@pherrymason
Copy link
Owner

pherrymason commented Aug 28, 2024

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 pherrymason added the enhancement New feature or request label Aug 28, 2024
@nikpivkin
Copy link
Contributor Author

@pherrymason It's gonna be great

@pherrymason
Copy link
Owner

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
Copy link
Owner

Implemented in v0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants