Skip to content

fix(links): Resolve bare file: paths from org file - #1198

Merged
seflue merged 1 commit into
nvim-orgmode:masterfrom
seflue:fix/bare-file-link
Oct 12, 2026
Merged

seflue merged 1 commit into
nvim-orgmode:masterfrom
seflue:fix/bare-file-link

Conversation

@seflue

@seflue seflue commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Relative file: links written the way the Org manual writes them resolve against the wrong directory. Currently [[file:foo.org]] opens foo.org relative to Neovim's working directory instead of the org file's directory. But the Org manual treats file:papers/last.pdf and ./papers/last.pdf as the same link.

get_file_path passes a bare path on unchanged, so Vim resolves it against the working directory. That is right for links without file:, where a bare word is a headline search, but file: links go through the same code.

Bare file: paths now get a ./ prefix before they resolve, as :tangle paths already do.

A file: link without a ./ prefix, like the ones Emacs writes, opened
relative to the working directory instead of the directory of the org
file. Org mode treats such a path as relative to the file that holds
the link.

Bare paths after file: now resolve like ./ paths. Links without the
file: prefix are unchanged, since a bare link there is a headline
search. The shared path helper keeps returning nothing for bare paths,
because other callers rely on that.

AI-assisted: Claude Code
@seflue
seflue requested a review from kristijanhusak October 11, 2026 22:23
@seflue
seflue merged commit 150993e into nvim-orgmode:master Oct 12, 2026
14 checks passed
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