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

Parse std lib instead of using manual definition files #73

Open
Caleb-o opened this issue Sep 15, 2024 · 6 comments
Open

Parse std lib instead of using manual definition files #73

Caleb-o opened this issue Sep 15, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@Caleb-o
Copy link

Caleb-o commented Sep 15, 2024

Is your feature request related to a problem? Please describe.
From a browse of the source, it would seem that std lib code is done using some definition files which works to get the signature, but this makes maintenance very hard in the long run.

Describe the solution you'd like
Parse std lib so it can collect the required information. This should also make it a little easier to manage, as it doesn't require some manual intervention of creating these files. These def files sound liked they will also be painful to manage as the library grows and changes over time.

If you have the stdlib path (and it is valid), you can then recursively parse these files to collect all the info you need to get features to work.
If the project has specified that it does not use the stdlib, then it can skip parsing.

It should probably error if no lib is found at the path or is empty, but expects a stdlib to be used in the project.

Describe alternatives you've considered
As a workaround, you would need to have the stdlib open in another editor to see the source or create a c3lsp.json with the stdlib path for goto.

Edit: Changed description based on information provided about LSP config

@pherrymason
Copy link
Owner

Do you mean parsing on server startup instead of having the definitions already incorporated?

@Caleb-o
Copy link
Author

Caleb-o commented Sep 16, 2024

Something like that yes. Not sure what capabilities an LSP can have, but you could potentially even cache these in some way. I think Rust Analyser might just do it on startup, so that's probably not too bad of a solution.

@pherrymason
Copy link
Owner

pherrymason commented Sep 16, 2024

It could be done yes.
What you can have in the meantime is setup the c3lsp.json fie in your project to specify where are the stdlib sources: https://github.com/pherrymason/c3-lsp/wiki/Configuration

It will not re-parse them, but it will give you "Go To" capabilities.

@Caleb-o
Copy link
Author

Caleb-o commented Sep 16, 2024

Ah, I thought I seen a stdlib path somewhere but wasn't sure. Could this c3lsp.json become part of the vscode extension (or any other editor extension) settings, so it can be more automatic? But this works nicely! I didn't realise this was possible, since I only looked at the README.

@pherrymason
Copy link
Owner

pherrymason commented Sep 16, 2024

the stdlib path value could be specified by the extension yes. There is no change required in the LSP for that, if the extension implements it you could use it today.

The idea of the c3lps.json is so you can use different configurations for different projects.

@pherrymason pherrymason added the enhancement New feature or request label Sep 16, 2024
@Caleb-o
Copy link
Author

Caleb-o commented Sep 16, 2024

Using the extension doesn't seem to give me goto def for std, with the path specified in there instead. I will change the description of the issue, since part of this already exists, it's just the parsing.

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