* refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class * refactor(#2826): View is an Explorer member * refactor(#2826): move autocmds to Explorer * refactor(#2826): API uses Explorer's View * refactor(#2826): move View into Explorer package * refactor(#2826): retain necessary view globals * refactor(#2826): move all winhl to appearance constants * refactor(#2826): add lifecycle logging to all Explorer members * refactor(#2826): fix bad cherry-pick * refactor(#2826): better enumerate_options function * refactor(#2826): add View.tab_line for debugging * refactor(#2826): default lifecycle log off * refactor(#2826): add experimental.multi_instance_debug, split globals out of view, move diagnostics to its own module * refactor(#2826): instrument View:get_winnr * refactor(#2826): instrument View:setup_tabpage * refactor(#2826): instrument View:set_current_win, View:prevent_buffer_override * refactor(#2826): instrument View:get_bufnr * refactor(#2826): track member bufnr -> winid with global * refactor(#2826): tidy experiment names and logs * vim: nvim-tree: track bufnr via buffer-update channel * vim: nvim-tree: more logging * vim: nvim-tree: revert: track bufnr via buffer-update channel * refactor(#2826): notify error on view winid and bufnr mismatches * refactor(#2826): notify error on view winid and bufnr mismatches * refactor(#2826): explorer init logging
This commit is contained in:
committed by
GitHub
parent
d54a1875a9
commit
0a06f65bf0
@@ -143,10 +143,16 @@ function M.find_node(nodes, fn)
|
||||
return node.group_next and { node.group_next } or (node.open and #node.nodes > 0 and node.nodes)
|
||||
end)
|
||||
:iterate()
|
||||
i = require("nvim-tree.view").is_root_folder_visible() and i or i - 1
|
||||
if node and node.explorer.live_filter.filter then
|
||||
i = i + 1
|
||||
|
||||
if node then
|
||||
if not node.explorer.view:is_root_folder_visible() then
|
||||
i = i - 1
|
||||
end
|
||||
if node.explorer.live_filter.filter then
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
return node, i
|
||||
end
|
||||
|
||||
@@ -537,7 +543,10 @@ function M.focus_file(path)
|
||||
local _, i = M.find_node(require("nvim-tree.core").get_explorer().nodes, function(node)
|
||||
return node.absolute_path == path
|
||||
end)
|
||||
require("nvim-tree.view").set_cursor({ i + 1, 1 })
|
||||
local explorer = require("nvim-tree.core").get_explorer()
|
||||
if explorer then
|
||||
explorer.view:set_cursor({ i + 1, 1 })
|
||||
end
|
||||
end
|
||||
|
||||
---Focus node passed as parameter if visible, otherwise focus first visible parent.
|
||||
@@ -557,7 +566,7 @@ function M.focus_node_or_parent(node)
|
||||
end)
|
||||
|
||||
if found_node or node.parent == nil then
|
||||
require("nvim-tree.view").set_cursor({ i + 1, 1 })
|
||||
explorer.view:set_cursor({ i + 1, 1 })
|
||||
break
|
||||
end
|
||||
|
||||
@@ -652,32 +661,29 @@ function M.is_executable(absolute_path)
|
||||
end
|
||||
end
|
||||
|
||||
---List of all option info/values
|
||||
---@param opts vim.api.keyset.option passed directly to vim.api.nvim_get_option_info2 and vim.api.nvim_get_option_value
|
||||
---@param was_set boolean filter was_set
|
||||
---@return { info: vim.api.keyset.get_option_info, val: any }[]
|
||||
function M.enumerate_options(opts, was_set)
|
||||
local res = {}
|
||||
---@class UtilEnumerateOptionsOpts
|
||||
---@field keyset_opts vim.api.keyset.option
|
||||
---@field was_set boolean? as per vim.api.keyset.get_option_info
|
||||
|
||||
local infos = vim.tbl_filter(function(info)
|
||||
if opts.buf and info.scope ~= "buf" then
|
||||
return false
|
||||
elseif opts.win and info.scope ~= "win" then
|
||||
return false
|
||||
---Option name/values
|
||||
---@param opts UtilEnumerateOptionsOpts
|
||||
---@return table<string, any>
|
||||
function M.enumerate_options(opts)
|
||||
-- enumerate all options, limiting buf and win scopes
|
||||
return vim.tbl_map(function(info)
|
||||
if opts.keyset_opts.buf and info.scope ~= "buf" then
|
||||
return nil
|
||||
elseif opts.keyset_opts.win and info.scope ~= "win" then
|
||||
return nil
|
||||
else
|
||||
return true
|
||||
-- optional, lazy was_set check
|
||||
if not opts.was_set or vim.api.nvim_get_option_info2(info.name, opts.keyset_opts).was_set then
|
||||
return vim.api.nvim_get_option_value(info.name, opts.keyset_opts)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end, vim.api.nvim_get_all_options_info())
|
||||
|
||||
for _, info in vim.spairs(infos) do
|
||||
local _, info2 = pcall(vim.api.nvim_get_option_info2, info.name, opts)
|
||||
if not was_set or info2.was_set then
|
||||
local val = pcall(vim.api.nvim_get_option_value, info.name, opts)
|
||||
table.insert(res, { info = info2, val = val })
|
||||
end
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user