From bc1c6801b4771d6768c6ec6727d0e7669e6aac5f Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Sat, 22 Jul 2023 06:14:14 +0800 Subject: [PATCH] fix: windows symlink (#64) * fix: normalize path on Windows * fix: windows symlink * doc: sponsor --- .github/FUNDING.yml | 2 +- README.md | 2 +- lua/gitlinker/util.lua | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index b2bfcd7..e9c30d4 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -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 diff --git a/README.md b/README.md index 07d5109..54e2887 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lua/gitlinker/util.lua b/lua/gitlinker/util.lua index 4b0e43d..1c96ea2 100644 --- a/lua/gitlinker/util.lua +++ b/lua/gitlinker/util.lua @@ -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)),