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

Autoreload cached mappings on query save

Open
#787 2 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 want to be able to :TSEditQuery to edit a query and then save it and then have it work.

Currently this is jacked because treesitter-textobjects caches queryable objects in the key map:

:lua pp(require('nvim-treesitter.textobjects.select').keymaps_per_buf[62])
{ {
    lhs = "aa",
    mode = "o"
  }, {
    lhs = "aa",
    mode = "x"
  }, {
    lhs = "if",
    mode = "o"
  }, {
    lhs = "if",
    mode = "x"
  } }

https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/89ebe73cd2836db80a22d9748999ace0241917a5/lua/nvim-treesitter/textobjects/select.lua#L152-L154

Describe the solution you'd like
The keymaps should be detached and reattached on query save IMO.

Describe alternatives you've considered
You can restart vim I guess, that is no fun.

Additional context
Add any other context or screenshots about the feature request here.

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 with lua/nvim-treesitter/textobjects/select.lua at the referenced keymap caching code, and reproduce the issue by editing a query with :TSEditQuery and saving it. Trace how keymaps_per_buf is populated and define done as query saves causing the affected keymaps to detach and reattach without restarting Vim.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.