Skip to content

Commit

Permalink
fix: windows symlink (#64)
Browse files Browse the repository at this point in the history
* fix: normalize path on Windows

* fix: windows symlink

* doc: sponsor
  • Loading branch information
linrongbin16 committed Jul 21, 2023
1 parent 0a0f29d commit bc1c680
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: linrongbin16
# patreon: # Replace with a single Patreon username
# open_collective: # Replace with a single Open Collective username
# ko_fi: # Replace with a single Ko-fi username
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,6 @@ Please also open [issue](https://github.com/linrongbin16/lin.nvim/issues)/[PR](h

Like gitlinker.nvim? Consider

[![buymeacoffee](https://img.shields.io/badge/-Buy%20Me%20a%20Coffee-ff5f5f?logo=ko-fi&logoColor=white)](https://www.buymeacoffee.com/linrongbin16)
[![Github Sponsor](https://img.shields.io/badge/-Sponsor%20Me%20on%20Github-magenta?logo=github&logoColor=white)](https://github.com/sponsors/linrongbin16)
[![Wechat Pay](https://img.shields.io/badge/-Tip%20Me%20on%20WeChat-brightgreen?logo=wechat&logoColor=white)](https://linrongbin16.github.io/sponsor)
[![Alipay](https://img.shields.io/badge/-Tip%20Me%20on%20Alipay-blue?logo=alipay&logoColor=white)](https://linrongbin16.github.io/sponsor)
11 changes: 11 additions & 0 deletions lua/gitlinker/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ local function relative_path(cwd)
if cwd == nil or string.len(cwd) <= 0 then
cwd = vim.fn.getcwd()
end
-- get real path from possibly symlink
cwd = vim.fn.resolve(cwd)
-- normalize path slash from '\\' to '/'
if cwd:find("\\") then
cwd = cwd:gsub("\\\\", "/")
cwd = cwd:gsub("\\", "/")
end
if buf_path:find("\\") then
buf_path = buf_path:gsub("\\\\", "/")
buf_path = buf_path:gsub("\\", "/")
end
logger.debug(
"|util.relative_path| buf_path(%s):%s, cwd(%s):%s",
vim.inspect(type(buf_path)),
Expand Down

0 comments on commit bc1c680

Please sign in to comment.