Closed JafarAbdi closed 2 years ago
How your callable build_dir
looks?
This's how a workspace looks like
workspace/
src/
pkg1/
...
build/
pkg1_build_dir/
...
So, what I do is create a file called .clangd_config
that live in each package's root path (it gets automatically generated when I build), it contains the path to the build directory for that package (it's somewhat a dumb solution, but that's the only solution I had :D)
local get_build_dir = function()
local file_path = require("lspconfig.util").root_pattern(".clangd_config")(vim.fn.expand("%:p:h"))
local p = Path:new(file_path, ".clangd_config")
return Path:new(vim.trim(p:read()))
end
But CMake automatically creates build folder for each project inside the build directory.
But CMake automatically creates build folder for each project inside the build directory.
The tool we use is built on top of CMake (https://github.com/colcon if you're interested), each package is a standalone CMake project and that tool create the build directory under the workspace directory
But how you detect for which project you run CMake?
But how you detect for which project you run CMake?
By looking for .clangd_config
file in one of the parent directories of the opened cpp/cmake files
Got it, please update the README to indicate that build_dir could be a callable and I will merge it.
Please let me know if the description isn't clear, I apologize for the delayed response.
It's good, thanks!
I work with a pretty big codebase which consists of multiple CMake packages (sometimes 300 :D), so having a fixed string for the build_dir doesn't work well for my case, it would be great to have an option to call a function similar to nvim-lspconfig's root_dir