hierarchy.nvim
replicates the "Call Hierarchy" functionality from VS C*de, showing (recursively) the functions that a given function calls.
With your LSP enabled, hover over a function, use the :FunctionReferences
command, and observe the call hierarchy of that function. Press <Enter>
over an item in the list to expand its list of children, and type gd
over an item to jump to its definition.
Using lazy:
return {
'lafarr/hierarchy.nvim'
}
local opts = {
-- Determines how many levels deep the call hierarchy shows
depth = 3
}
In your init.lua
:
vim.api.nvim_create_autocmd({ 'LspAttach' }, {
group = 'Hierarchy',
desc = 'Set up the :FunctionReferences user command',
callback = function()
local opts = {
-- Your opts here
}
require('hierarchy').setup(opts)
end
})
Now, navigate your cursor over a function and use the :FunctionReferences
command