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

include_surrounding_whitespace should be an option on the mapping itself

Open
#431 2 comments 3 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

Instead of requiring users to implement and write their own monolithic function themselves as in

keymaps = {
    ["af"] = "@function.outer",
    ["if"] = "@function.inner",
    ["aa"] = "@attribute.outer",
    ["ia"] = "@attribute.inner",
    ....
],
include_surrounding_whitespace = function (a)
    if a.query_string == "@function.outer" then
        return false
    elseif a.query_string == "@function.inner" then
        return false
    elseif a.query_string == "@attribute.outer" then
        return true
    elseif a.query_string == "@attribute.inner" then
        return false
    ....
end

I think making it an option on the keymap is a nicer and more expected API:

keymaps = {
    ["af"] = "@function.outer",
    ["if"] = "@function.inner",
    ["aa"] = { query = "@attribute.outer", includes_surrounding_whitespace = true },
    ["ia"] = "@attribute.inner",
    ....
],

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

Start by locating the keymaps configuration and the existing include_surrounding_whitespace handling in the textobjects plugin. Check how current mapping values are interpreted, then verify that per-keymap settings can express the requested behavior without breaking existing mappings.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.