mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-22 12:31:07 +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
|
||||
|
||||
function M.bufpath(buf)
|
||||
local path = LazyVim.norm(vim.api.nvim_buf_get_name(assert(buf)))
|
||||
-- Use pattern to extract path for terminal windows
|
||||
return M.realpath(path and path:match("^term:/([^:]+)") or path)
|
||||
local name = LazyVim.norm(vim.api.nvim_buf_get_name(assert(buf)))
|
||||
local path = name and name:match("^term:/(.+/%d+):") or name
|
||||
-- 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
|
||||
|
||||
function M.cwd()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue