ahmedkhalf / project.nvim

The superior project management solution for neovim.
Apache License 2.0
1.29k stars 119 forks source link

fix(lsp): prioritise `workspace_folders` for root directory detection #147

Open mrcjkb opened 4 months ago

mrcjkb commented 4 months ago

Some LSP clients can have more than one workspace folder, which can be added via workspace/didChangeWorkspaceFolders.

This is especially useful for resource-hungry clients, like rust-analyzer or haskell-language-server, in order to avoid spawning multiple clients.

Using lsp.Client.config.root_dir as the source of truth results in this plugin detecting the wrong project root in this scenario.

This PR fixes that, by first searching through the lsp.Client.workspace_folders, and then falling back to the config.root_dir if no matching workspace folder is found.