Add object files to ninja completions

When working on a C or C++ projects, it is often handy to compile a
single file (e.g. large refactoring where many files fail to compile so
compiling a single file results in less compiler errors making the compiler
output significantly easier to read and navigate). Current completion offers
only ninja targets which are usually just top level binaries. This commit makes
object files and library files to be offered in the ninja completion.

The change is inspired by the zsh ninja completion [1], but aims to reduce noise
by only matching for entries ending in ".o", ".so" or ".a".

[1] c828f06e08/src/zsh/_ninja (L30)

(cherry picked from commit 2e89e0c205)
This commit is contained in:
Rudolf Lovrenčić 2023-12-12 13:53:04 +01:00 committed by David Adam
parent 99254d74fe
commit bfe47e5979

View File

@ -13,6 +13,7 @@ end
function __fish_print_ninja_targets
__fish_ninja -t targets 2>/dev/null | string replace -r ':.*' ''
__fish_ninja -t targets all 2>/dev/null | string replace -r ':.*' '' | string match -e -r '\.(?:o|so|a)$'
end
complete -c ninja -f -a '(__fish_print_ninja_targets)' -d target
complete -x -c ninja -s t -x -a "(__fish_print_ninja_tools)" -d subtool