LanguageClient-neovim
LanguageClient-neovim copied to clipboard
Project root not updated when editing file from different project
Environment
- Plugin version: 3e31d01
- Plugin binary version: 0.1.146
- Neovim version: 0.3.5
- Language: C
- Language server:
cclslatest release (0.20190314.1)
Describe the bug
After launching Neovim and editing a file belonging to a project in my workspace, LanguageClient successfully detects the project root, using my custom root marker. The project root is printed and logged correctly, and all the language client+server functionalities work. When I start editing another file belonging to a different project, the project root is not updated, in fact is remains the same as before thus breaking all the functionalities.
The workspace tree is something like the following:
workspace
│
├── project_a
│ ├── build
│ │ └── compile_commands.json
│ └── source
│ └── main.c
│
└── project_b
├── build
│ └── compile_commands.json
└── source
└── main.c
My root marker is build/compile_commands.json. LanguageClient is set to automatically start. Initialization options for ccls are as follows:
{
"initializationOptions": {
"cache": { "directory": "/tmp/ccls" },
"compilationDatabaseDirectory": "build",
"client": { "snippetSupport": true },
"clang" : { "extraArgs": ["-Wno-extra"] },
"highlight": { "lsRanges": true }
}
}
To recap, I start Neovim inside workspace, then :edit project_a/source/main.c and LanguageClient outputs
[LC] Project root: workspace/project_a
and everything works. Then I :edit project_b/source/main.c but the project root is not updated, thus also the compile_commands.json database is not loaded, and nothing works as expected.
Am I missing something or is this a bug/non-feature of LanguageClient?
This is how this plugin works as of now.
In order to associate files of same type + project to the same language server instance, filetype is used as key mapping to language server instances.
This might be changed to use project root as key in the future. I cannot guarantee when it will come or whether it will.
As a workaround, when switching project, you can run :LanguageClientStop, :LanguageClientStart to start the language server for project b. Alternatively running different neovim session for different project.