A purr-fectly simple way to visualize LSP hierarchies in Neovim.
meow.yarn.nvim - Untangle Your Code's Relationships
Ever feel like you're unraveling a tangled ball of yarn when navigating your codebase? meow.yarn.nvim is here to help. It provides a simple, beautiful, and interactive way to explore LSP hierarchies without the usual clutter. Forget getting lost in endless definitions and references; meow.yarn.nvim visualizes type and call hierarchies in a clean, intuitive tree view.
<BS> steps back and puts the cursor exactly where you drilled in<Space> and send them all at once to the quickfix list — or to trouble.nvim when it is installed/, cycle sort order with s, expand/collapse everything with zO / zC:MeowYarn last brings back the previous hierarchy exactly as it was| Requirement | Details |
|---|---|
| Neovim | ≥ 0.8.0 |
| LSP Client | An active LSP server that supports typeHierarchyProvider or callHierarchyProvider. |
| Dependencies | nui.nvim |
| Optional | Details |
|---|---|
| trouble.nvim | Used instead of the built-in quickfix window when installed. |
Install meow.yarn.nvim using your favorite plugin manager.
{
"retran/meow.yarn.nvim",
dependencies = { "MunifTanjim/nui.nvim" },
config = function()
require("meow.yarn").setup({
-- Your custom configuration goes here
})
end,
}
use {
"retran/meow.yarn.nvim",
requires = { "MunifTanjim/nui.nvim" },
config = function()
require("meow.yarn").setup({})
end,
}
:Rocks install meow.yarn.nvim
The dependency (nui.nvim) will be automatically installed and managed. Then add to your Neovim configuration:
require("meow.yarn").setup({
-- Your custom configuration goes here
})
The plugin provides the :MeowYarn command to open hierarchy views.
:MeowYarn type super:MeowYarn type sub:MeowYarn call callers:MeowYarn call callees:MeowYarn lastYou can customize the plugin by passing a configuration table to the setup function. Here are the defaults:
require("meow.yarn").setup({
window = {
width = 0.8,
height = 0.85,
border = "rounded",
preview_height_ratio = 0.35,
-- "vertical": tree above, preview below (default); "horizontal": tree left, preview right
layout = "vertical",
},
icons = {
loading = "",
placeholder = "",
selected = "●",
animation_frames = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" },
},
mappings = {
jump = "<CR>",
toggle = "<Tab>",
expand = "l",
expand_alt = "<Right>",
collapse = "h",
collapse_alt = "<Left>",
show_super_hierarchy = "K",
show_sub_hierarchy = "J",
quit = "q",
breadcrumb_back = "<BS>",
yank_path = "y",
expand_all = "zO",
collapse_all = "zC",
filter = "/",
preview_scroll_down = "<C-d>",
preview_scroll_up = "<C-u>",
sort = "s",
toggle_select = "<Space>",
clear_selection = "<Esc>",
send_to_quickfix = "<C-q>",
},
quickfix = {
-- Open trouble.nvim (when installed) instead of the built-in quickfix window.
use_trouble = true,
},
-- Stay in the hierarchy window after jumping to a symbol.
keep_open_on_jump = false,
expand_depth = 3,
preview_context_lines = 10,
animation_speed = 100,
hierarchies = {
type_hierarchy = {
icons = {
class = "",
struct = "",
interface = "",
default = "",
},
},
call_hierarchy = {
icons = {
method = "",
func = "",
variable = "",
default = "",
},
},
},
-- Optional: fully control how each node is rendered, see `:help meow-yarn-render-node`.
-- render_node = function(node_info)
-- return string.format("%s %s", node_info.icon, node_info.name)
-- end,
})
You can map the commands for easier access.
-- Using lua functions
vim.keymap.set("n", "<leader>yt", function() require("meow.yarn").open_tree("type_hierarchy", "supertypes") end, { desc = "Yarn: Type Hierarchy (Super)" })
vim.keymap.set("n", "<leader>yT", function() require("meow.yarn").open_tree("type_hierarchy", "subtypes") end, { desc = "Yarn: Type Hierarchy (Sub)" })
vim.keymap.set("n", "<leader>yc", function() require("meow.yarn").open_tree("call_hierarchy", "callers") end, { desc = "Yarn: Call Hierarchy (Callers)" })
vim.keymap.set("n", "<leader>yC", function() require("meow.yarn").open_tree("call_hierarchy", "callees") end, { desc = "Yarn: Call Hierarchy (Callees)" })
vim.keymap.set("n", "<leader>yl", "<Plug>(MeowYarnLast)", { desc = "Yarn: Re-open last hierarchy" })
-- Or using commands
vim.keymap.set("n", "<leader>yS", "<Cmd>MeowYarn type super<CR>", { desc = "Yarn: Super Types" })
vim.keymap.set("n", "<leader>ys", "<Cmd>MeowYarn type sub<CR>", { desc = "Yarn: Sub Types" })
vim.keymap.set("n", "<leader>yC", "<Cmd>MeowYarn call callers<CR>", { desc = "Yarn: Callers" })
vim.keymap.set("n", "<leader>yc", "<Cmd>MeowYarn call callees<CR>", { desc = "Yarn: Callees" })
Inside the hierarchy view, the following default keymappings are available:
| Key | Action |
|---|---|
<CR> |
Jump to the selected item, or open the whole selection (mappings.jump) |
<Tab> |
Toggle expand/collapse for the selected node (mappings.toggle) |
l or <Right> |
Expand the selected node (mappings.expand, mappings.expand_alt) |
h or <Left> |
Collapse the selected node (mappings.collapse, mappings.collapse_alt) |
zO / zC |
Expand / collapse all nodes (mappings.expand_all, mappings.collapse_all) |
<Space> |
Toggle multi-selection for the node (mappings.toggle_select) |
<C-q> |
Send the selection to quickfix / trouble.nvim (mappings.send_to_quickfix) |
<Esc> |
Clear the multi-selection (mappings.clear_selection) |
/ |
Filter nodes by name (mappings.filter) |
s |
Cycle sort order: lsp → alpha → file (mappings.sort) |
y |
Yank file:line of the selected node to the clipboard (mappings.yank_path) |
<C-d> / <C-u> |
Scroll the preview pane (mappings.preview_scroll_down, ..._up) |
K / J |
Open new hierarchy from selected item (K=super/callers, J=sub/callees) |
<BS> |
Step back in the breadcrumb history (mappings.breadcrumb_back) |
q |
Quit the hierarchy view (mappings.quit) |
Press <Space> to mark nodes (the cursor moves down, so repeated presses select consecutive items), then <C-q> — or simply <CR> — to send them all to the quickfix list at once. With nothing selected, the node under the cursor is used. When trouble.nvim is installed it is opened instead of the built-in quickfix window; set quickfix.use_trouble = false to always use :copen.
See :help meow-yarn-selection for details.
Contributions are welcome! Feel free to open an issue or submit a pull request.
Licensed under the MIT License. See LICENSE for details.
meow.yarn.nvim would not be possible without these amazing projects:
Special thanks to everyone who helped shape this plugin:
meow.yarn.nvim is developed by Andrew Vasilyev with help from GitHub Copilot and feline assistants Sonya Blade, Mila, and Marcus Fenix.
Happy coding with project meow! 🐱
Made with ❤️ by Andrew Vasilyev and feline assistants Sonya Blade, Mila, and Marcus Fenix.