xonsh/xontrib/fish_completer.py
Noorhteen Raja NJ ecc1ab1020
xontrib load/unload (#4817)
* feat: add function to make event registration from function signature

* docs: add xontrib special functions description

* feat: handle xontribs with special functions

also reduce usage of XSH singleton

* fix: missing XSH

for now import singleton

* docs: fix .rst format

* fix: failing tests

* feat: implement primitive xontrib-unload and xontrib-reload

* chore: give explicit name

* docs: update doc
2022-05-30 15:33:17 +05:30

30 lines
836 B
Python

"""Populate rich completions using fish and remove the default bash based completer"""
from xonsh.completers import completer
from xonsh.completers.tools import complete_from_sub_proc, contextual_command_completer
from xonsh.parsers.completion_context import CommandContext
@contextual_command_completer
def fish_proc_completer(ctx: CommandContext):
if not ctx.args:
return
line = ctx.text_before_cursor
script_lines = [
f"complete --no-files {ctx.command}", # switch off basic file completions for the executable
f"complete -C '{line}'",
]
return (
complete_from_sub_proc(
"fish",
"-c",
"; ".join(script_lines),
),
False,
)
def _load_xontrib_(**_):
completer.add_one_completer("fish", fish_proc_completer, "<bash")