Skip to content

Commit 30b689b

Browse files
committed
cmake compiler plugins
Signed-off-by: Guybrush <miguel.barro@live.com>
1 parent 6008a56 commit 30b689b

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
" Vim compiler file
2+
" Compiler: GNU C Compiler
3+
4+
if exists("current_compiler")
5+
finish
6+
endif
7+
let current_compiler = "cmake_gcc"
8+
9+
CompilerSet errorformat=%C\ %#%l\ %#\|%m,
10+
\%Z\ %#\|%p%.%#,
11+
\%E%f:%l:%c:\ %trror:%m,
12+
\%W%f:%l:%c:\ %tarning:%m,
13+
\%-G%.%#
14+
15+
CompilerSet makeprg=cmake
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
" Vim compiler file
2+
" Compiler: Microsoft Visual C/C++
3+
4+
if exists("current_compiler")
5+
finish
6+
endif
7+
let current_compiler = "cmake_msvc"
8+
9+
CompilerSet errorformat=%C\ %\\{10\\\,}%m,
10+
\%o\ :\ %trror\ LNK%n:\ %m,
11+
\%E%f(%l\\\,%c):\ %trror\ :%m,
12+
\%E%f(%l\\\,%c):\ %trror\ C%n:%m,
13+
\%E%f(%l):\ %trror\ C%n:%m,
14+
\%E%f(%l\\\,%c):\ fatal\ %trror\ C%n:%m,
15+
\%E%f(%l):\ fatal\ %trror\ C%n:%m,
16+
\%W%f(%l\\\,%c):\ %tarning\ C%n:%m,
17+
\%W%f(%l):\ %tarning\ C%n:%m,
18+
\%I%f(%l\\\,%c):\ %tessage\ :%m,
19+
\%I%f(%l):\ %tessage\ :%m,
20+
\%-G%.%#
21+
22+
CompilerSet makeprg=cmake

start/cpptags/doc/cpptags.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Copyright: Copyright (C) 2024 Miguel Barro *cpptags-copyright*
2121
4. Usage.............................................: |cpptags-usage|
2222
REQUIRED TAG GENERATION OPTIONS...............: |cpptags-options|
2323
NEW TAG SYNTAX................................: |cpptags-syntax|
24+
5. Compiler plugins..................................: |cpptags-compiler|
2425

2526
==============================================================================
2627
2. Motivation *cpptags-motivation*
@@ -204,3 +205,41 @@ All the above rules can be combined together, for example in: >
204205
the command: >
205206
:tag A::B::m<true>(int)
206207
will match case b which is the result of combining the rules above.
208+
209+
==============================================================================
210+
5. Compiler plugins *cpptags-compiler*
211+
212+
For convenience some extra compiler plugins are bundled:
213+
`cmake_msvc` which sets up |'errorformat'| for Visual C/C++ compiler ouput.
214+
• `cmake _gcc` which sets up |'errorformat'| for gcc/c++ compiler ouput.
215+
216+
In the plugis the |'makeprg'| is set up plainly as `cmake`. Thus, |:make| will
217+
require arguments, at least the `--build` one.
218+
219+
Note that using `cmake` to compile requires two stages:
220+
221+
• Generator stage to create the project native files associated with the
222+
selected generator. >sh
223+
$ cmake -B <binary-path> <source-path>
224+
< where:
225+
<binary-path> is the folder where the native project files will
226+
be created.
227+
<source-path> is the folder where the C/C++ sources are.
228+
This stage must be executed before the |:make| call.
229+
230+
• Build stage where the native tools are called to compile.
231+
This is the one associated with the |:make| call. >sh
232+
$ cmake --build <binary-path>
233+
< With the default plugin set up for |'makeprg'| the call would be: >vim
234+
:make --build <binary-path>
235+
236+
Is convenient to customize |'makeprg'| to match specific use cases.
237+
For example, is possible to run `cmake` onto `wsl2` from a `vim` instance
238+
running on the windows host. >
239+
:let &makeprg = "wsl cmake --build <binary-path> *>&1 \\| \\\% { $_ -replace '/mnt/c', 'C:' }"
240+
In this case `vim` is using `powershell` as shell (see |dos-powershell|) and
241+
the source path files referenced in the compiler output must be translated back
242+
to windows host paths (otherwise traversal of the list of errors would not
243+
work).
244+
245+
vim:tw=78:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)