Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ use {
["<cr>"] = "open",
["<esc>"] = "revert_preview",
["P"] = { "toggle_preview", config = { use_float = true } },
["l"] = "focus_preview"
["S"] = "open_split",
["s"] = "open_vsplit",
-- ["S"] = "split_with_window_picker",
Expand Down
2 changes: 2 additions & 0 deletions doc/neo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ z = close_all_nodes: Close all nodes in the tree.

P = toggle_preview: Toggles "preview mode", see |neo-tree-preview-mode|

l = focus_preview: Focus the active preview window

<esc> = revert_preview: Ends "preview_mode" if it is enabled, and reverts
any preview windows to what was being shown before
preview mode began.
Expand Down
1 change: 1 addition & 0 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ local config = {
["<cr>"] = "open",
["<esc>"] = "revert_preview",
["P"] = { "toggle_preview", config = { use_float = true } },
["l"] = "focus_preview",
["S"] = "open_split",
-- ["S"] = "split_with_window_picker",
["s"] = "open_vsplit",
Expand Down
4 changes: 4 additions & 0 deletions lua/neo-tree/sources/common/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ M.toggle_preview = function(state)
Preview.toggle(state)
end

M.focus_preview = function()
Preview.focus()
end

---Open file or directory
---@param state table The state of the source
---@param open_cmd string The vim command to use to open the file
Expand Down
8 changes: 7 additions & 1 deletion lua/neo-tree/sources/common/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ Preview.toggle = function(state)
local preview_event = {
event = events.VIM_CURSOR_MOVED,
handler = function()
if not toggle_state then
if not toggle_state or vim.api.nvim_get_current_win() == instance.winid then
return
end
if vim.api.nvim_get_current_win() == winid then
Expand All @@ -410,4 +410,10 @@ Preview.toggle = function(state)
end
end

Preview.focus = function()
if Preview.is_active() then
vim.fn.win_gotoid(instance.winid)
end
end

return Preview