### Motivation
It's very annoying to search env variable exactly by lprefix. The better
is to search by substring and sort results by the position of substring
and then alphabetically.
Closes#5386
### Before
```xsh
$TRA<Tab>
# nothing
```
### After
```xsh
$TRA<Tab>
# 'XONSH_TRACE_COMPLETIONS',
# 'XONSH_TRACE_SUBPROC',
# 'XONSH_TRACE_SUBPROC_FUNC',
# 'XONSH_TRACEBACK_LOGFILE',
# 'XONSH_SHOW_TRACEBACK',
# 'VC_GIT_INCLUDE_UNTRACKED'
```
## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
---------
Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* refactor: project requires 3.9+
changed as per NEP-29
https://numpy.org/neps/nep-0029-deprecation_policy.html
* test: nose type tests are deprecated in pytest now
* fix: deprecation of ast.Str and ast.Bytes and .s attribute access
* fix: deprecation of ast.Num,ast.NameConstant,ast.Ellipsis
* refactor: upgrade code to be py39+ using ruff
the changes are auto-generated
* refactor: remove typing.Annotated compatibility code
* fix: temporarily disable having xonsh syntax inside f-strings
* test: skip failing tests
there is no workaround for this version. It might get solved in the
final release though
* refactor: make XonshSession.completer lazily populated
this speedsup the tests as cmd_cache would not be actively populated
when used in default_completers function
* refactor: make presence of walrus operator default
* Update and rename README to README.rst
* Create hello_world.py
* Update README.rst
* init
* remove bashisms
* Transfer abbrevs to xontrib-abbrevs
* Transfer free-cwd to xontrib-free-cwd
* news
* black
* Transfer fish-completer to xonsh/xontrib-fish-completer
* Transfer vox to xonsh/xontrib-vox
* Transfer pdb, xog to xonsh/xontrib-debug-tools
* remove hello_world
* fix tests
* black
* fix whitespaces
* fix readme
* Update python_virtual_environments.rst
* Update README.rst
* Update xontribs_transfer.rst
---------
Co-authored-by: a <1@1.1>
* todo:
* refactor: remove usage of singleton in cmd-cache
* refactor: pass aliases/env to commands_cache on creation
reduce the usage of singletons
* fix: setting up mockups for tests
* feat: add $XONSH_CACHE_DIR
* refactor: use cache path to stire cmds-cache
* chore: todo
* feat: efficient cache commands per path and modified time
* refactor: move aliases to commands cache
now XonshSession is not needed to setup cmds-cache
* refactor: update tests
* fix: type annotation
* refactor: init aliases at commands-cache
* test: update failing tests
* fix: handle paths mtime changing
* docs: add news item
* refactor: remove $COMMANDS_CACHE_SIZE_WARNING
* fix: loading on windows fails because of setup sequence
* fix: failing tests
* Fixing bash completion bug when prefix started with '>', '<', or ':'
* Fixing code formatting
* More code formatting fixes
* Fixing test
* Refactor to fix bug by improving completion parser
* Supporting '<' and '>>' in completion parser
* Support for all IO redirect tokens
* Update test_pip_completer.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Fix tab-completion trailing space for command arguments that use equals sign
* Add test for completion of path ending with equal sign
* Move test_path_completers.py to tests/completers
* Restore _quote_paths() to original behaviour
* Apply trailing equal sign fix to _bash_quote_paths()
Use _bash_quote_paths instead of _quote_paths in complete_from_bash()
* Do not need to pass quote_paths=_bash_quote_paths
fix: qa error, it is not a class method
still B019 is raised from bugbear
fix: failing vox tests in windows
fix: unc check on windows on ci
fix: vox failing on windows
get_binary_path already appends .exe
* fix: pip -r appends spaces at the end
modularize completing output from subproc-out
* docs:
* fix: flake8
* fix: failing pip comp tests
* refactor: naming xonsh conflicts with actual package
the IDE completions don't work.
we add this naming convention instead.
* feat: option to filter after completion returned
this will help reduce some boilerplate, and we can enrich the filtering
behaviour
* feat: add gh completions
* fix: filtering out completions
* refactor: simplify invoking completer interface
* test: add fixture for xsh with os-env
* test: add tests for gh-completions
* fix: flake error
* fix: mypy errors and update gh completer tests
* fix: handle cross-platform line endings
* feat: include man,bash completer only if available
* todo: improve man page completions
* fix: failing man page tests
* fix: py 3.7 compatibility
* fix: qa error
* fix: stop dir completions
* feat: improve man page completions
now shows descriptions, recognizes more number of options correctly
* fix: update man page completions
* feat: support filtering based on display as well
* Update xonsh/completer.py
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
* style:
* test: xfail ptk-shell tests on windows
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
* todo
* test: remove usage of DummyEnv and setting .env attribute on xession fixture
one step closer to making too much of tweaking to xession during tests
* test: fix tests vox and gitstatus-prompt
* docs: update test-fixture usage
* fix: import flake8 error
* test: remove direct access to XSH in tests
* test: remove usage of XSH in test files
* todo
* test: use tmp-dir to create stubs
* refactor: use fixture factory to mock out XonshSession
* refactor: remove direct access of XSH from functions
* refactor: remove direct access of XSH from functions
* fix: qa checks
* refactor: rename variables to match their values
* test: update failing tests because it had no PATH set previously
* fix: remove builtins usage from pyghooks.py
* style:
* refactor: update tests to use fixtures
* fix: env varialbe is setup per function
some tests accidentally update the env variables and that is leaking
into next tests
* fix: failing vox tests
* test: set commands_cache per test
* test: fix failing tests
* fix: failing tests on linux
ptk-highlight
* fix: failing tests on Windows
cwd-prompt
* test: copy env as to not affect original object
* fix: lazily evaluate cmds-cache in pyghooks
* test: fix failing tests
* fix: qa errors import
* test: set commands-cache per test
while caching path results
* test: speedup test_thread_local_swap
* fix: failing tests on windows
* refactor: Execer doesn't control session
* refactor: XSH.unload will take care of reversing builtins attrs set
* test: use env.update over monkeypatch
* Revert "test: use env.update over monkeypatch"
This reverts commit 010a5022247a098f1741966b8af1bf758663480e.
* feat: update command completions to show description as well
closes#3823
* test: fix failing tests on windows
* fix: failing tests on windows machine
* feat: create field to define alias-completer
this will resolve checking parser or alias. Now the alias can define how
it completes.
will solve
https://github.com/xonsh/xonsh/pull/4267#discussion_r676066853
* docs:
* fix: mypy error
* fix: rst qa
* style:
* feat: improve pip completer
* refactor: optimize imports
* fix: update tests for other completers
* fix: failing tests
* test: fix failing tests
* refactor: make error message clear
exception like KeyError will be more clear now
* qs import
* fix: failing tests on windows
* fix: failing tests on windows
* fix: failing tests on windows
* refactor: optimize imports
* feat: use ArgparserAlias for xontrib
* test: add test for xontrib-name-completer
* fix: bashisms tests should unload module after tests
* test: make assertion failure message obvious
* fix: failing tests because autovox is already loaded in some py versions
* feat: use ArgparserAlias for xonfig
* test: update test for xonfig completions
* refactor: update docs
* refactor: use function based completer
* fix: remove old import
* docs:
* fix: merge issues
* test: move xsh_with_aliases to root conftest.py
* docs:
* feat: set subparser's prog from func-name
* feat: add colored help formatter and alias builder
closes#4284
* feat: add auto-completion support to argparser
* test: update test for completer
* fix: getting doc from params that have annotation
* refactor: use filter-function for checking alias completions
* doc: add discussion abount check for alias having parser
see discussion on
https://github.com/xonsh/xonsh/pull/4267
* type fix
* refactor: use function based completer
* test: fix failing argparser test
* docs: update news item
* update completion for argparser sub-commands to append_space
from comment on
https://github.com/xonsh/xonsh/pull/4267#discussion_r676044508
* docs: update docstring typo
* refactor: move inspect import to top
* feat: support option strings before positionals
and add env setting for showing completions for options by default
* test: update tests after adding new $ALIAS_COMPLETIONS_OPTIONS_BY_DEFAULT
* add suggested completion_context_parse fixture
* docs: add suggested doc for dispatch function
* refactor: use try/except for import of typing.annotated
* refactor: move complete_argparser_aliases to completers/aliases.py
* refactor: move argparser completer to its own module
* style:
* refactor: rename completer to not clash with argparse
* fix: expand option's descriptions
* fix: add completer/argparser to amalgam
* tests: Run tests with the amalgamated xonsh
* tests: Test xonsh loads correctly interactively
* tests: Ensure tests run from amalgamated xonsh
* environ: Separate $XONSH_DEBUG and $XONSH_NO_AMALGAMATE
* tests: Keep XONSH_NO_AMALGAMATE in a comment for ease of debugging
* tests: Fix monkeypatch for amalgamated code
* refactor: remove usage of global variables in abbrevs.py
* chore: add flake8-mutable to prevent mutable defaults
* fix: abbrevs expand test
* refactor: add xonsh session singleton
* refactor: fix circular errors when using xonshSession as singleton
* refactor: remove black magicked builtin attributes
* style: black format tests as well
* refactor: update tests to use xonsh-session singleton
* refactor: update abbrevs to not use builtins
* test: remove DummyCommandsCache and patch orig class
* fix: failing test_command_completers
* test: use monkeypatch to update xession fixture
* fix: failing test_pipelines
* fix: failing test_main
* chore: run test suit as single invocation
* test: fix tests/test_xonsh.xsh
* refactor: remove builtins from docs/conf.py
* fix: mypy error in jobs
* fix: test error from test_main
* test: close xession error in test_command_completers
* chore: use pytest-cov for reporting coverage
this will include subprocess calls, and will increase coverage
* style:
* Added env variable to ignore ./ and ../ in filepath completion
* Changed ignore_dots to complete dots as always, never, or upon matching
* Updated news
* Added default 'matching'
* Update ignore_dots.rst
* black
* fix test
* tests
Co-authored-by: Bailey Morgan <bailey.mccarty.morgan@gmail.com>
Co-authored-by: a <a@a.a>
* completion-context: Add CompletionContextParser placeholder
Implements the xonsh (tab-)completion context parser.
This parser is meant to parse a (possibly incomplete) command line.
* completers: tools: Implement ``contextual_completer`` decorator
This is used to mark completers that want to use the parsed completion context.
* completers: Enable using contextual completers in xonsh/completer.py
* completers: readline, ptk, jupyter: Enable using contextual completers
Pass ``multiline_text`` and ``cursor_index`` to ``Completer.complete()``
* parsers: base: Refactor out a ``raise_parse_error`` function
* tokenize: Enable ``tolerant`` mode
If ``tolerant`` is True, yield ERRORTOKEN instead of
throwing an exception when encountering an error.
* lexer: Enable ``tolerant`` mode
Tokenize without extra checks (e.g. paren matching).
When True, ERRORTOKEN contains the erroneous string instead of an error msg.
* tests: lexer: Test ``tolerant`` mode
* completion-context: Implement simple CommandContext parsing
* completion-context: tests: Test simple CommandContext parsing
* completion-context: Implement parsing sub-commands
* completion-context: tests: Test parsing sub-commands
* completion-context: Add news file
* completion-context: parser: Add parser table path to relevant locations
Code-coverage, mypy ignore list, etc.
* completion-context: Implement parsing partial strings and line continuations
* completion-context: tests: Test parsing partial strings and line continuations
* completion-context: Convert ``Span`` object to a ``slice``
* completion-context: Refactor out ``create_command`` and ``cursor_in_span``
* completion-context: Implement handling empty commands
* completion-context: tests: Test handling empty commands
* completion-context: Implement handling multiple commands
Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`
* completion-context: tests: Test handling multiple commands
Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`
* completion-context: Implement handling python context
* completion-context: tests: Test handling python context
* completers: tools: Add `contextual_command_completer`
* completers: Make `complete_skipper` contextual
* completers: Make `complete_from_man` contextual
* completers: Make `complete_from_bash` contextual and add test
* completers: Make `complete_pip` contextual and update tests
* completers: Keep opening string quote if it exists
* completion-context: Handle cursor after a closing quote
For example - cursor at the end of ``ls "/usr/"``.
1. The closing quote will be appended to all completions.
I.e the completion ``/usr/bin`` will turn into ``/usr/bin"``
2. If not specified, lprefix will cover the closing prefix.
I.e for ``ls "/usr/"``, the default lprefix will be 6 to include the closing quote.
* completion-context: tests: Test handling cursor after a closing quote
* completion-context: Fix bug with multiple empty commands
e.g. `;;;`
* completion-context: tests: Speed up tests
From ~15 seconds to ~500 ms
* completion-context: Expand commands and subcommands
* completion-context: Simplify `commands` rules
* completion-context: Simplify `sub_expression` rules
* completion-context: Simplify editing a multi-command token
* completion-context: Inline `create_command`
* completion-context: Implement `contextual_command_completer_for` helper
* completers: Make `complete_cd`/`complete_rmdir` contextual and add tests
* completers: path: Don't append a double-backslash in a raw string
When completing a path, if a raw string is used (e.g. `r"C:\Windows\"`),
there's no reason to append a double-backslash (e.g. `r"C:\Windows\\"`).
* completers: Make `complete_xonfig`/`complete_xontrib` contextual and add tests
* completers: Make `complete_completer` contextual and add tests
* completers: Make `complete_import` contextual and add tests
* completion-context: Add python `ctx` attribute
* completion: tools: Simplify `RichCompletion` attributes handling
* completers: Make `base`, `python`, and `commands` contextual
* Add tests
* No need for `python_mode` completer anymore
* completion: tools: Add `append_space` attribute to `RichCompletion`
* completion-context: Get all lines in a main python context
* xontrib: jedi: Make the `jedi` completer contextual
* completers: tools: Remove `get_ptk_completer` and `PromptToolkitCompleter.current_document`
These aren't needed anymore now that contextual completers can access the multiline code (via `PythonContext.multiline_code`).
* completion-context: ptk: Expand aliases
* completion-context: jupyter: Expand aliases and fix line handling
* completer: Preserve custom prefix after closing quote
* completers: bash: Ensure bash completion uses the complete prefix
* completers: pip: Append a space after a pip command
* completers: pip: Prevent bad package name completions
* completers: Remove a common prefix from `RichCompletion` if `display` wasn't provided
* completion-context: Treat cursor at edge of `&& || | ;` as normal args
This will be used for completing a space
* completers: Complete end proc keywords correctly
* flake8 fixes -- tests only
* fix ci failure
* integrate fix from is_3551 so tests will pass.
* Update tests/test_builtins.py
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>