prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Options for multiline completions

Open
#1,606 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

Hi
I would like to be able to have a way to display multiline data on the meta property of a completion, ideally it'd be a secondary window like in neovim:

nvim
but if that's too complicated it can also be useful in a bottom/top bar (classic vim):
Screenshot from 2022-03-27 12-57-05

I've hacked a bit some examples and came up with this:
Screenshot from 2022-03-27 13-02-03
however I don't see a way to make the metadata not show in the prompt completion, and having it visible twice is not great

This image comes from:


def bottom_toolbar():
    cs = get_app().current_buffer.complete_state
    if cs and cs.current_completion:
        cc = cs.current_completion
        return cc.display_meta
    else:
        return None


def main():
    sess = PromptSession(
        completer=animal_completer,
        bottom_toolbar=bottom_toolbar,
    )
    text = sess.prompt(
        "Give some animals: ",
    )
    print("You said: %s" % text)

I would also be OK if I can somehow generate a floating window and stick it next to the completions -- but I haven't figured out how to do this yet

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how completion metadata is exposed through current_completion and display_meta, using the bottom_toolbar() example in the issue as the entry point. Compare the requested secondary-window and top/bottom-bar presentation options, then define an implementation approach that avoids showing the metadata twice. Done should include a documented, tested way to display multiline completion metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.