Skip to content

Commit 3b14c77

Browse files
committed
follow files through symlinks
1 parent fba6d1f commit 3b14c77

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lua/neo-tree/sources/manager.lua

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ M.get_state_for_window = function(winid)
230230
end
231231
end
232232

233+
---Gets the path to reveal.
234+
---@param include_terminals boolean?
235+
---@return string? bufname_path The non-canonical path (keeps the symlinks in the path without resolving them)
236+
---@return string? realpath The real path of the item to reveal
233237
M.get_path_to_reveal = function(include_terminals)
234238
local win_id = vim.api.nvim_get_current_win()
235239
local cfg = vim.api.nvim_win_get_config(win_id)
@@ -240,14 +244,22 @@ M.get_path_to_reveal = function(include_terminals)
240244
if vim.bo.filetype == "neo-tree" then
241245
return nil
242246
end
243-
local path = vim.fn.expand("%:p")
244-
if not utils.truthy(path) then
247+
248+
local realpath = vim.fn.expand("%:p")
249+
if not utils.truthy(realpath) then
245250
return nil
246251
end
247-
if not include_terminals and path:match("term://") then
252+
if not include_terminals and realpath:match("term://") then
248253
return nil
249254
end
250-
return path
255+
256+
local relative_bufname = vim.fn.fnamemodify(vim.fn.expand("%"), ":.")
257+
local bufname_path = vim.fs.normalize(utils.path_join(vim.fn.getcwd(win_id), relative_bufname))
258+
if utils.is_windows then
259+
bufname_path = utils.windowize_path(bufname_path)
260+
end
261+
262+
return bufname_path, realpath
251263
end
252264

253265
---@param source_name string

0 commit comments

Comments
 (0)