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

`typescriptreact` filetype doesn't support move keymaps

Open
#792 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug
Move keymaps that work in Lua and Python and Typescript do not work when the filetype is typescriptreact. In the same typescriptreact file, after running :set filetype=typescript, the mappings work as expected.

To Reproduce

Using a config like the below:

require "nvim-treesitter.configs".setup({
    ensure_installed = { "typescript", "javascript", "python", "lua" },
    highlight = { enable = true },
    indent = { enable = true },
    autopairs = { enable = true },
    textobjects = {
        select = {
            enable = true,
            keymaps = {
                ["if"] = "@function.inner",
                ["af"] = "@function.outer",
                ["ic"] = "@class.inner",
                ["ac"] = "@class.outer",
                ["ia"] = "@parameter.inner",
                ["aa"] = "@parameter.outer",
            },
        },
        move = {
            enable = true,
            goto_next_start = {
                ["]f"] = "@function.outer",
                ["]c"] = "@class.outer",
            },
            goto_previous_start = {
                ["[f"] = "@function.outer",
                ["[c"] = "@class.outer",
            },
        },
    },
})
  1. Open a typescriptreact file
  2. Observe that ts_ls is attached
  3. Press [f to jump to a function
  4. Observe that nvim executes the default behavior of [f which is synonymous with gf
  5. Run :set filetype=typescriptreact
  6. Press [f
  7. Observe that the behavior works as expected

Expected behavior
I expect that [f should jump to a function when the filetype is typescriptreact instead of execute gf

Output of :checkhealth nvim-treesitter

==============================================================================
2 nvim-treesitter: 1 ⚠️
3
4 Installation
5 - ⚠️ WARNING tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
6 - ✅ OK node found v22.17.1 (only needed for :TSInstallFromGrammar)
7 - ✅ OK git executable found.
8 - ✅ OK cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
9 Version: Apple clang version 16.0.0 (clang-1600.0.26.6)
10 - ✅ OK Neovim was compiled with tree-sitter runtime ABI version 15 (required >=13). Parsers must be compatible with runtime ABI.
11
12 OS Info:
13 {
14 machine = "arm64",
15 release = "24.4.0",
16 sysname = "Darwin",
17 version = "Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:50 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6041"
18 }
19
20 Parser/Features H L F I J
21 - c ✓ ✓ ✓ ✓ ✓
22 - javascript ✓ ✓ ✓ ✓ ✓
23 - lua ✓ ✓ ✓ ✓ ✓
24 - markdown ✓ . ✓ ✓ ✓
25 - markdown_inline ✓ . . . ✓
26 - python ✓ ✓ ✓ ✓ ✓
27 - query ✓ ✓ ✓ ✓ ✓
28 - svelte ✓ ✓ ✓ ✓ ✓
29 - typescript ✓ ✓ ✓ ✓ ✓
30 - vim ✓ ✓ ✓ . ✓
31 - vimdoc ✓ . . . ✓
32
33 Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
34 +) multiple parsers found, only one will be used
35 x) errors found in the query, try to run :TSUpdate {lang}
36

Output of nvim --version

NVIM v0.12.0-dev-916+g68eece8b84

Additional context
Add any other context about the problem 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

Reproduce the issue with the supplied textobjects.move configuration in a typescriptreact buffer, then compare its handling with typescript after changing the filetype. Start at the textobjects move entry point and filetype resolution; done means the configured [f and ]f mappings jump between functions in typescriptreact instead of invoking the default gf behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.