nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects

feature: virtual text to where a mapping would jump OR expose getting locations where to jump

Open
#899 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Tree-sitter Query
Stars
2.8k
Forks
271
Avg merge
8d 8h
Merged PRs (30d)
1

Description

Is your feature request related to a problem? Please describe.
I mapped all jumps of this plugin similar to other jumps: [ or ] plus key or KEY.

I wonder if it is possible to have like a virtual text or whatever stylistically similar to https://github.com/wsdjeg/hop.nvim . Assuming that all keymaps are assigned somehow similar to vim's, I would like after pressing ] or [ to see where it would jump depending on next pressed key.

Describe the solution you'd like

The current possible solution is hop-treesitter and I don't understand how to make it as powerful as https://github.com/nvim-treesitter/nvim-treesitter-textobjects/ because currently it just takes all surrounding nodes of current node and all surrounding nodes of its parent. And then it takes the locations of the nodes, then returns them and calls hop.hint_with(locations, ...).

Maybe, getting locations from nvim-treesitter-textobjects's jumps would be good enough so that mapping them to the hop.hint_with(locations, ...) would provide solution.

AFAIU from https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/main/lua/nvim-treesitter-textobjects/move.lua , selecting where to go and actually jumping is a last thing decision. Probably, the best solution is decoupling getting the locations and actually jumping. If getting of locations was exposed in any way, It would provide the necessary API for hop.hint_with and
still keep existing jumping working.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read nvim-treesitter-textobjects/lua/nvim-treesitter-textobjects/move.lua alongside hop-treesitter/treesitter.lua to understand how jump locations are collected and consumed. Define an API that exposes those locations for hop.hint_with while preserving existing jumping behavior; done means the requested mappings can show destinations before jumping.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.