Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • ion ion
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 84
    • Issues 84
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • redox-os
  • ionion
  • Merge requests
  • !780

WIP: Tab completions

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed BafDyce requested to merge BafDyce/ion:tab-completions-wip into master Jun 10, 2018
  • Overview 22
  • Commits 9
  • Changes 23

IMPORTANT This is sorta, kinda WIP and NOT intended to be merged as it is! The code still needs a few tweaks, and the commits are not meaningful on their own (I just committed all wip-stuff at once when I made breaks). This is more like a proposal and a basis for discussion.

Problem: This PR adds support for tab completions. See #397

Solution: The general idea: For each application, there is a user-friendly config file (RON-format) which defines different types of command line parameters, etc. Currently supported features:

  • boolean flags (e.g. --version)
  • paths
  • files with specific file extensions
  • numbers
  • key=value
  • string (aka "everything else that takes custom values") with support for options (predefined list of possible values)

If an application has no completion-config, the default file file completer is used.

Changes introduced by this pull request:

  • New dependencies: libflate, ron, serde
  • A new completer (IonCmdCompleter) was created, similar to the existing IonFileCompleter
  • When the user hits tab twice and the application (first word on the command line) has a completion defined, it is examined for possible matches.
  • I've added a base ("empty") config file as well as two (unfinished) configs for cargo and git.

Drawbacks:

  • I don't know if my code structure/architecture is fine, as I figured out how liner works as I worked on this, so the code may be restructured more cleanly?
  • Also, I had to add an unsafe (https://gitlab.redox-os.org/BafDyce/ion/blob/adb13743757078f021614e89a8820958ea15203e/src/lib/shell/completer.rs#L71) to satisfy the borrow checker. Don't know if this can be avoided by restructuring.
  • Aliases (different names for the same application) are not handled/implemented yet.
  • Tab completions don't work when using the absolute path
    • For both issues we would need some efficient HashMap-like data structure to map multiple keys to the same value

TODOs:

  • Discuss whether such a config-file based solution is wanted. mmstick seems to be OK with it!? ;)
  • Add support for "dynamic" parameters (list of completions generated at runtime by executing an ion script?)
  • Add support for "scheme" parameters
  • Decide where to save the config files -> ION_CONFIG_DIR/completions/
    • Add hook for installation script
    • Adapt initialization code accordingly Implement lazy-loading functionality
  • Fix issue: auto-complete does not work if the cursor is on the right edge of a completed parameter (no space is inserted afterwards) Fixed by recent liner upgrade
  • Cleanup the code, Add comments
  • Rebase onto current master and fix merge conflicts
  • Add a new builtin for (re)loading completions at runtime
  • Implement parsers to import completions:
    • From man-pages
      • Improve parsing capabilities (subcommands, detect & filter invalid parsed files)
  • Test on Redox (currently only on Linux tested)
  • Add a bunch of completion configs.
  • Add completions for ion builtins
  • CI: Add validation of supplied completion files (just check whether they can be parsed correctly)
  • rustmft
  • clippy
  • Bug fixes

Fixes: #397

State: WIP

Blocking/related: None that I know of.

Other:

I'm open for feedback, however I'll also be busy in the next days.

Edit 2018-06-17: Update text to match current state of MR

Edited Jun 22, 2018 by BafDyce
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: tab-completions-wip