Skip to content

fix(nvim): resolve Windows absolute markdown link paths - #196

Merged
aguil merged 1 commit into
masterfrom
fix/nvim-markdown-windows-abspath
Nov 23, 2026
Merged

aguil merged 1 commit into
masterfrom
fix/nvim-markdown-windows-abspath

Conversation

@aguil

@aguil aguil commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Why the change

On Windows, markdown links to absolute paths like C:\notes\a.md were joined onto the buffer's folder and never found, so peek, the outline preview and gf failed on them; now they resolve like /-rooted paths do.

Special things to note

  • This is the cause of the one nvim unit test (opens linked markdown files in a floating preview buffer) that failed on Windows and passed in CI: it links to a vim.fn.tempname() path.
  • Linux CI can't exercise the Windows case (isabsolutepath('C:\…') is 0 there), so the existing test on a Windows machine is the coverage. All 39 nvim tests pass locally on Windows.

Change outline

resolve_path in dot_config/nvim/lua/custom/markdown_nav.lua, both absolute checks:

- if not vim.startswith(candidate, '/') then resolved = normalize(joinpath(base_dir, candidate)) end
+ if vim.fn.isabsolutepath(candidate) == 0 then resolved = normalize(joinpath(base_dir, candidate)) end
  ...
- if vim.startswith(fallback, '/') then return fallback end
+ if vim.fn.isabsolutepath(fallback) == 1 then return fallback end

vim.fn.isabsolutepath on Windows (nvim 0.12.6): C:\x\y.md → 1, C:/x/y.md → 1, /x/y.md → 1, docs/a.md → 0.

🤖 Generated with Claude Code

resolve_path treated a link target as absolute only when it started
with '/', so on Windows a target like C:\notes\a.md was joined onto the
buffer's directory and never found. Peek (<leader>gp), the outline
previewer and gf all went through it, and the test 'opens linked
markdown files in a floating preview buffer' failed on Windows (it
links to a vim.fn.tempname() path) while passing on Linux CI.

Use vim.fn.isabsolutepath, which accepts drive-letter and UNC paths on
Windows and keeps '/'-rooted paths absolute on every platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aguil
aguil marked this pull request as ready for review November 23, 2026 03:30
@aguil
aguil merged commit 54f360e into master Nov 23, 2026
1 check passed
@aguil
aguil deleted the fix/nvim-markdown-windows-abspath branch November 23, 2026 03:32
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.

1 participant