Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Breaks highlight on yank in javascript files in neovim 0.11 #61

@sarmong

Description

@sarmong

Describe the bug

Highlight on yank autocommand (with vim.highlight.on_yank) doesn't work when yanking from the middle of the word in javascript and typescript files.

When yanking from the start of the word - it works as expected

To Reproduce

Steps to reproduce the behavior:

  1. Save minimal reproducible config below
  2. Run NVIM_APPNAME=nvim-debug-yank nvim -u minimal.lua file.js
  3. Move cursor to the middle of the word (where refactor highlight is present)
  4. Press yaw
Minimal reproducible config
local pack_path = vim.fn.stdpath("data") .. "/site/pack"

local function install_plugin(slug)
  local plugin_name = vim.fs.basename(slug)
  local plugin_path =
    vim.fs.joinpath(pack_path, plugin_name, "opt", plugin_name)
  if vim.fn.isdirectory(plugin_path) == 0 then
    vim
      .system({
        "git",
        "clone",
        "https://github.com/" .. slug .. ".git",
        plugin_path,
      })
      :wait()
  end

  vim.cmd.packadd(plugin_name)
end

install_plugin("nvim-treesitter/nvim-treesitter")
install_plugin("nvim-treesitter/nvim-treesitter-refactor")

require("nvim-treesitter.configs").setup({
  ensure_installed = { "javascript" },
  sync_install = true,
  highlight = { enable = true },
  refactor = {
    highlight_definitions = { enable = true },
    highlight_current_scope = { enable = true },
  },
})

vim.api.nvim_create_autocmd("TextYankPost", {
  group = vim.api.nvim_create_augroup("Highlight on yank", {}),
  pattern = "*",
  callback = function()
    vim.highlight.on_yank()
  end,
})
yank11-2025-04-05_14.27.22.mp4

Expected behavior

Highlight on yank works properly, as in 0.10:

yank10-2025-04-05_14.29.44.mp4

Output of :checkhealth nvim_treesitter

Click me
Installation ~
- OK `tree-sitter` found 0.22.2 (fc15f621334a262039ffaded5937e2844f88da61) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.9.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (Debian 12.2.0-14) 12.2.0
- OK Neovim was compiled with tree-sitter runtime ABI version 15 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
machine = "x86_64",
release = "6.1.0-31-amd64",
sysname = "Linux",
version = "#1 SMP PREEMPT_DYNAMIC Debian 6.1.128-1 (2025-02-07)"
} ~

Parser/Features         H L F I J
- c                   ✓ ✓ ✓ ✓ ✓
- javascript          ✓ ✓ ✓ ✓ ✓
- lua                 ✓ ✓ ✓ ✓ ✓
- markdown            ✓ . ✓ ✓ ✓
- markdown_inline     ✓ . . . ✓
- query               ✓ ✓ ✓ ✓ ✓
- vim                 ✓ ✓ ✓ . ✓
- vimdoc              ✓ . . . ✓

Output of nvim --version

NVIM v0.11.0
Build type: Release
LuaJIT 2.1.1741730670

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions