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

projectMapping doesn't work for the first opened file #303

Open
khaledh opened this issue Mar 19, 2025 · 0 comments
Open

projectMapping doesn't work for the first opened file #303

khaledh opened this issue Mar 19, 2025 · 0 comments

Comments

@khaledh
Copy link

khaledh commented Mar 19, 2025

I noticed that the first file I open in VSCode creates a nimsuggest process for that specific file, not the associated project file. When I later open other files, their nimsuggest instance uses the associated project file correctly.

// settings.json
{
  "nim.projectMapping": [
    {
        "projectFile": "src/kernel/main.nim",
        "fileRegex": "src/(kernel|common)/.*\\.nim"
    }
  ]
}
DBG Starting nimlangserver                     version=1.10.0 params="(clientProcessId: none(int), transport: some(stdio), port: 0)"
DBG Starting stdio server                     
DBG [Processsing Message]                      request="\"initialize\""
DBG Initialize received...                    
DBG Registering monitor for process            pid=84584
DBG Initialize completed. Trying to start nimsuggest instances
DBG Trying to start nimsuggest instances done 
DBG [Processsing Message]                      request="\"initialized\""
DBG Requesting configuration from the client  
DBG [Processsing Message]                      request="\"textDocument/didOpen\""
DBG New document opened for URI:               uri=file:///Users/khaled/src/khaledh/fusion/src/common/segtree.nim
DBG Auto-guessing project file for             file=/Users/khaled/src/khaledh/fusion/src/common/segtree.nim
DBG getProjectFile                             project=/Users/khaled/src/khaledh/fusion/src/common/segtree.nim fileUri=/Users/khaled/src/khaledh/fusion/src/common/segtree.nim

Notice that it says Auto-guessing project file, when it should rely on the project mapping config. The next file I open gets associated with the project file correctly:

DBG [Processsing Message]                      request="\"textDocument/didOpen\""
DBG New document opened for URI:               uri=file:///Users/khaled/src/khaledh/fusion/src/common/pagetables.nim
DBG ShowMessage                                message="RegEx matched `src/(kernel|common)/.*\\.nim` for file `/Users/khaled/src/khaledh/fusion/src/common/pagetables.nim`"
DBG Document associated with the following projectFile uri=file:///Users/khaled/src/khaledh/fusion/src/common/pagetables.nim projectFile=/Users/khaled/src/khaledh/fusion/src/kernel/main.nim

I looked at the langserver code, but it's not clear to me what might be the issue. I have a feeling it has to do with waiting on the workspace configuration future, which leads to this comment in getWorkspaceConfiguration:

    #this is the root of a lot a problems as there are multiple race conditions here.
    #since most request doenst really rely on the configuration, we can just go ahead and 
    #return a default one until we have the right one. 
    #TODO review and handle project specific confs when received instead of reliying in this func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant