GitPedia

Nvim treehopper

Region selection with hints on the AST nodes of a document powered by treesitter

From mfusseneggerยทUpdated June 1, 2026ยทView on GitHubยท

A Plugin that provides region selection using hints on the abstract syntax tree of a document. The project is written primarily in Lua, distributed under the GNU General Public License v3.0 license, first published in 2021. Key topics include: neovim, neovim-plugin, nvim-treesitter, tree-sitter.

Treehopper ๐Ÿ‡

Syntax trees + hop = Treehopper

A Plugin that provides region selection using hints on the abstract syntax tree of a document.

Demo

Requirements

  • Neovim 0.7.2+

Treehopper operates on syntax trees. It uses tree-sitter to retrieve the tree
if a parser is available, otherwise it tries to use the built-in LSP client in
Neovim (using the selectionRange functionality).

You can install tree-sitter parsers either via:

Installation

  • Install it like any other neovim plugin:
    • If using vim-plug: Plug mfussenegger/nvim-treehopper
    • If using packer.nvim: use mfussenegger/nvim-treehopper

Usage

Selecting a region

Define two mappings:

omap     <silent> m :<C-U>lua require('tsht').nodes()<CR>
xnoremap <silent> m :lua require('tsht').nodes()<CR>

You can configure which keys are used for hint labels, the first N characters will be taken from the hint_keys and then after that it will restart from a-zA-Z

require("tsht").config.hint_keys = { "h", "j", "f", "d", "n", "v", "s", "l", "a" }

Moving

Moving depends on hop.nvim

If you want to move to the start or end of a syntax node you can use
require('tsht').move({ side = "start" }).

The parameter is optional and defaults to start. Use side = "end" if you
want to move to the end of a node.

Credits

Contributors

Showing top 9 contributors by commit count.

View all contributors on GitHub โ†’

This article is auto-generated from mfussenegger/nvim-treehopper via the GitHub API.Last fetched: 6/27/2026