diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..e2612ae6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = off diff --git a/README.md b/README.md index 9298e1f5..bec2c23e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Plug 'sindrets/diffview.nvim' ```lua -- Packer -use "sindrets/diffview.nvim" +use "sindrets/diffview.nvim" ``` ## Merge Tool diff --git a/lua/diffview/debounce.lua b/lua/diffview/debounce.lua index 74fc51f5..29535e1c 100644 --- a/lua/diffview/debounce.lua +++ b/lua/diffview/debounce.lua @@ -243,4 +243,3 @@ function M.set_timeout(func, delay) end return M - diff --git a/lua/diffview/vcs/adapters/git/init.lua b/lua/diffview/vcs/adapters/git/init.lua index 3a137bc9..84aa0afe 100644 --- a/lua/diffview/vcs/adapters/git/init.lua +++ b/lua/diffview/vcs/adapters/git/init.lua @@ -25,6 +25,24 @@ local logger = DiffviewGlobal.logger local pl = lazy.access(utils, "path") ---@type PathLib local uv = vim.loop +local has_cygpath +local function normalize_cygwin_path(path) + if path and vim.fn.has('win32') == 1 and string.sub(path, 1, 1) == '/' then + if has_cygpath == nil then + has_cygpath = vim.fn.executable('cygpath') == 1 + end + + if has_cygpath then + path = vim.fn.system({"cygpath", "--absolute", "--windows", path}) + + -- remove "\n" + path = string.sub(path, 1, #path -1) + end + end + + return path +end + local M = {} ---@class GitAdapter : VCSAdapter @@ -177,7 +195,8 @@ local function get_toplevel(path) if code ~= 0 then return nil end - return out[1] and vim.trim(out[1]) + + return normalize_cygwin_path(out[1]) end ---Try to find the top-level of a working tree by using the given indicative @@ -279,7 +298,8 @@ function GitAdapter:get_dir(path) if code ~= 0 then return nil end - return out[1] and vim.trim(out[1]) + + return normalize_cygwin_path(out[1]) end ---Verify that a given git rev is valid.