Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add node.open.vertical_no_picker, node.open.horizontal_no_picker #3031

Merged
merged 5 commits into from
Dec 21, 2024
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
12 changes: 12 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2025,9 +2025,19 @@ node.open.no_window_picker({node})
node.open.vertical({node}) *nvim-tree-api.node.open.vertical()*
|nvim-tree-api.node.edit()|, file will be opened in a new vertical split.

*nvim-tree-api.node.open.vertical_no_picker()*
node.open.vertical_no_picker({node})
|nvim-tree-api.node.vertical()|, window picker will never be used as per
|nvim-tree.actions.open_file.window_picker.enable| `false`

node.open.horizontal({node}) *nvim-tree-api.node.open.horizontal()*
|nvim-tree-api.node.edit()|, file will be opened in a new horizontal split.

*nvim-tree-api.node.open.horizontal_no_picker()*
node.open.horizontal_no_picker({node})
|nvim-tree-api.node.horizontal()|, window picker will never be used as per
|nvim-tree.actions.open_file.window_picker.enable| `false`

*nvim-tree-api.node.open.toggle_group_empty()*
node.open.toggle_group_empty({node})
Toggle |nvim-tree.renderer.group_empty| for a specific folder.
Expand Down Expand Up @@ -3189,6 +3199,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree-api.node.open.drop()|
|nvim-tree-api.node.open.edit()|
|nvim-tree-api.node.open.horizontal()|
|nvim-tree-api.node.open.horizontal_no_picker()|
|nvim-tree-api.node.open.no_window_picker()|
|nvim-tree-api.node.open.preview()|
|nvim-tree-api.node.open.preview_no_picker()|
Expand All @@ -3197,6 +3208,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree-api.node.open.tab_drop()|
|nvim-tree-api.node.open.toggle_group_empty()|
|nvim-tree-api.node.open.vertical()|
|nvim-tree-api.node.open.vertical_no_picker()|
|nvim-tree-api.node.run.cmd()|
|nvim-tree-api.node.run.system()|
|nvim-tree-api.node.show_info_popup()|
Expand Down
8 changes: 6 additions & 2 deletions lua/nvim-tree/actions/node/open-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ end

local function get_target_winid(mode)
local target_winid
if not M.window_picker.enable or mode == "edit_no_picker" or mode == "preview_no_picker" then
if not M.window_picker.enable or string.find(mode, "no_picker") then
target_winid = lib.target_winid

-- first available window
if not vim.tbl_contains(vim.api.nvim_tabpage_list_wins(0), target_winid) then
target_winid = first_win_id()
Expand Down Expand Up @@ -280,6 +279,11 @@ local function open_in_new_window(filename, mode)
return
end

local position = string.find(mode, "no_picker")
if position then
mode = string.sub(mode, 0, position - 2)
end

-- non-floating, non-nvim-tree windows
local win_ids = vim.tbl_filter(function(id)
local config = vim.api.nvim_win_get_config(id)
Expand Down
2 changes: 2 additions & 0 deletions lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ Api.node.open.tab_drop = wrap_node(open_or_expand_or_dir_up("tab_drop"))
Api.node.open.replace_tree_buffer = wrap_node(open_or_expand_or_dir_up("edit_in_place"))
Api.node.open.no_window_picker = wrap_node(open_or_expand_or_dir_up("edit_no_picker"))
Api.node.open.vertical = wrap_node(open_or_expand_or_dir_up("vsplit"))
Api.node.open.vertical_no_picker = wrap_node(open_or_expand_or_dir_up("vsplit_no_picker"))
Api.node.open.horizontal = wrap_node(open_or_expand_or_dir_up("split"))
Api.node.open.horizontal_no_picker = wrap_node(open_or_expand_or_dir_up("split_no_picker"))
Api.node.open.tab = wrap_node(open_or_expand_or_dir_up("tabnew"))
Api.node.open.toggle_group_empty = wrap_node(open_or_expand_or_dir_up("toggle_group_empty", true))
Api.node.open.preview = wrap_node(open_or_expand_or_dir_up("preview"))
Expand Down
Loading