Description
Currently clangd root directory is detected by NearestRoot(["compile_commands.json", "compile_flags.txt", ".clangd", "CMakeLists.txt", "Makefile"]), which is usually result in the up directory which contains "CMakeLists.txt" or "Makefile" of active file, and is not the root directory of project. Instead, clangd should run in the root directory.
clangd will search from active file directory up to root directory to find .clangd or compile_flags.txt. We do not need to do the search again in LSPServer.
compile_commands.json is important to clangd, clangd will look in the parent directories of active file looking for it, and also in subdirectories named "build/". But it usually fails if one build project out of source tree. Argument of clangd (--compile-commands-dir) can be used to pass the location.
So all we need to do:
- set root directory of the project correctly.
- pass
compile_commands.json using argument.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
Currently
clangdroot directory is detected byNearestRoot(["compile_commands.json", "compile_flags.txt", ".clangd", "CMakeLists.txt", "Makefile"]), which is usually result in the up directory which contains "CMakeLists.txt" or "Makefile" of active file, and is not the root directory of project. Instead,clangdshould run in the root directory.clangdwill search from active file directory up to root directory to find.clangdorcompile_flags.txt. We do not need to do the search again in LSPServer.compile_commands.jsonis important to clangd, clangd will look in the parent directories of active file looking for it, and also in subdirectories named "build/". But it usually fails if one build project out of source tree. Argument of clangd (--compile-commands-dir) can be used to pass the location.So all we need to do:
compile_commands.jsonusing argument.Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response