More work on completions

This commit is contained in:
Kovid Goyal
2022-09-07 10:55:07 +05:30
parent d0efe00449
commit 63287e4115
4 changed files with 82 additions and 36 deletions

View File

@@ -3,6 +3,7 @@
import io
import json
import sys
from contextlib import contextmanager, suppress
from typing import Dict, Iterator, List, Set, Tuple, Union
@@ -45,6 +46,17 @@ def replace(template: str, **kw: str) -> str:
# }}}
def generate_completions_for_kitty() -> None:
from kitty.entry_points import entry_points, namespaced_entry_points
print('package completion\n')
print('func kitty(root *Command) {')
print('k := root.add_command("kitty")')
print('}')
print('func init() {')
print('registered_exes["kitty"] = kitty')
print('}')
# rc command wrappers {{{
json_field_types: Dict[str, str] = {
'bool': 'bool', 'str': 'string', 'list.str': '[]string', 'dict.str': 'map[string]string', 'float': 'float64', 'int': 'int',
@@ -247,7 +259,13 @@ def update_at_commands() -> None:
def update_completion() -> None:
pass
orig = sys.stdout
try:
with replace_if_needed('tools/completion/kitty_generated.go') as f:
sys.stdout = f
generate_completions_for_kitty()
finally:
sys.stdout = orig
def main() -> None: