[clang] Improve instructions in Clang Format Vim Integration Document (PR #102730)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 10 01:48:15 PDT 2024
https://github.com/cuppajoeman updated https://github.com/llvm/llvm-project/pull/102730
>From b42951aac97b2660bcadb1028e623f9e70981cde Mon Sep 17 00:00:00 2001
From: cuppajoeman <ccn at cuppajoeman.com>
Date: Sat, 10 Aug 2024 03:25:15 -0400
Subject: [PATCH 1/2] update to show where you can actually get the mentioned
file
---
clang/docs/ClangFormat.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index dbd9c91ae508e5..e30dea3568fcf3 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -164,7 +164,8 @@ Vim Integration
There is an integration for :program:`vim` which lets you run the
:program:`clang-format` standalone tool on your current buffer, optionally
selecting regions to reformat. The integration has the form of a `python`-file
-which can be found under `clang/tools/clang-format/clang-format.py`.
+which can be found under `clang/tools/clang-format/clang-format.py
+<https://github.com/llvm/llvm-project/tree/main/clang/tools/clang-format>`_.
This can be integrated by adding the following to your `.vimrc`:
>From ad13f76f0c2a5e22fddcde2b60644a74bfbd5ff0 Mon Sep 17 00:00:00 2001
From: cuppajoeman <ccn at cuppajoeman.com>
Date: Sat, 10 Aug 2024 04:47:17 -0400
Subject: [PATCH 2/2] add python version checks
---
clang/docs/ClangFormat.rst | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index e30dea3568fcf3..c6eac07acbba67 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -199,7 +199,11 @@ your `.vimrc`:
function! Formatonsave()
let l:formatdiff = 1
- pyf <path-to-this-file>/clang-format.py
+ if has('python')
+ pyf <path-to-this-file>/clang-format.py
+ elseif has('python3')
+ py3f <path-to-this-file>/clang-format.py
+ endif
endfunction
autocmd BufWritePre *.h,*.cc,*.cpp call Formatonsave()
More information about the cfe-commits
mailing list