Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What version of clang-format is used / can I use the system clang-format? #930

Open
MarcelRobitaille opened this issue Feb 24, 2023 · 3 comments

Comments

@MarcelRobitaille
Copy link

Observed behavior

I want to use the setting SpacesInLineCommentPrefix in my .clang-format file. I can see that it's only available as of clang 13. This setting works flawlessly if I run clang-format from the command line. However, when I press ff, which I have bound in vim to lua vim.lsp.buf.format(), nothing happens when this setting is enabled. Not just this setting for comments isn't applied, but the formatting isn't working at all, even for things that used to work like indentation. If I take this setting out of .clang-format and press ff, everything else is working.

It's like clang-format is erroring out, but nothing is printed in Vim. I checked :messages and I don't see anything in the LSP log file even with my log level set to debug (vim.lsp.set_log_level("debug")).

I saw in #910 that ccls uses the LLVM clang-format. However, I don't have /usr/lib/llvm-14/bin/clang-format on my computer. I don't know how to figure out which clang-format it's trying to use. When I do which clang-format, I get /usr/bin/clang-format. Is there any way to get it to use that clang-format? I don't have any of CMAKE_PREFIX_PATH, LLVM_INCLUDE_DIR, LLVM_BUILD_INCLUDE_DIR why I try to echo them in my terminal.

Expected behavior

The setting SpacesInLineCommentPrefix in .clang-format should not break formatting. There should be some way to setting ccls to use a different clang-format binary. There should be some error message when formatting fails.

Steps to reproduce

  1. Put this in .clang-format:
    SpacesInLineCommentPrefix:
      Minimum: 1
      Maximum: 1
    
  2. Trigger LSP formatting

System information

  • ccls version (git describe --tags --long): 0.20210330-1 from apt
  • clang version: 14
  • OS: Pop_os
  • Editor: neovim v0.9.0-dev
  • Language client (and version): neovim built in
@MarcelRobitaille
Copy link
Author

BTW do you accept donations?

@findNextStep
Copy link

ccls complie with libclang in your computer, it may be not in /usr/lib/llvm-14/bin/clang-format. it depend on where ccls complie
https://github.com/MaskRay/ccls/blob/master/src/messages/textDocument_formatting.cc here is source code abort how ccls work with clang-format. if you get ccls from apt source, it depend on apt source

@metablaster
Copy link

The option SpacesInLineCommentPrefix works only for single line comments and does not work if comments span multiple lines regardless if // style or /**/ style is used.

In addition the option ReflowComments must be set to true

Expected behavior is for this option to work on any amount of lines of comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants