rhysd/vim-clang-format

Useful information

Closed this issue · 0 comments

8dcc commented

First of all, thank you for making this plugin. I have been using it for some months now, and I want to write some information that might be useful for everyone that uses clang-format.

formatprg (gq)

In vim (at least in neovim) you can format text with gw and gq. You can specify a program for formatting, that reads from stdin and writes to stdout. See :help formatprg.

You can tell vim to use clang-format by using:

set formatprg=clang-format    " No quotes

Compiling clang-format without the full toolchain

Instead of compiling the entire clang toolchain, you can compile clang-format by doing:

$ git clone --depth=1 https://github.com/llvm/llvm-project
$ cd llvm-project
$ mkdir tmp
$ cd tmp

$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" ../llvm
...

$ ninja clang-format
...

$ ./bin/clang-format --help
...