Skip to content

Hyperlinks: Relative path to files in parent directories do not work #583

@seflue

Description

@seflue

Describe the bug

Assuming the following file tree

.
├── dir1
│   └── file2.org
├── dir2
│   └── file3.org
└── file1.org

If I reference a heading in file2 or file3 from file1, everything works as expected.
If I reference a heading from file2 to file1 or file2 to file3 (analogous from file3), the links break. The lsp autocompletion looks up headings from the file where I am creating the link. Somehow the path resolving breaks in this case.

Actually I am willing to fix it myself, if someone can give me some guidance where to look.

I already started to take a look into the hyperlink code and I have to admit, that I don't find it great. It is hard to graps and seems to be brittle. Adding features have a high risk to break things.

I am working on a refactoring right now and would like to coordinate with people already working on further features (I saw some open PRs). If I am successfull, the code should be much easier to extend in the future.

Steps to reproduce

Create a file tree like this:

├── dir1
│   └── file2.org
├── dir2
│   └── file3.org
└── file1.org
  1. Create a headline in file1.org and file3.org
  2. Try to create links to these headlines from file2 using relative paths.

Expected behavior

Should work like described in the documentation:

  • autocompletion should list headlines from file1 and file3 respectively
  • opening the link should jump to file1 and file3 respectively

Emacs functionality

No response

Minimal init.lua

I'm pretty sure, my lua configuration is not the issue here - should be reproducible with any setup.

Screenshots and recordings

No response

OS / Distro

openSUSE Tumbleweed

Neovim version/commit

0.9.1

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions