projectile icon indicating copy to clipboard operation
projectile copied to clipboard

#1509 broke lsp-mode for ccls

Open bk138 opened this issue 5 years ago • 7 comments

https://github.com/bbatsov/projectile/pull/1509 broke lsp-mode for ccls, which is expecting compile_commands.json (generated by CMake) in the project root.

Probably the build dir should be made configurable in projectile instead of hardcoding build.

Expected behavior

ccls finds compile_commands.json in the project root

Actual behavior

ccls does not find compile_commands.json in the project root because it's in ./build.

Steps to reproduce the problem

Open a CMake C project, try to use LSP. FWIW, my config can be found here.

Environment & Version information

Projectile version information

Projectile 20200329.1908

Emacs version

GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511))

Operating system

MacOS 10.15

bk138 avatar Apr 04 '20 12:04 bk138

I'm fine with adding a configuration option for this.

bbatsov avatar Apr 28 '20 05:04 bbatsov

Is this about in ccls? For me right now ccls works ok.

Cmake projects don't like in tree builds in most cases, so this would have been broken without the prior PR.

Thaodan avatar Sep 16 '22 16:09 Thaodan

Well for me with compile_commands.json inside the ./build subdir, ccls starts but does not yield any helpful results. If I copy the generated compile_commands.json to the project root, ccls works and can do jump-to-definition and show-references and all that.

bk138 avatar Sep 16 '22 17:09 bk138

Anyway, I think it makes sense for projectile to default to an out-of-source build, I worked around the ccls issue by letting CMake copy the generated compile_commands.json to the project root. Therefore, feel free to close @bbatsov

bk138 avatar Sep 16 '22 17:09 bk138

Well for me with compile_commands.json inside the ./build subdir, ccls starts but does not yield any helpful results. If I copy the generated compile_commands.json to the project root, ccls works and can do jump-to-definition and show-references and all that.

Jokes on me, I was using project.el which quacks like a projectile.

Thaodan avatar Sep 16 '22 17:09 Thaodan

Setting compilationDatabaseDirectory in ccls might help as explained in MaskRay/ccls#903.

Thaodan avatar Sep 16 '22 23:09 Thaodan

Setting compilationDatabaseDirectory in ccls might help as explained in MaskRay/ccls#903.

Yeah, and it'd be super awesome if emacs (projectile, lsp-mode, ...) would set this automagically.

Edit: ccls (or rather emacs-ccls) seems to consult projectile about project roots, so probably the compile_commands.json location should be set in projectile or rather https://github.com/emacs-lsp/emacs-ccls which might get the build dir info from projectile.

bk138 avatar Sep 17 '22 10:09 bk138