emacs-lsp / emacs-ccls

Emacs client for ccls, a C/C++ language server
200 stars 29 forks source link

Made project root suggester configurable #76

Closed Maverobot closed 4 years ago

Maverobot commented 4 years ago

This PR made root search list configurable via ccls-root-files

MaskRay commented 4 years ago

Two alternatives:

  1. ln -s build/compile_commands.txt .
  2. touch .ccls-root + (setq ccls-initialization-options '(:compilationDatabaseDirectory "build")) https://github.com/MaskRay/ccls/wiki/Customization#compilationdatabasedirectory
Maverobot commented 4 years ago

Your alternatives require creating file in every project I visit. Sometimes I just want to visit a project and have a quick look without having to create either a soft link or .ccls-root. Can you please explain your reason not wanting .ccls-root to be configurable? It seems to me rather an enhancement to your library.

MaskRay commented 4 years ago

locate-dominating-file compile_commands.json is actually a regression.

Say you have out/release/compile_commands.json (not everyone uses build/ as a build directory. And I generally consider that name inappropriate because usually you want to differentiate debug builds from release builds). You have generated source files in out/release/a/b.cc.

Now locate-dominating-file can erroneously think out/release/ is the root directory, which is apparently wrong.

See https://github.com/MaskRay/ccls/wiki/FAQ#project-root-detection

Maverobot commented 4 years ago

I see your point.

How about remove compile_commands.json and build/compile_commands.json from the changes while keeping ccls-root-files configurable? This way its default behavior would be exactly as it is now.

If the user desires to add build/compile_commands.json, he can add it by appending it to ccls-root-files and is aware of that. Since .ccls-root will be tried first, if .ccls-root can be found, it will still behave normally in your mentioned case.

ccls-root-files would be similar to projectile-project-root-files-top-down-recurring in projectile.el.

MaskRay commented 4 years ago

ccls-root-files: (".ccls-root") is good.

Maverobot commented 4 years ago

PR has been updated. Please let me know if there is anything to be changed.