mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
descriptions for built-in xompleters
This commit is contained in:
parent
468eae8340
commit
2db0912c9b
6 changed files with 28 additions and 3 deletions
|
@ -6,6 +6,9 @@ from xonsh.completers.commands import complete_command
|
|||
|
||||
|
||||
def complete_base(prefix, line, start, end, ctx):
|
||||
"""If the line is empty, complete based on valid commands, python names,
|
||||
and paths. If we are completing the first argument, complete based on
|
||||
valid commands and python names."""
|
||||
if line.strip() == '':
|
||||
out = (complete_python(prefix, line, start, end, ctx) |
|
||||
complete_command(prefix, line, start, end, ctx))
|
||||
|
|
|
@ -24,7 +24,7 @@ for ((i=0;i<${{#COMPREPLY[*]}};i++)) do echo ${{COMPREPLY[i]}}; done
|
|||
|
||||
|
||||
def complete_from_bash(prefix, line, begidx, endidx, ctx):
|
||||
"""Attempts BASH completion."""
|
||||
"""Completes based on results from BASH completion."""
|
||||
if not INITED:
|
||||
_load_bash_complete_funcs()
|
||||
_load_bash_complete_files()
|
||||
|
|
|
@ -26,6 +26,10 @@ def complete_command(cmd, line, start, end, ctx):
|
|||
|
||||
|
||||
def complete_skipper(cmd, line, start, end, ctx):
|
||||
"""
|
||||
Skip over several tokens (e.g., sudo) and complete based on the rest of the
|
||||
line.
|
||||
"""
|
||||
res = line.split(' ', 1)
|
||||
if len(res) == 2:
|
||||
first, rest = res
|
||||
|
|
|
@ -6,12 +6,18 @@ PREVENT_OTHERS = ['path']
|
|||
|
||||
|
||||
def complete_cd(prefix, line, start, end, ctx):
|
||||
"""
|
||||
Completion for "cd", includes only valid directory names.
|
||||
"""
|
||||
if start != 0 and line.split(' ')[0] == 'cd':
|
||||
return complete_dir(prefix, line, start, end, ctx, True)
|
||||
return set()
|
||||
|
||||
|
||||
def complete_rmdir(prefix, line, start, end, ctx):
|
||||
"""
|
||||
Completion for "rmdir", includes only valid directory names.
|
||||
"""
|
||||
if start != 0 and line.split(' ')[0] == 'rmdir':
|
||||
return complete_dir(prefix, line, start, end, ctx, True)
|
||||
return set()
|
||||
|
|
|
@ -22,7 +22,8 @@ INNER_OPTIONS_RE = re.compile(r'-\w|--[a-z0-9-]+')
|
|||
|
||||
|
||||
def complete_from_man(prefix, line, start, end, ctx):
|
||||
"""Completes an option name, basing on content of man page."""
|
||||
"""Completes an option name, based on the contents of the associated man
|
||||
page."""
|
||||
global OPTIONS
|
||||
if not prefix.startswith('-'):
|
||||
return set()
|
||||
|
|
|
@ -17,11 +17,15 @@ XONSH_TOKENS = {
|
|||
'/', '//', '%', '**', '|', '&', '~', '^', '>>', '<<', '<', '<=', '>', '>=',
|
||||
'==', '!=', '->', '=', '+=', '-=', '*=', '/=', '%=', '**=', '>>=', '<<=',
|
||||
'&=', '^=', '|=', '//=', ',', ';', ':', '?', '??', '$(', '${', '$[', '..',
|
||||
'...'
|
||||
'...', '![', '!(',
|
||||
}
|
||||
|
||||
|
||||
def complete_python(prefix, line, start, end, ctx):
|
||||
"""
|
||||
Completes based on the contents of the current Python environment,
|
||||
the Python built-ins, and xonsh operators.
|
||||
"""
|
||||
filt = get_filter_function()
|
||||
rtn = {s for s in XONSH_TOKENS if filt(s, prefix)}
|
||||
if ctx is not None:
|
||||
|
@ -33,6 +37,9 @@ def complete_python(prefix, line, start, end, ctx):
|
|||
|
||||
|
||||
def complete_python_mode(prefix, line, start, end, ctx):
|
||||
"""
|
||||
Python-mode completions for @( and ${
|
||||
"""
|
||||
if not (prefix.startswith('@(') or prefix.startswith('${')):
|
||||
return set()
|
||||
prefix_start = prefix[:2]
|
||||
|
@ -88,6 +95,10 @@ def attr_complete(prefix, ctx, filter_func):
|
|||
|
||||
|
||||
def complete_import(prefix, line, start, end, ctx):
|
||||
"""
|
||||
Completes module names and contents for "import ..." and "from ... import
|
||||
..."
|
||||
"""
|
||||
ltoks = line.split()
|
||||
if len(ltoks) == 2 and ltoks[0] == 'from':
|
||||
# completing module to import
|
||||
|
|
Loading…
Add table
Reference in a new issue