andymass / vim-matchup

vim match-up: even better % :facepunch: navigate and highlight matching words :facepunch: modern matchit and matchparen. Supports both vim and neovim + tree-sitter.

Home Page:https://www.vim.org/scripts/script.php?script_id=5624

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong matching across strings

Isrothy opened this issue · comments

Explain the issue

  1. What vim version are you using? If using neovim, Are you using
    tree-sitter or classic matching?
❯ nvim --version  
NVIM v0.10.0-dev-1031+gc431d820e
Build type: RelWithDebInfo
LuaJIT 2.1.1693350652
Run "nvim -V1 -v" for more info

Both tree-sitter and classic matching produce this bug

  1. Steps to reproduce
    In a file, write two strings.
    One string contains a '{' and another contains a '}'
    For example
local s1 = "{...."
local s2 = ".....}"

Then move the cursor onto on of the dots.

  1. Expected behavior
    No parentheses is highlighted
image
  1. Observed behavior
    The parentheses are highlighted
image

Minimal working example

local s1 = "{...."
local s2 = ".....}"

Minimal vimrc file

I'm using lazy for neovim

{
"andymass/vim-matchup",
init = function()
	vim.g.loaded_matchparen = 1
	vim.g.matchup_matchparen_deferred = 1
	vim.g.matchup_matchparen_hi_surround_always = 1
end,
}

Does the following option do what you want (disable matching in strings)?

let g:matchup_delim_noskips = 2

Unfortunately, I don't see any way in treesitter to match this

local s3 = "{.....}"

but not this

local s1 = "{...."
local s2 = ".....}"

as the braces are not tree nodes.

Thank you for your reply.
I tried this method. It works without vim.g.matchup_matchparen_hi_surround_always = 1. No matching in strings.
However, if I turn on vim.g.matchup_matchparen_hi_surround_always and matchup_matchparen_deferred, this issue still exists.