feat(bash): highlight arguments of trap and kill builtin commands

This commit is contained in:
Omar Valdez 2025-12-08 01:09:27 -08:00 committed by Christian Clason
parent 93537d6998
commit f47f549f74
2 changed files with 36 additions and 12 deletions

View file

@ -105,18 +105,6 @@
(special_variable_name) @constant (special_variable_name) @constant
; trap -l
((word) @constant.builtin
(#any-of? @constant.builtin
"SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1"
"SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP"
"SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH"
"SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4"
"SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11"
"SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13"
"SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6"
"SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX"))
(comment) @comment @spell (comment) @comment @spell
(test_operator) @operator (test_operator) @operator
@ -179,6 +167,30 @@
(word) @variable.parameter) (word) @variable.parameter)
]) ])
; help trap
(command
name: (command_name
(word) @_command)
argument: (word) @string.special
(#eq? @_command "trap")
(#any-of? @string.special "EXIT" "DEBUG" "RETURN" "ERR"))
; trap -l
(command
name: (command_name
(word) @_command)
argument: (word) @string.special
(#any-of? @_command "trap" "kill")
(#any-of? @string.special
"SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1"
"SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP"
"SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH"
"SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4"
"SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11"
"SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13"
"SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6"
"SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX"))
(declaration_command (declaration_command
(word) @variable.parameter) (word) @variable.parameter)

View file

@ -76,3 +76,15 @@
(#offset! @injection.content 0 1 0 -1) (#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children) (#set! injection.include-children)
(#set! injection.language "readline")) (#set! injection.language "readline"))
((command
name: (command_name) @_command
.
argument: [
(string)
(raw_string)
] @injection.content)
(#eq? @_command "trap")
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children)
(#set! injection.self))