xonsh/news
Daniel Shimon 224fc55e41
Completion context (#4017)
* 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
2021-03-30 13:37:56 -04:00
..
appimage_alpine.rst docs: Running xonsh AppImage on Alpine (#4159) 2021-03-10 09:27:25 -05:00
appimage_xpip_sudo.rst fix: xpip sudo behavior in xonsh appimage (#4192) 2021-03-22 16:07:30 -04:00
BOM-bug.rst fix: use 'utf-8-sig' instead of 'utf-8' to allow importing user modules with a 'UTF-8 with BOM' encoding (#4161) 2021-03-15 17:04:45 -04:00
catch_callable.rst Catch callable in the arguments list (#4191) 2021-03-22 16:17:54 -04:00
completion-context.rst Completion context (#4017) 2021-03-30 13:37:56 -04:00
cp_int_hash.rst Added casting CommandPipeline to int, hash, str (#4205) 2021-03-30 13:36:01 -04:00
fix-abbrevs-callback.rst fix: abbrevs with callback alters buffer text before expansion (#4156) 2021-03-09 09:07:53 -05:00
fix-json-hist-gc-seconds.rst Fix garbage collection of JSON history specified in seconds. (#4098) 2021-03-22 16:20:36 -04:00
fix_history_reading.rst fix: Not load history in not interactive (#4178) 2021-03-15 11:15:15 -04:00
fix_orend.rst fix: and/or colorize (#4188) 2021-03-22 16:13:21 -04:00
fix_prompt_like_title.rst #4148 TITLE can be set to a function (#4190) 2021-03-22 13:40:12 -04:00
fix_xonfig.rst fix xonfig (#4173) 2021-03-12 09:45:36 -05:00
gitstatus_lines.rst add lines changed and removed in gitstatus (#4133) 2021-03-04 15:53:30 -05:00
improve-which-output.rst Improve which output (#4196) 2021-03-22 16:06:41 -04:00
PEP263upd.rst update imphooks encoding regex to match the newer version at PEP 263 (#4162) 2021-03-22 14:13:13 -04:00
shelltypes.rst Clean up shell check aliases (#4145) 2021-03-08 10:56:06 -05:00
starship.rst starship (#4147) 2021-03-07 09:50:02 -05:00
TEMPLATE.rst single instance of string.Formatter 2018-10-20 12:22:59 -06:00
update-bash-completion.rst bash-completion: Update to 0.2.7 (#4153) 2021-03-08 10:36:03 -05:00
welcome_message.rst Welcome message: fix color, add ptk warning (#4143) 2021-03-07 09:51:07 -05:00
XONSH_HISTORY_FILE.rst Fix XONSH_HISTORY_FILE (#4146) 2021-03-06 10:14:11 -05:00
XONSH_HISTORY_FILE_setting.rst feat: Added ability to set XONSH_HISTORY_FILE (#4175) 2021-03-16 17:07:11 -04:00
xontrib-linuxbrew.rst feat: add xontrib-linuxbrew (#4139) 2021-03-05 10:15:08 -05:00