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

Smart selection mode

Open
#810 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.

It would be nice if we could have "smart" selection mode, i.e., if the textobject takes up whole line/lines, use line-wise select, else use char-wise select. E.g., for the following lua function, use line-wise select:

local function my_func()
    return
end

But for this function, use char-wise select, as it does not take up a whole line at the beginning of the function:

local my_func = function()
    return
end

Describe the solution you'd like

Smartly detect if a textobj should have line-wise selection or char-wise selection based on its range.

Describe alternatives you've considered
N/A

Additional context
N/A

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

No file or test is named in the issue. Start by locating the textobject selection entry point and the code that computes its range; then compare the line-wise and character-wise selection behavior in the two Lua examples. Done means the selection mode is chosen from whether the range occupies whole lines, with both examples covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.