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.
https://www.vim.org/scripts/script.php?script_id=5624
MIT License
1.69k stars 71 forks source link

Parens in strings being matched #82

Closed ds26gte closed 4 years ago

ds26gte commented 4 years ago

In this Lispy language fragment, syntax is appropriately set so that anything after ; on a line is a comment, and strings are double-quote-delimited.

(define procname ; ) in comment isn't matched as expected
  ") in string is however matched"
  body)

vim-matchup correctly skips the ) in the comment but not in the string. Any suggestions? Is this a config issue?

These are my settings

let matchup_matchparen_offscreen = {}
let matchup_delim_noskips = 2
ds26gte commented 4 years ago

p.s. Seems to happen only if the string highlight group was defined as a link to another group. I was able to circumvent the problem by defining string from scratch.

andymass commented 4 years ago

What filetype is this? Do you have a fully reproducible example?

ds26gte commented 4 years ago

The filetype is scheme. To reproduce, either install no colorscheme or install colorscheme default, install vim-matchup as a package, and start neovim. Edit a file j.scm, which contains the contents above, i.e.,

(define procname ; ) in comment isn't matched as expected
  ") in string is however matched"
  body)

No or default colorscheme uses a link for the syntax group string: so the paren matching will fail.

Now, perform the ex command

:hi string guibg=none guifg=green

(Or put this in a vim file in ~/.config/nvim/plugin and reopen neovim.)

The parens will now match correctly.

This may be the only acceptable solution -- i.e., having the user ensure that string is assigned its own colors and not linked to another group. So I'm willing to consider the issue solved.