Skip to content

feat(#2092): add api.node.navigate.open.next, prev #2093

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

Merged
merged 4 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 20 additions & 4 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1446,10 +1446,26 @@ api.tree.toggle_help() *nvim-tree.api.tree.toggle_help()*
- navigate.sibling.last
- navigate.parent
- navigate.parent_close
- navigate.git.next
- navigate.git.prev
- navigate.diagnostics.next
- navigate.diagnostics.prev

api.node.navigate.git.next() *nvim-tree.api.navigate.git.next()*
Navigate to the next item showing git status.

api.node.navigate.git.prev() *nvim-tree.api.navigate.git.prev()*
Navigate to the previous item showing git status.

*nvim-tree.api.navigate.diagnostics.next()*
api.node.navigate.diagnostics.next()
Navigate to the next item showing diagnostic status.

*nvim-tree.api.navigate.diagnostics.prev()*
api.node.navigate.diagnostics.prev()
Navigate to the next item showing diagnostic status.

api.node.navigate.open.next() *nvim-tree.api.navigate.open.next()*
Copy link
Collaborator

@gegoune gegoune Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if open is a good name here. It sorta points toward action rather than a state, such as diagnostics or git. I don't have a better idea though. opened, buffers or more verbose like opened_buffers, listed_buffers. Not sure.

Copy link
Member Author

@alex-courtis alex-courtis Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listed_buffers

That's factual and exactly what we are testing for. Updated.

Edit: listed_buffers looked a bit odd, used just listed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not right... changed to opened to match highlight_opened_files.

Clarified that both of these actually show bufloaded().

Noted that filters.no_buffer uses buflisted(), however that could be considered a breaking change and may also have side effects RE buffer unloading.

Navigate to the next item with a listed buffer.

api.node.navigate.open.prev() *nvim-tree.api.navigate.open.prev()*
Navigate to the previous item with a listed buffer.

- api.git: *nvim-tree.api.git*
- reload
Expand Down
2 changes: 2 additions & 0 deletions lua/nvim-tree/actions/moves/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function M.fn(where, what)
valid = explorer_node.get_git_status(node) ~= nil
elseif what == "diag" then
valid = node.diag_status ~= nil
elseif what == "open" then
valid = vim.fn.bufloaded(node.absolute_path) ~= 0
end

if not first and valid then
Expand Down
4 changes: 3 additions & 1 deletion lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local notify = require "nvim-tree.notify"

local Api = {
tree = {},
node = { navigate = { sibling = {}, git = {}, diagnostics = {} }, run = {}, open = {} },
node = { navigate = { sibling = {}, git = {}, diagnostics = {}, open = {} }, run = {}, open = {} },
events = {},
marks = { bulk = {}, navigate = {} },
fs = { copy = {} },
Expand Down Expand Up @@ -157,6 +157,8 @@ Api.node.navigate.git.next = inject_node(require("nvim-tree.actions.moves.item")
Api.node.navigate.git.prev = inject_node(require("nvim-tree.actions.moves.item").fn("prev", "git"))
Api.node.navigate.diagnostics.next = inject_node(require("nvim-tree.actions.moves.item").fn("next", "diag"))
Api.node.navigate.diagnostics.prev = inject_node(require("nvim-tree.actions.moves.item").fn("prev", "diag"))
Api.node.navigate.open.next = inject_node(require("nvim-tree.actions.moves.item").fn("next", "open"))
Api.node.navigate.open.prev = inject_node(require("nvim-tree.actions.moves.item").fn("prev", "open"))

Api.git.reload = require("nvim-tree.actions.reloaders.reloaders").reload_git

Expand Down