Skip to content

Flexible and sleek fuzzy picker, LSP symbol navigator, and more. inspired by Zed.

Notifications You must be signed in to change notification settings

bassamsdata/namu.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Namu.nvim

🌿 Jump to symbols in your code with live preview, built-in fuzzy finding, and other modules. Inspired by Zed, it preserves symbol order while guiding you through your codebase. Supports LSP, Treesitter, ctags, and works across buffers and workspaces.

“Namu” means “tree🌳” in Korean—just like how it helps you navigate the structure of your code.

Warning

🚧 Beta Status: This plugin is currently in beta. While it's functional, you may encounter breaking changes as we improve and refine the architecture. Your feedback and contributions are welcome!

main_preview.mp4

🧩 Built-in Modules

Module Description
🏷️ symbols LSP symbols for current buffer
🌐 workspace LSP workspace symbols, interactive, live preview
📂 watchtower Symbols from all open buffers (LSP or Treesitter)
🩺 diagnostics Diagnostics for buffer or workspace, live filter
🔗 call_hierarchy Call hierarchy (in/out/both) for symbol
🏷️ ctags ctags-based symbols (buffer or watchtower)
🪟 ui_select Wrapper for vim.ui.select with enhanced UI

What Makes It Special

  • 🔍 Live Preview: See exactly where you'll land before you jump
  • 🌳 Order Preservation: Maintains symbol order as they appear in your code, even after filtering
  • 🗂️ Hierarchy Preservation: Keeps the parent-child structure of your code symbols intact, so you always see context.
  • 📐 Smart Auto-resize: Window adapts to your content in real-time as you type and filter, no need for a big window with only a couple of items
  • 🚀 Zero Dependencies: Works with any LSP-supported language out of the box
  • 🎯 Context Aware: Always shows your current location in the codebase
  • Powerful Filtering:
    • Live filtering through /xx such as /fn for fcuntions or /bf: for buffer names if watchtower module.
    • Built-in fuzzy finding that understands code structure
    • Filter by symbol types (functions, classes, methods)
    • Use regex patterns (e.g., ^__ to filter out Python's __init__ methods)
  • 🎨 Quality of Life:
    • Auto-select when only one match remains
    • Remembers cursor position when you cancel
    • Customizable window style and behavior
  • ✂️ Multi-Action Workflow: Perform multiple operations while Namu is open (or close it after, you choose!):
    • Delete, yank, and add to CodeCompanion chat (more plugins coming soon)
    • Works with both single and multiple selected symbols
  • 🌑 Initially Hidden Mode: Start with an empty list and populate it dynamically as you type, just like the command palette in Zed and VS Code

Table of Contents

⚡ Requirements

  • LSP server for your language (Treesitter fallback for some modules)
  • Treesitter (for live preview)
  • ctags (for ctags module, optional)

Installation

Lazy.nvim

Using lazy.nvim:

{
  "bassamsdata/namu.nvim",
  config = function()
    require("namu").setup({
      -- Enable the modules you want
      namu_symbols = {
        enable = true,
        options = {}, -- here you can configure namu
      },
      -- Optional: Enable other modules if needed
      ui_select = { enable = false }, -- vim.ui.select() wrapper
    })
    -- === Suggested Keymaps: ===
    vim.keymap.set("n", "<leader>ss",":Namu symbols<cr>" , {
      desc = "Jump to LSP symbol",
      silent = true,
    })
    vim.keymap.set("n", "<leader>sw", ":Namu workspace<cr>", {
      desc = "LSP Symbols - Workspace",
      silent = true,
    })
  end,
}
📦 Paq.nvim
require "paq" {
  "bassamsdata/namu.nvim"
}
📦 Mini.deps
require("mini.deps").add("bassamsdata/namu.nvim")

Features

  • Live kind filtering for all symbol modules (/fn, /me, etc.) and then start type like /fnmain to filter more see demo
  • Filter by buffer name in watchtower: /bf:buffer_name see demo
  • Combine filters: /bf:name:fn (buffer and function) see demo
  • Diagnostics filtering: /er (errors), /wa (warnings), /hi (hints), /in (info) see demo
  • Two display styles: tree_guides or indent [see pictures](## Display Styles)
  • Configurable prefix icon for current item
  • All operations are asynchronous (non-blocking)
  • No dependencies except Neovim, LSP, and optional ctags
  • Hierarchy Preservation: Keeps the parent-child structure of your code symbols intact, so you always see context.

Keymaps

Show keymaps
Key Action
<CR> Select item
<Esc> Close picker
<C-n> Next item
<C-p> Previous item
<Tab> Toggle multiselect
<C-a> Select all
<C-l> Clear all
<C-y> Yank symbol(s)
<C-d> Delete symbol(s)
<C-v> Open symbol in vertical split
<C-h> Open symbol in horizontal split
<C-o> Add symbol(s) to CodeCompanion chat

Change Keymaps:

change the default keymaps:
-- in namu_symbols.options
  movement = {
    next = { "<C-n>", "<DOWN>" }, -- Support multiple keys
    previous = { "<C-p>", "<UP>" }, -- Support multiple keys
    close = { "<ESC>" }, -- close mapping
    select = { "<CR>" }, -- select mapping
    delete_word = {}, -- delete word mapping
    clear_line = {}, -- clear line mapping
  },
  multiselect = {
    enabled = false,
    indicator = "", -- or "✓"◉
    keymaps = {
      toggle = "<Tab>",
      select_all = "<C-a>",
      clear_all = "<C-l>",
      untoggle = "<S-Tab>",
    },
    max_items = nil, -- No limit by default
  },
  custom_keymaps = {
    yank = {
      keys = { "<C-y>" }, -- yank symbol text
    },
    delete = {
      keys = { "<C-d>" }, -- delete symbol text
    },
    vertical_split = {
      keys = { "<C-v>" }, -- open in vertical split
    },
    horizontal_split = {
      keys = { "<C-h>" }, -- open in horizontal split
    },
    codecompanion = {
      keys = "<C-o>", -- Add symbols to CodeCompanion
    },
    avante = {
      keys = "<C-t>", -- Add symbol to Avante
    },
  },

Commands

Command Arguments Description
:Namu symbols function, class, method… Show buffer symbols, filter by kind
:Namu workspace Search workspace symbols
:Namu watchtower Symbols from all open buffers, it fallbacks to treesitter
:Namu diagnostics workspace Diagnostics for buffer or workspace
:Namu call in/out/both in/out/both Call hierarchy for symbol
:Namu ctags [watchtower] watchtower ctags symbols (buffer or watchtower)
:Namu help [topic] symbols/analysis Show help

Make It Yours

You can check the configuration documentation for details on each option.

Here's the full setup with defaults:
{ -- Those are the default options
  "bassamsdata/namu.nvim",
  config = function()
    require("namu").setup({
      -- Enable symbols navigator which is the default
      namu_symbols = {
        enable = true,
        ---@type NamuConfig
        options = {
          AllowKinds = {
            default = {
              "Function",
              "Method",
              "Class",
              "Module",
              "Property",
              "Variable",
              -- "Constant",
              -- "Enum",
              -- "Interface",
              -- "Field",
              -- "Struct",
            },
            go = {
              "Function",
              "Method",
              "Struct", -- For struct definitions
              "Field", -- For struct fields
              "Interface",
              "Constant",
              -- "Variable",
              "Property",
              -- "TypeParameter", -- For type parameters if using generics
            },
            lua = { "Function", "Method", "Table", "Module" },
            python = { "Function", "Class", "Method" },
            -- Filetype specific
            yaml = { "Object", "Array" },
            json = { "Module" },
            toml = { "Object" },
            markdown = { "String" },
          },
          BlockList = {
            default = {},
            -- Filetype-specific
            lua = {
              "^vim%.", -- anonymous functions passed to nvim api
              "%.%.%. :", -- vim.iter functions
              ":gsub", -- lua string.gsub
              "^callback$", -- nvim autocmds
              "^filter$",
              "^map$", -- nvim keymaps
            },
            -- another example:
            -- python = { "^__" }, -- ignore __init__ functions
          },
          display = {
            mode = "icon", -- "icon" or "raw"
            padding = 2,
          },
          -- This is a preset that let's set window without really get into the hassle of tuning window options
          -- top10 meaning top 10% of the window
          row_position = "top10", -- options: "center"|"top10"|"top10_right"|"center_right"|"bottom",
          preview = {
            highlight_on_move = true, -- Whether to highlight symbols as you move through them
            -- still needs implmenting, keep it always now
            highlight_mode = "always", -- "always" | "select" (only highlight when selecting)
          },
          window = {
            auto_size = true,
            min_height = 1,
            min_width = 20,
            max_width = 120,
            max_height = 30,
            padding = 2,
            border = "rounded",
            title_pos = "left",
            show_footer = true,
            footer_pos = "right",
            relative = "editor",
            style = "minimal",
            width_ratio = 0.6,
            height_ratio = 0.6,
            title_prefix = "󱠦 ",
          },
          debug = false,
          focus_current_symbol = true,
          auto_select = false,
          initially_hidden = false,
          multiselect = {
            enabled = true,
            indicator = "", -- or "✓"●
            keymaps = {
              toggle = "<Tab>",
              untoggle = "<S-Tab>",
              select_all = "<C-a>",
              clear_all = "<C-l>",
            },
            max_items = nil, -- No limit by default
          },
          actions = {
            close_on_yank = false, -- Whether to close picker after yanking
            close_on_delete = true, -- Whether to close picker after deleting
          },
          movement = {-- Support multiple keys
            next = { "<C-n>", "<DOWN>" },
            previous = { "<C-p>", "<UP>" },
            close = { "<ESC>" }, -- "<C-c>" can be added as well
            select = { "<CR>" },
            delete_word = {}, -- it can assign "<C-w>"
            clear_line = {}, -- it can be "<C-u>"
          },
          custom_keymaps = {
            yank = {
              keys = { "<C-y>" },
              desc = "Yank symbol text",
            },
            delete = {
              keys = { "<C-d>" },
              desc = "Delete symbol text",
            },
            vertical_split = {
              keys = { "<C-v>" },
              desc = "Open in vertical split",
            },
            horizontal_split = {
              keys = { "<C-h>" },
              desc = "Open in horizontal split",
            },
            codecompanion = {
              keys = "<C-o>",
              desc = "Add symbol to CodeCompanion",
            },
            avante = {
              keys = "<C-t>",
              desc = "Add symbol to Avante",
            },
          },
          icon = "󱠦", -- 󱠦 -  -  -- 󰚟
          kindText = {
            Function = "function",
            Class = "class",
            Module = "module",
            Constructor = "constructor",
            Interface = "interface",
            Property = "property",
            Field = "field",
            Enum = "enum",
            Constant = "constant",
            Variable = "variable",
          },
          kindIcons = {
            File = "󰈙",
            Module = "󰏗",
            Namespace = "󰌗",
            Package = "󰏖",
            Class = "󰌗",
            Method = "󰆧",
            Property = "󰜢",
            Field = "󰜢",
            Constructor = "󰆧",
            Enum = "󰒻",
            Interface = "󰕘",
            Function = "󰊕",
            Variable = "󰀫",
            Constant = "󰏿",
            String = "󰀬",
            Number = "󰎠",
            Boolean = "󰨙",
            Array = "󰅪",
            Object = "󰅩",
            Key = "󰌋",
            Null = "󰟢",
            EnumMember = "󰒻",
            Struct = "󰌗",
            Event = "󰉁",
            Operator = "󰆕",
            TypeParameter = "󰊄",
          },
          highlight = "NamuPreview",
          highlights = {
            parent = "NamuParent",
            nested = "NamuNested",
            style = "NamuStyle",
          },
          kinds = {
            prefix_kind_colors = true,
            enable_highlights = true,
            highlights = {
              PrefixSymbol = "NamuPrefixSymbol",
              Function = "NamuSymbolFunction",
              Method = "NamuSymbolMethod",
              Class = "NamuSymbolClass",
              Interface = "NamuSymbolInterface",
              Variable = "NamuSymbolVariable",
              Constant = "NamuSymbolConstant",
              Property = "NamuSymbolProperty",
              Field = "NamuSymbolField",
              Enum = "NamuSymbolEnum",
              Module = "NamuSymbolModule",
            },
          },
        }
      }
      ui_select = { enable = false }, -- vim.ui.select() wrapper
    })
  end,
}

Tips

  • Type to filter symbols - it's fuzzy, so no need to be exact, though it prioritizes exact words first
  • Use regex patterns for precise filtering (e.g., ^test_ for test functions)
  • Press <CR> to jump, <Esc> to cancel

Feature Demos

🌳 Order Preservation Maintains symbol order as they appear in your code, even after filtering
preserve_order.mp4
symbols
  • Shows LSP symbols for current buffer.
  • Filter by kind: :Namu symbols function
  • Live kind filtering: /fn for fucntion , /me for methods, etc.
  • Live preview as you move.
Kind_filtering.mp4
workspace
  • Interactive workspace symbol search (LSP).
  • Start typing to see results, live preview.
workspace.mp4
watchtower
  • Shows symbols from all open buffers (LSP or Treesitter fallback).
  • Filter by buffer: /bf:buffer_name
  • Combine with kind: /bf:name:fn
buffer_filtering.mp4
diagnostics
  • Shows diagnostics for buffer or workspace.
  • Filter by severity: /er, /wa, /hi, /in
  • Live preview and navigation.
diagnostics.mp4
call_hierarchy
  • Show incoming, outgoing, or both calls for a symbol.
  • Usage: :Namu call in, :Namu call out, :Namu call both
call_hierarchy.mp4
ctags
  • Show ctags-based symbols for buffer or watchtower.
  • Requires ctags installed.
  • Usage: :Namu ctags, :Namu ctags watchtower
ctags.mp4

Display Styles

Show display style examples
  • options.display.format = "tree_guides": tree_guides

  • options.display.format = "indent": indent

Highlights

Show highlight groups
Group Description
NamuPrefix Prefix highlight
NamuMatch Matched characters in search
NamuFilter Filter prompt
NamuPrompt Prompt window
NamuSelected Selected item in multiselect
NamuFooter Footer text
NamuCurrentItem Current item highlight
NamuPrefixSymbol Symbol prefix
LSP KINDS HIGHLIGHTS -----------------
NamuSymbolFunction Function symbol
NamuSymbolMethod Method symbol
NamuSymbolClass Class symbol
NamuSymbolInterface Interface symbol
NamuSymbolVariable Variable symbol
NamuSymbolConstant Constant symbol
NamuSymbolProperty Property symbol
NamuSymbolField Field symbol
NamuSymbolEnum Enum symbol
NamuSymbolModule Module symbol
Some Other Styles --------------------
NamuTreeGuides Tree guide lines
NamuFileInfo File info text
NamuPreview Preview window highlight
NamuParent Parent item highlight
NamuNested Nested item highlight
NamuStyle Style elements highlight
NamuCursor Cursor highlight during Picker active

Contributing

I made this plugin for fun at first and didn't know I could replicate what Zed has, and to be independent and free from any pickers. Pull requests are welcome! Just please be kind and respectful. Any suggestions to improve and integrate with other plugins are also welcome.

Credits & Acknowledgements

  • Zed editor for the idea.
  • Mini.pick @echasnovski for the idea of getchar(), without which this plugin wouldn't exist.
  • Magnet module (couldn’t find it anymore on GitHub, sorry!), which intrigued me a lot.
  • @folke for handling multiple versions of Neovim LSP requests and treesitter "locals" in Snacks.nvim.
  • tests and ci structure, thanks to @Oli CodeCompanion
  • A simple mechanism to persist the colorscheme, thanks to this Reddit comment.
  • Aerial.nvim and @Stevearc for borroing some treesitter queries.

About

Flexible and sleek fuzzy picker, LSP symbol navigator, and more. inspired by Zed.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published