Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Incremental completion for jq-interactively #27

Open
Galagora opened this issue Oct 9, 2020 · 3 comments
Open

Feature request: Incremental completion for jq-interactively #27

Galagora opened this issue Oct 9, 2020 · 3 comments

Comments

@Galagora
Copy link

Galagora commented Oct 9, 2020

It would be great to be able to see the buffer narrowing as you type (and perhaps have tab-completion). Wrapping calls to jq in something like this would get you part of the way there, but you'd then need to reconstruct the original query:

.|with_entries(select(.key|match("^foo.*")))

*Of course, this breaks lists

@ljos
Copy link
Owner

ljos commented Oct 12, 2020

Thank you for contributing to jq-mode.

I am not sure I understand what you are suggesting.

buffer narrowing as you type

jq-interactively should already show the result of the command that you type.

By tab-completion, do you mean completion based on what is in the json?

That could be interesting.

@Galagora
Copy link
Author

Let me illustrate my request with an example. Say you have a JSON file:

{"foobar": 1, "foobaz": 2, "fooquux": 3}

Currently if you type .foob, the buffer shows null. But ideally, it should wrap your query in .|with_entries(select(.key|match("^foob.*"))), so that as you type, the buffer gets narrowed to {"foobar": 1, "foobaz": 2}. You can then press a key (say, C-c C-c) to unwrap your query back to .foob, or have it done when you type a |.

From this, tab completion comes naturally. The query can be completed to the greatest common prefix using the list of matching keys.

I'll get to implementing this sometime soon. Of course, it will be configurable, and probably off by default.

@ljos
Copy link
Owner

ljos commented Oct 13, 2020

That sounds like a nice feature! I am not entirely how that would be implemented in practice, but I am more than happy to accept a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants