Giter VIP home page Giter VIP logo

Comments (2)

chrisant996 avatar chrisant996 commented on June 15, 2024

Short Version:

No.

But you could make a new command in a Lua script.

This zip file contains a script which might be what you want: issue556.zip
(Little was stated about what's desired, so I made a lot of guesses.)

Long Version:

First I think it's worth clarifying some things that were stated but aren't accurate or are oversimplifications.

Clink offers two separate logic systems for auto-completion:
one is Auto-Suggestions, which are based on past input history

Suggestions are a suggestion for a whole command line, which could be many words. Clink includes 3 built-in suggestion strategies; two use the history list to attempt to provide a suggestion, and one uses match generators ("completion") to provide a suggestion.

And suggestion strategies can use whatever they want. For example, a doskey strategy could suggest adding $* to the end of a doskey macro being created. Or a strategy could make suggestions based on GPS location, or what program will be launched, or what time it is, or even using AI to predict what the user is trying to accomplish and what they might want to do next.

and the other is Completion, which provides suggestions according to the current directory context.

Match generators provide a context-sensitive list of words for a single word at the current word position in the command line, and the various completion commands have different strategies for how to use the list of matches for "completing" the current word that's being entered.

File and directory match generators provide a list of words (files or directories) based on the current directory context. There are many other match generators that provide a list of words based on criteria that aren't related to directory context. For example, after git has been input then a git completion script would provide a list of words based on the available git commands.

The shortcut key for Auto-Suggestions is Tab, while the shortcut for Completion is the Right arrow key.

It's the other way around.

The default key binding for Tab is either complete or old-menu-complete depending on whether bash or Windows default key bindings are selected via clink.default_bindings. Those use very different completion strategies.

The default key binding for Right is either forward-char or win-cursor-forward depending on whether bash or Windows default key bindings are selected.

The inquiry is whether it's feasible to combine these two functionalities into a single mechanism and use Tab consistently as the shortcut, such that upon the first press of Tab, Auto-Suggestions would be displayed, and subsequent presses of Tab would then cycle through to the Completion feature.

It sounds like you're focused on one specific completion strategy, i.e. the one that cycles through possible completions. The suggestion seems inherently incompatible with the other completion commands like complete or clink-select-complete or etc.

The suggestion is ambiguous, but I think you're saying:

  1. You want to never see a suggestion preview shown in a dimmed color.
  2. You want Right to never insert a suggestion even if one is available.
  3. You want Tab to take what the completion list was provided by match generators, and you want to insert the whole-command-line suggestion at the beginning of the completion list.
  4. You essentially want to convert the whole-command-line suggestion into a kind of completion instead.

It's a rough idea, and it introduces many nuanced problems that are either expensive or possibly even impossible to resolve. Especially since 2 of the 3 built-in completion strategies are inherently incompatible with the idea. And what about when using custom completion strategies, such as fzf?

I get the general concept. But it's only compatible with one specific narrow way of using Clink. I can't go making Clink incompatible with itself and with scripts; that would create problems for many users, and would leave lots of things just broken.

I don't see how it's something that could be built into Clink itself. But a Lua script could make new commands that might do what's desired, and then if the scripts are incompatible with various commands and/or settings and/or other scripts then it's not necessarily as much of a problem as if the commands were built into Clink.

from clink.

bytetip avatar bytetip commented on June 15, 2024

Thank you for the comprehensive explanation and the provided script. I fully concur with your viewpoint.

Given the intrinsic complexities, merging Auto-Suggestions and Completion into a single Tab shortcut is not practically viable. Customizing through Lua scripts ensures compatibility and better aligns with Clink's diverse functionalities.

Moving forward, I will be testing and optimizing based on the Lua script you have supplied.

from clink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.