by choeger · 6y ago · 0 comments
If I put the setup in my home directory, I am limited to a single setup (compiler, stdlib).
If I put it into the project directory, I am limited to a single build for, and potentially a single branch, and I will have multiple instances of the lsp running if I stop working on one project.
If I put it into the build for, which seems sensible, how does the editor decide which server to run or ask?
It seems to me that I need some sort of project manager that acts like a lap proxy and then resolves these issues. Do I need to write one myself?
+ ~/repos/repoA
| - CMakeLists.txt
| - compile_commands.json -> ../../build/repoA_config1/compile_commands.json
|
+ ~/build/repoA_config1
| - CMakeCache.txt
| - build.ninja
| - compile_commands.json
|
+ ~/build/repoA_config2
| - CMakeCache.txt
| - build.ninja
| - compile_commands.json
etc. for repoB, C, ...That said I'm thinking on flipping it around - keep the LS configuration in the build folder, and symlink the source folder in it. That way I can have several different configurations in effect at once and switch between them easily. Currently I have to change where compile_commands.json points to if I want to change YouCompleteMe's completions.
Your editor should manage the language server and you should just have to provide the configuration it expects in the directory you start it in.
There is one clangd process per editor process. If you have multiple projects with distinct compile_commands you might be able to come-up with a scheme to switch between DBs and relaunch clangd. Alternatively, you could try merge all compile_commands together, but I'm not sure the effort would be worth it -- just running separate vims seems like it makes the most sense to me.
For switching between branches, you can typically regenerate the compile commands DB pretty easily (if you use cmake...), but it's really only necessary if there are big differences in files and/or compile settings between branches.
At the moment, I run everything (toolchain, LSP server, nvim) in a toolbox. Works well, but it feels unecessary to have a copy of vim in every container.