|
1 |
| -*quickfix.txt* For Vim version 9.1. Last change: 2024 Dec 16 |
| 1 | +*quickfix.txt* For Vim version 9.1. Last change: 2024 Dec 27 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar
|
@@ -1424,6 +1424,70 @@ of |:make|, and assigning its |Funcref| to the selected key. For example:
|
1424 | 1424 | \ function('GenericPostCompilerCommand'),
|
1425 | 1425 | \ }
|
1426 | 1426 |
|
| 1427 | +When "PostCompilerAction" is available, "PostCompilerActionExecutor" is also |
| 1428 | +supported. Its value must be a Funcref pointing to a function that always |
| 1429 | +declares a single parameter of type string and decides whether |:execute| can |
| 1430 | +be dispatched on its argument, containing a pending post-compiler action, |
| 1431 | +after ascertaining the current status of |:cc| (or |:ll|): >vim |
| 1432 | + |
| 1433 | + function! GenericPostCompilerActionExecutor(action) abort |
| 1434 | + try |
| 1435 | + cc |
| 1436 | + catch /\<E42:/ |
| 1437 | + execute a:action |
| 1438 | + endtry |
| 1439 | + endfunction |
| 1440 | + |
| 1441 | +Complementary, some or all of the available "Pre*Action"s (or "*Pre*Command"s) |
| 1442 | +may run `:doautocmd java_spotbugs_post User` in their implementations before |
| 1443 | +|:make| (or its equivalent) to define a once-only |ShellCmdPost| `:autocmd` |
| 1444 | +that will arrange for "PostCompilerActionExecutor" to be invoked; and then run |
| 1445 | +`:doautocmd java_spotbugs_post ShellCmdPost` to consume this event: >vim |
| 1446 | + |
| 1447 | + function! GenericPreCompilerCommand(arguments) abort |
| 1448 | + if !exists('g:spotbugs_compilation_done') |
| 1449 | + doautocmd java_spotbugs_post User |
| 1450 | + execute 'make ' . a:arguments |
| 1451 | + " only run doautocmd when :make was synchronous |
| 1452 | + " see note below |
| 1453 | + doautocmd java_spotbugs_post ShellCmdPost " XXX: (a) |
| 1454 | + let g:spotbugs_compilation_done = 1 |
| 1455 | + else |
| 1456 | + cc |
| 1457 | + endif |
| 1458 | + endfunction |
| 1459 | + |
| 1460 | + function! GenericPreCompilerTestCommand(arguments) abort |
| 1461 | + if !exists('g:spotbugs_test_compilation_done') |
| 1462 | + doautocmd java_spotbugs_post User |
| 1463 | + execute 'make ' . a:arguments |
| 1464 | + " only run doautocmd when :make was synchronous |
| 1465 | + " see note below |
| 1466 | + doautocmd java_spotbugs_post ShellCmdPost " XXX: (b) |
| 1467 | + let g:spotbugs_test_compilation_done = 1 |
| 1468 | + else |
| 1469 | + cc |
| 1470 | + endif |
| 1471 | + endfunction |
| 1472 | + |
| 1473 | + let g:spotbugs_properties = { |
| 1474 | + \ 'compiler': 'maven', |
| 1475 | + \ 'DefaultPreCompilerCommand': |
| 1476 | + \ function('GenericPreCompilerCommand'), |
| 1477 | + \ 'DefaultPreCompilerTestCommand': |
| 1478 | + \ function('GenericPreCompilerTestCommand'), |
| 1479 | + \ 'PostCompilerActionExecutor': |
| 1480 | + \ function('GenericPostCompilerActionExecutor'), |
| 1481 | + \ } |
| 1482 | + |
| 1483 | +If a command equivalent of `:make` is capable of asynchronous execution and |
| 1484 | +consuming `ShellCmdPost` events, `:doautocmd java_spotbugs_post ShellCmdPost` |
| 1485 | +must be removed from such "*Action" (or "*Command") implementations (i.e. the |
| 1486 | +lines `(a)` and `(b)` in the listed examples) to retain a sequential order for |
| 1487 | +non-blocking execution, and any notification (see below) must be suppressed. |
| 1488 | +A `ShellCmdPost` `:autocmd` can be associated with any |:augroup| by assigning |
| 1489 | +its name to the "augroupForPostCompilerAction" key. |
| 1490 | + |
1427 | 1491 | When default actions are not suited to a desired workflow, proceed by writing
|
1428 | 1492 | arbitrary functions yourself and matching their Funcrefs to the supported
|
1429 | 1493 | keys: "PreCompilerAction", "PreCompilerTestAction", and "PostCompilerAction".
|
|
0 commit comments