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

fix(dirman): add raw_path option to work with arbitrary filetype #1143

Merged
merged 1 commit into from
Nov 8, 2023
Merged

fix(dirman): add raw_path option to work with arbitrary filetype #1143

merged 1 commit into from
Nov 8, 2023

Conversation

pysan3
Copy link
Contributor

@pysan3 pysan3 commented Nov 5, 2023

core.dirman.utils.expand_path is the function to resolve filepath with workspace notation ($<workspace>/).

This should work with arbitrary file type as it will be used to resolve files in for example .image $/relative/path/to/image.png, but currently, it is hardcoded to append .norg after the file path.

I've added an argument raw_path which, when is true, does not append the norg extension.

The previous calls to this function does not specify this arg, (hence nil) so we should have backwards compatibility.

Note

-- If the path isn't absolute (doesn't begin with `/` nor `~`) then prepend the current file's
-- filehead in front of the path
path = (vim.tbl_contains({ "/", "~" }, path:sub(1, 1)) and "" or (vim.fn.expand("%:p:h") .. "/")) .. path

Not in the scope of this PR but I don't think this works on Windows. I don't have an environment to test Windows so I'll leave it to someone else for a fix.

Possibly related: #241

@pysan3
Copy link
Contributor Author

pysan3 commented Nov 5, 2023

@vhyrro
Copy link
Member

vhyrro commented Nov 8, 2023

Looks good to me! That path logic should be ideally fixable with some vim.fs functions.

@vhyrro vhyrro merged commit 0c9f5de into nvim-neorg:main Nov 8, 2023
1 check passed
@pysan3 pysan3 deleted the fix-expand-path branch November 8, 2023 13:54
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