jemag / nvim-treehopper

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TSHT (Treesitter hint textobject)

Plugin that provides region selection using hints on the abstract syntax tree of a document. This is intended to be used for pending operator mappings.

Demo

Requirements

  • Requires Neovim HEAD/Nightly
  • A treesitter parser for each language you plan to use the plugin with.
    • Parsers can be installed via nvim-treesitter TSInstall
    • For manual installation, you need to compile the language specific parsers using gcc and place the object files into ~/.config/nvim/parser.
  • locals queries for each language you plan to use the plugin with.
    • nvim-treesitter ships locals queries for many languages. If you've it installed they'll be picked up.
    • You can install them manually by placing locals.scm query files into ~/.config/nvim/queries/<language>/

Installation

  • nvim-ts-hint-textobject is a plugin. Install it like any other neovim plugin:
    • If using vim-plug: Plug mfussenegger/nvim-ts-hint-textobject
    • If using packer.nvim: use mfussenegger/nvim-ts-hint-textobject

Usage

Define two mapppings:

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" }

Credits

About

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

License:GNU General Public License v3.0


Languages

Language:Lua 92.2%Language:Vim Script 7.8%