Ale: [Clarification] Is clangd supported for C++ ?

Created on 3 Sep 2018  路  8Comments  路  Source: dense-analysis/ale

Reading documentation (e.g. https://github.com/w0rp/ale/blob/79f02fce69a0dceb8bbbe2c6f5a7cebceaa34be6/doc/ale-cpp.txt) and ALE outputs, it seemed to me that ALE supports clangd (and afaik clangd can only be used for LSP features like completion, no Linting or Fixing).

Yet, I cannot seem to get any completion information with clangd (LLVM v 6.0.0) in the path, and ALE configured with g:ale_completion_enabled = 1. ALEInfo does report clangd as an available linter, yet it does not appear anywhere under Command History.

1594 also could indicate that clangd is not yet supported.

Is it supported ? If not, what is the current purpose of clangd in ALE ?

Thank you for the awesome project,

bug

Most helpful comment

ALE finds the project root by looking for build/compile_commands.json now, or whatever build directories you have for g:ale_c_build_dir_names.

All 8 comments

Yes, it is. Where does your compile_commands.json file live in your project?

@w0rp thank you for taking time to answer this question and the follow-up

compile_commands.json live in /build folder (/ denoting the project's root). The cpp file I am trying it on is in /src/libs/Components.

The compile_commands.json is correctly picked-up by clang-check (I can see -p /path_to_my_repo/build in the Command History). It also seems to be correctly parsed to provide info to clang++, after setting ale_c_parse_compile_commands=1.

The /build folder will be the issue. I can add a patch later to get the project root based on compile_commands.json in /build. The person who added the linter only looks for compile_commands.json in /.

Spot on, symlinking the compile_commands.json at the root of the repository allows suggestions to show-up.
My mistake was to assume that g:ale_c_build_dir_names mechanism to look for build dir would be applied uniformly to all _linters_. (Even though the docs for clangd does not mention it).

Thank you for the quickfix, and of course, the patch you mention would be of great help to us!

I took a glance at this today, and it looks like it's assuming the location of compile_commands.json is the project root, so it's not _quite_ as simple as just considering g:ale_c_build_dir_names in the process.

ALE finds the project root by looking for build/compile_commands.json now, or whatever build directories you have for g:ale_c_build_dir_names.

I am trying to move away from making a symlink to compile_commands.json at the root of the repository, yet cannot get it to work correctly at the moment.

With the symlink in place, clangd does not report any error during the linting phase.
If I remove the symlink, and the file is only present in build/compile_commands.json, clangd reports error (like inability to include 'string.h' when my code contains #include <string>).

My folder structure is as follows:

repo/build/compile_commands.json
repo/src/libs/name/name/Testfile.h
repo/src/libs/name/name/Testfile.cpp

Is my understanding correct that, in this situation, the default value for g:ale_c_build_dir_names (confirmed to be ['build', 'bin']) should allow clangd to find the compilation db without the symlink at the root?

@w0rp (In case notifications are not automatic for closed issues, sorry if you already received it)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sublee picture sublee  路  3Comments

trevordmiller picture trevordmiller  路  3Comments

aressler38 picture aressler38  路  3Comments

glepnir picture glepnir  路  3Comments

sodiumjoe picture sodiumjoe  路  4Comments