Add `set_jumps` option to `select` module

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

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
lua, vim
Domain
tooling

Research direction

Start in the select module and compare its option handling with the set_jumps implementation in lua/nvim-treesitter/utils.lua for the move module. The linked targets.vim implementation provides another reference for jumplist behavior. Done means select accepts set_jumps, defaults it to false, and updates the jumplist only when enabled.

Written by the indexing model from the issue text.

Description

enhancement

Is your feature request related to a problem? Please describe.
Oftentimes I find myself selecting the wrong textobject (eg, vac instead of vax) or just needing to go back to the place my cursor was before I performed the textobject selection. There's no instant way to go back. You have to use vim motions to go to your original position. This is a bit inconvenient because textobjects from wellle/targets.vim add the cursor position to the jumplist just like set_jumps for the move module. So from time to time that muscle memory kicks in and you go back in the jumplist only to find yourself not where you'd expect.

Describe the solution you'd like
Add the option set_jumps, which is present in the move module to the select module. It should default to false for backward compatibility.

Describe alternatives you've considered
None, currently.

Additional context
Textobjects from wellle/targets.vim have the same jumplist functionality enabled by default for a few textobjects, but can optionally be enabled for all of them.

The implementation in targets.vim here and the move module here are functionally the same, so we can reuse the same implementation in select and have consistency between the two plugins.

I can prepare a PR if there's interest in this functionality.

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

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.

More from nvim-treesitter/nvim-treesitter-textobjects

All issues in nvim-treesitter/nvim-treesitter-textobjects

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.