mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-24 13:31:06 +00:00
Enhance bufpath for terminal paths and Windows support
Refactor bufpath function to handle terminal window paths and fix duplicated driver letters on Windows.
This commit is contained in:
parent
3f2c1c41e6
commit
f054a0240c
1 changed files with 7 additions and 3 deletions
|
|
@ -67,9 +67,13 @@ function M.detectors.pattern(buf, patterns)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.bufpath(buf)
|
function M.bufpath(buf)
|
||||||
local path = LazyVim.norm(vim.api.nvim_buf_get_name(assert(buf)))
|
local name = LazyVim.norm(vim.api.nvim_buf_get_name(assert(buf)))
|
||||||
-- Use pattern to extract path for terminal windows
|
local path = name and name:match("^term:/(.+/%d+):") or name
|
||||||
return M.realpath(path and path:match("^term:/([^:]+)") or path)
|
-- fix duplicated driver letters for Windows
|
||||||
|
if vim.fn.has("win32") == 1 and path and path:find(":/.*:/") then
|
||||||
|
path = path:gsub("^.-%:/", "", 1)
|
||||||
|
end
|
||||||
|
return LazyVim.root.realpath(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.cwd()
|
function M.cwd()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue