1

Neovim .6.1

Got this line:

add_post_meta($this->cmr_id, 'intro_paragraph', 'Hello');

With:

add_post_meta($this->cmr_id, 'intro_paragraph', 'Hello');
                                 ^ cursor here

Hitting '%' key jumps to opening paren as expected.

But with:

add_post_meta($this->cmr_id, 'intro_paragraph', 'Hello');
                 ^ cursor here

Nothing happens. If I remove the $, it works.

StevieD
  • 1,492
  • 1
  • 16
  • 24
  • 1
    I can't reproduce your issue with nvim 0.6.1 you probably want to check how do I debug my vimrc or maybe check if you have a mapping on % which causes an issue (How to debug a mapping). EDIT: Or it is a filetype issue. It would be worth checking that the issue still happens after using set ft= or if it happens with different filetypes. – statox Feb 22 '22 at 11:14
  • 1
    Ok I actually can reproduce in both vim and nvim if I set the filetype to php. That looks like a bug in the matchit plugin when using php... Maybe it would be worth creating an issue on Github. Also @ChristianBrabandt is listed as the maintainer of matchit in the source code, maybe he is the right person to ask this question to. – statox Feb 22 '22 at 11:19
  • 1
    OK, yeah, I was just about to come here and report I think it's a filetype issue. Thanks! – StevieD Feb 22 '22 at 11:28
  • 1
    So, turns out the php.vim script in vim calls html.vim script. html.vim script is the culprit. If I comment out the line that loads it, things works as expected. – StevieD Feb 22 '22 at 12:41
  • I didn't check the repo's issues but it could be worth creating one so that maintainers can fix it. – statox Feb 22 '22 at 15:44
  • I added an issue to neovim. They closed and it and told me to submit issue to vim. I have a better workaround below. – StevieD Feb 22 '22 at 16:08
  • 1
    Yeah I think neovim gets the matchit plugin from the vim repo so it makes sense they ask you to create it there. Your second solution is nice – statox Feb 22 '22 at 18:00
  • You don't want to know how long it took to figure that out. Vim is like one big giant hack on a hack. – StevieD Feb 22 '22 at 18:58

2 Answers2

1

OK, here's a much better fix, albeit probably not perfect.

In after/ftplugin/php.vim, add the following 3 lines:

let b:match_words .= '<?php:[^-]>'
set matchpairs-=<:>
let b:match_words = substitute(b:match_words, '<:>', '<:\@<=[^-]>', '')
StevieD
  • 1,492
  • 1
  • 16
  • 24
0

Looks to be a bug in html.vim which gets loaded by php.vim.

Hack fix:

Comment out:

"setlocal matchpairs+=<:>

And:

"if exists("loaded_matchit")
"    let b:match_ignorecase = 1
"    let b:match_words = '<:>,' .
"    \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
"    \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
"    \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
"endif
StevieD
  • 1,492
  • 1
  • 16
  • 24