Windows: path separator issues
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start with lua/plenary/path.lua, especially Path:new, and reproduce the Windows behavior from Telescope's git_files, git status, and path_display usage. Review issues #646, #254, and #393 plus PRs #591, #618, and #654 before choosing an approach. Done means paths from git and other utilities behave correctly on Windows while preserving a way to represent Unix-style paths when needed.
Written by the indexing model from the issue text.
Description
There are currently multiple open issues for this:
#646 , #254 , #393
And even some open PRs:
#591 , #618, #654
My issue comes from Telescope git_files and git status functions and path_display setting which is not working correctly.
Since git (and there may be other unix/linux utilities which do the same) ignores OS specific path separator and always uses '/'
path processing becomes i bit of a nightmare.
I'd like to propose that Path utils always normalize path separator in constructor to the path separator valid for current OS.
There might be problems with this approach where someone might expect unix like path even on windows ...
For those scenarios maybe a helper function would be appropriate which would return unix style path
Anyways, here is my dirty fix that solves MY issue with git in telescope
diff --git a/lua/plenary/path.lua b/lua/plenary/path.lua
index 0865f2e..b93e79e 100644
--- a/lua/plenary/path.lua
+++ b/lua/plenary/path.lua
@@ -261,6 +261,11 @@ function Path:new(...)
path_string = table.concat(path_objs, sep)
else
assert(type(path_input) == "string", vim.inspect(path_input))
+ if path.sep == "\\" then
+ -- quickfix: on windows some utilities, e.g. git, return paths with '/' instead of '\'
+ -- so we will replace it here so that the rest of path processing works as expected
+ path_input = string.gsub(path_input, "/", "\\")
+ end
path_string = path_input
end
- Dominant language
- Lua
- Stars
- 3.5k
- Forks
- 340
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nvim-lua/plenary.nvim
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
nvim-lua/plenary.nvim#682 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
nvim-lua/plenary.nvim#680 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
nvim-lua/plenary.nvim#675 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
nvim-lua/plenary.nvim#672 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
nvim-lua/plenary.nvim#671 · 1 comment ·
All issues in nvim-lua/plenary.nvim
Similar issues
-
ai-authored
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Data Correction Forever Needs testing/reproduction
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Questie/Questie#7941 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
remote remote-plugin
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day