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

Find project file #8

Open
PMunch opened this issue Nov 4, 2018 · 6 comments
Open

Find project file #8

PMunch opened this issue Nov 4, 2018 · 6 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@PMunch
Copy link
Owner

PMunch commented Nov 4, 2018

As this issue points out nimsuggest needs a project file to work. Currently this just treats every file as it's own project file, but an actual algorithm should be implemented for this task. Internally it would replace the nimsuggest field in the openFiles table with a project field that can be shared across files. If anyone could make a procedure that takes a file as an argument and returns the best match project file (or just returns the file itself if no project file is found), that would help a lot.

@PMunch
Copy link
Owner Author

PMunch commented Nov 5, 2018

I've implemented something that works at the moment, but it has a stub where Nimble support would be. If anyone could figure out how to get the project file from a .nimble file it would be nice to add.

@bung87
Copy link
Contributor

bung87 commented Nov 5, 2020

I think we can use initialise params's rootUri as project root dir,

for workspace feature, we take each workspaceFolder as project root,

the compiler/options.nim has findProjectNimFile proc see https://github.com/nim-lang/Nim/blob/05752cd5d027a746053897d124f9dae513a0e664/compiler/options.nim#L793

we can use it pass to initNimsuggest

it's all during initialize period .

https://github.com/microsoft/vscode/wiki/Adopting-Multi-Root-Workspace-APIs#language-client--language-server
https://microsoft.github.io/language-server-protocol/specification#initialize

@PMunch
Copy link
Owner Author

PMunch commented Nov 5, 2020

I think there was some problem with using findProjectNimFile when I last looked at it. But that might've been fixed since. Otherwise I'm all for making the project detection better, it's a bit of a mess right now.

@bung87
Copy link
Contributor

bung87 commented Nov 5, 2020

when I check the debug info it shows Initialising project with each file, so currently it compile each file to get graph, basically we only need compile project entry file to get graph right ?

@bung87
Copy link
Contributor

bung87 commented Nov 5, 2020

for the nimble things , I think nimble need export some proc ,we can import it use its api, I remember there's proc doing this work, but it is private proc.

@PMunch
Copy link
Owner Author

PMunch commented Nov 5, 2020

It should only initialise the project for new project files. So in your case it isn't able to get the project properly. As long as all files in the same project return the same project file from https://github.com/PMunch/nimlsp/blob/master/src/nimlsp.nim#L128.

The Nimble part is a bit trickier since nimble files are NimScript and need to be evaluated in order to get the value. However this already imports the entire compiler, so at least it won't add much of a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants