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

$EDITOR for SQL/PRQL commands #1396

Closed
Mr-Andersen opened this issue Feb 18, 2025 · 4 comments
Closed

$EDITOR for SQL/PRQL commands #1396

Mr-Andersen opened this issue Feb 18, 2025 · 4 comments
Labels
enhancement Feature Request

Comments

@Mr-Andersen
Copy link

Mr-Andersen commented Feb 18, 2025

Is your feature request related to a problem? Please describe.

My PRQL expression got really big. It would be much nicer to write it in a more capable editor. Also, that would make it easier to save the expression elsewhere --- currently, this is tedious process of copying the expression in chunks.

Describe the solution you'd like
A shortcut to open current expression in $EDITOR? E.g. I press ;, then I press Ctrl+; (or whatever), and $EDITOR replaces lnav. On exit, whatever I've left in editor is used as new expression.

@Mr-Andersen Mr-Andersen added the enhancement Feature Request label Feb 18, 2025
@tstack
Copy link
Owner

tstack commented Feb 18, 2025

See #1380

Right now, just the :comment command is wired up to use the multi-line prompt. I'll be doing the same for SQL/PRQL soon.

tstack added a commit that referenced this issue Feb 22, 2025
@tstack
Copy link
Owner

tstack commented Feb 22, 2025

The top-of-tree should be usable with the new prompt if you want to give it a try. Here's a screencap of it in action:

lnav-multiline-prql.mp4

In the prompt, you can press CTRL+L to switch the prompt to multi-line mode and reformat the query. In multi-line mode, press CTRL+X to run the query.

tstack added a commit that referenced this issue Feb 27, 2025
@tstack
Copy link
Owner

tstack commented Feb 27, 2025

Also, that would make it easier to save the expression elsewhere

I've tried to address this in two ways:

  • you can highlight the text with the mouse now (or shift-arrow-key) and then press CTRL+K to cut the text to the clipboard (pressing CTRL+Y will paste from the clipboard to restore it);
  • pressing CTRL+O will save contents of the prompt to the lnav config directory under "formats/installed/saved-prompt.lnav" and try to open that file with VSCode (or the macOS default text editor). The prompt will close after this, but you can just run |saved-prompt to execute the prompt as you change it in the editor. VSCode is the default since there is an lnav extension for it.

I think the changes so far pretty much cover what is mentioned in this request. So, I'll close it soon, unless you have some other thoughts. Thanks.

@Mr-Andersen
Copy link
Author

This is great, thank you

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

No branches or pull requests

2 participants