Extra completion for some kitty options
This commit is contained in:
parent
c2a2b4c087
commit
25a7ec9a07
@ -66,6 +66,11 @@ def generate_completions_for_kitty() -> None:
|
|||||||
print('k.Subcommand_must_be_first = true')
|
print('k.Subcommand_must_be_first = true')
|
||||||
for opt in go_options_for_seq(parse_option_spec()[0]):
|
for opt in go_options_for_seq(parse_option_spec()[0]):
|
||||||
print(opt.as_completion_option('k'))
|
print(opt.as_completion_option('k'))
|
||||||
|
from kitty.config import option_names_for_completion
|
||||||
|
conf_names = ', '.join((f'"{serialize_as_go_string(x)}"' for x in option_names_for_completion()))
|
||||||
|
print(f'k.find_option("-o").Completion_for_arg = complete_kitty_override("Config directives", []string{{{conf_names}}})')
|
||||||
|
print('k.find_option("--listen-on").Completion_for_arg = complete_kitty_listen_on')
|
||||||
|
|
||||||
print('plus := k.add_command("+", "Entry point")')
|
print('plus := k.add_command("+", "Entry point")')
|
||||||
print('plus.Description = "Various special purpose tools and kittens"')
|
print('plus.Description = "Various special purpose tools and kittens"')
|
||||||
|
|
||||||
|
|||||||
@ -125,6 +125,9 @@ def completion(self: TestCompletion, tdir: str):
|
|||||||
add('kitty --directory ', all_words('bin/', 'sub/'))
|
add('kitty --directory ', all_words('bin/', 'sub/'))
|
||||||
add('kitty -1d ', all_words('bin/', 'sub/'))
|
add('kitty -1d ', all_words('bin/', 'sub/'))
|
||||||
add('kitty -1d', all_words('-1d'))
|
add('kitty -1d', all_words('-1d'))
|
||||||
|
add('kitty -o a', has_words('allow_remote_control='))
|
||||||
|
add('kitty --listen-on ', all_words('unix:', 'tcp:'))
|
||||||
|
add('kitty --listen-on unix:b', all_words('unix:bin/'))
|
||||||
add('kitty --directory=', all_words('--directory=bin/', '--directory=sub/'))
|
add('kitty --directory=', all_words('--directory=bin/', '--directory=sub/'))
|
||||||
add('kitty --start-as=m', all_words('--start-as=minimized', '--start-as=maximized'))
|
add('kitty --start-as=m', all_words('--start-as=minimized', '--start-as=maximized'))
|
||||||
add('kitty @launch --ty', has_words('--type'))
|
add('kitty @launch --ty', has_words('--type'))
|
||||||
|
|||||||
@ -48,6 +48,31 @@ func complete_kitty(completions *Completions, word string, arg_num int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func complete_kitty_override(title string, names []string) completion_func {
|
||||||
|
return func(completions *Completions, word string, arg_num int) {
|
||||||
|
mg := completions.add_match_group(title)
|
||||||
|
for _, q := range names {
|
||||||
|
if strings.HasPrefix(q, word) {
|
||||||
|
mg.add_match(q + "=")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func complete_kitty_listen_on(completions *Completions, word string, arg_num int) {
|
||||||
|
if !strings.Contains(word, ":") {
|
||||||
|
mg := completions.add_match_group("Address family")
|
||||||
|
for _, q := range []string{"unix:", "tcp:"} {
|
||||||
|
if strings.HasPrefix(q, word) {
|
||||||
|
mg.add_match(q)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if strings.HasPrefix(word, "unix:") && !strings.HasPrefix(word, "unix:@") {
|
||||||
|
fnmatch_completer("UNIX sockets", CWD, "*")(completions, word[len("unix:"):], arg_num)
|
||||||
|
completions.add_prefix_to_all_matches("unix:")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func complete_plus_launch(completions *Completions, word string, arg_num int) {
|
func complete_plus_launch(completions *Completions, word string, arg_num int) {
|
||||||
if arg_num == 1 {
|
if arg_num == 1 {
|
||||||
fnmatch_completer("Python scripts", CWD, "*.py")(completions, word, arg_num)
|
fnmatch_completer("Python scripts", CWD, "*.py")(completions, word, arg_num)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user