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

term: Add % expansion for relative path to current file #7090

Closed
wants to merge 1 commit into from

Conversation

valpackett
Copy link
Contributor

This is especially useful for creating a file next to the current one, and is inspired by vim's expansions (but only handles the basic case of course).

hx cast

I've been missing this from nvim (kakoune too iirc??) ever since I switched, finally got frustrated enough to just implement it :)

This is especially useful for creating a file next to the current one,
and is inspired by vim's expansions (but only handles the basic case of course).
@kirawi
Copy link
Member

kirawi commented May 21, 2023

See #6979

@valpackett
Copy link
Contributor Author

See #6979

hm. I'm not sure these should be related. Maybe % could also be implemented as %val{filename} from that PR, but

  • that right now seems to expand as the absolute path, and I assume that is very much desired in various places, so there would have to be some %val{relfilename} or something
  • here I'm changing the completion function for files, which results in intuitive and friendly behavior: note how just typing % already shows the expanded path in the tab completion list, just like ~ on its own for absolute home dir path. I'm not sure the behavior would be the same with that implementation, as I see that PR touches the general prompt text input code…

@philipgiuliani
Copy link
Contributor

In this PR the % char will be added as a register which allows to paste the current filename quickly: #6985

Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we need yet another way to expand to.the current file. Instead we could add %val{filename} (and all the other possible placeholders) to the list of completions. This automatically teaches users about the syntax without adding anything new. You couls rebase this PR on #6979 and implement that

@valpackett
Copy link
Contributor Author

valpackett commented May 21, 2023

add %val{filename} (and all the other possible placeholders) to the list of completions

How would this be done and how would it work? If the placeholders themselves would appear in completions, that would be useless for me.

My desired workflow is exactly as in the screencast, that is I need to be able to type :o %<Tab><Ctrl-W>new.file.name<Return> to open a file in the same directory as the current file. I'm not interested in even being aware of placeholders for this use case. One single simple character should expand to the whole path relative to the current directory so that I can edit the path inline.

The editing is the point. I'm surprised this wasn't a feature from the beginning. How do y'all currently create files in some nested hierarchy similar to the one of the current file? I'm tired of copy-pasting the path with the mouse from the status bar!

@kirawi
Copy link
Member

kirawi commented May 21, 2023

This PR is linked to #2985
Duplicate of #6985 which superseded #5577

@valpackett
Copy link
Contributor Author

It's literally not a duplicate @kirawi, it's a different approach for a different place.

I guess using the register isn't the worst considering that there apparently is a keybinding in prompts to paste from a register, but right now that DocumentPathRegister from #6985 does not make the path relative to the current directory. And… should it? When pasting into the text the absolute path might actually be wanted more often. But in the prompt, the path must be relative to the current directory.

But also I really want to specifically exactly press %<Tab> and not <Ctrl-R>% 😠

@valpackett valpackett closed this May 22, 2023
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

Successfully merging this pull request may close these issues.

4 participants