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

feat: use relative path for a better initial view in :buffers #166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gh-liu
Copy link

@gh-liu gh-liu commented May 23, 2024

Use relative paths for a better initial view in :buffers and ensure that the result of bufname() is also a relative path.

before:
Snipaste_2024-05-23_10-11-17
Snipaste_2024-05-23_10-11-06

after:
Snipaste_2024-05-23_10-10-23
Snipaste_2024-05-23_10-10-43

@cbochs
Copy link
Owner

cbochs commented May 23, 2024

Hi @gh-liu, thanks for the PR!

Unfortunately, I don't think this is a safe change. It might not always be a good idea to shorten the path, some users might want the absolute path to use in a custom command function they've set. I might recommend instead to use the following in your configuration.

require("grapple").setup({
    command = function(path)
        local short_path = vim.fn.fnameescape(vim.fn.fnamemodify(path, ":."))
        vim.cmd.edit(short_path)
    end
})

@gh-liu
Copy link
Author

gh-liu commented May 24, 2024

Hi @gh-liu, thanks for the PR!

Unfortunately, I don't think this is a safe change. It might not always be a good idea to shorten the path, some users might want the absolute path to use in a custom command function they've set. I might recommend instead to use the following in your configuration.

require("grapple").setup({
    command = function(path)
        local short_path = vim.fn.fnameescape(vim.fn.fnamemodify(path, ":."))
        vim.cmd.edit(short_path)
    end
})

Thanks for your reply.
I have tried using <cr> to select, which works, but using | to select(vsplit) does not works.

@cbochs
Copy link
Owner

cbochs commented May 24, 2024

I have tried using to select, which works, but using | to select(vsplit) does not works.

I cannot seem to reproduce this easily on my side. Are you seeing an error? Does it not do anything at all? Is it closing the popup window?

@gh-liu
Copy link
Author

gh-liu commented May 25, 2024

Are you seeing an error?

No.

Does it not do anything at all?

Yes, using | to select(vsplit), the path is still absolute.

Is it closing the popup window?

Yes.

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.

2 participants