chrisbra / matchit

The matchit plugin from Vim
61 stars 9 forks source link

Regular regex issues with matchit #11

Closed snoblenet closed 5 years ago

snoblenet commented 5 years ago

Neovim v0.3.1 Mac OS X 10.14.1

call plug#begin('~/.config/nvim/autoload')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/neco-vim'
Plug 'airblade/vim-gitgutter'
Plug 'autozimu/LanguageClient-neovim', { 'do': 'bash install.sh' }
Plug 'neomake/neomake'
Plug 'blueyed/vim-diminactive'
Plug 'chrisbra/Colorizer'
Plug 'davidosomething/vim-enhanced-resolver', { 'do': 'npm install --global enhanced-resolve-cli' }
Plug 'elzr/vim-json'
Plug 'ervandew/supertab'
Plug 'hail2u/vim-css3-syntax'
Plug 'icymind/NeoSolarized'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim' "Both are required
Plug 'kana/vim-textobj-function'
Plug 'kana/vim-textobj-user'
Plug 'moll/vim-node'
Plug 'mxw/vim-jsx'
Plug 'othree/html5.vim'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'pangloss/vim-javascript'
Plug 'pearofducks/ansible-vim' " syntax highlighting for YAML files
Plug 'ryanoasis/vim-devicons'
Plug 'scrooloose/nerdtree'
Plug 'simnalamburt/vim-mundo'
Plug 'thinca/vim-textobj-function-javascript'
Plug 'tmux-plugins/vim-tmux' " syntax highlighting to ~/.conf.tmux
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'yggdroot/indentline'
Plug 'zchee/deoplete-zsh'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
call plug#end()

I am regularly getting the error shown below when my cursor is on one parenthesis and I press % to go to the matching parenthesis.

Note that this is despite the fact that the syntax highlighting plugin is correctly highlighting the matching parenthesis as jsFuncBraces.

I've found that the problem only affects one file at a time. But the affected file need not have any linting errors or unmatched braces for the problem to occur.

Quiting and restarting neovim temporarily solves the problem so the problem seems to be with the plugin not the inherit complexity of the file containing the parentheses.

Likewise, once the problem begins, it affects even minimal examples in the affected file, like jumping between braces in const sum = (a + b);.

After a restart, the problem does not appear for a few hours. Then it starts again and stays until I quit and restart again. (Sorry this is the only way I know to reproduce the issue.)

Actual behaviour

image

Expected behaviour

Go to matching parenthesis every time.

Sidebar

Given the Language Server Protocol can return a 'range' (start and end column and row for each function), I'm wondering if this might be better than regex for syntax highlighting and for % and for custom objects like inside function and around function.

Postscript

I hope that I've understood correctly that this issue should be filed on the plugin itself not on Neovim. Thank you.

chrisbra commented 5 years ago

I am sorry, I don't really understand what this has to do with LSP. matchit is a simple plugin for finding matching parts in a file. So I suppose that means, it happens on Javascript files. So with a file like this:

const sum = (a + b);

and the cursor on any of the paranthesis, pressing % will cause this error?

Unfortunately, I cannot reproduce the error. Have you tried with the latest version of this plugin?

Also, I see you are using several javascript plugins. Does any of those plugins define the b:match_words variable, it looks like this might be the culprit.

Also please have a look at :h matchit-debug and see if this gives more information on how to reproduce the issue.

Alieff commented 5 years ago

I also got this error for certain file at certain time (javascript file in most cases), but after check the b:match_words content as chrisbra suggested, I found that something unknown has changed the content, the content become complicated.

After that I try to reset the content by copying b:match_words content in new window (opening the same file), and apply in the old window, then it is solved :)

For preventing such event in the future, I save the regex content for that file type, and re-assign it in the future when such error happen again.

chrisbra commented 5 years ago

So what plugins are you using? the same as @snoblenet ? It would be interesting to know, which plugins is responsible for changing it (so we can open an issue there).

Alieff commented 5 years ago

No different, but for my case I think I've found problem root, after doing global search on ~/.vim/bundle folder, ultisnips and vim-polyglot seems responsible for changing the variable. Especially vim-polyglot(language pack for vim), I am pretty sure of it.

Because when I tried to execute ft=javascript.jsx multiple times, variable b:match_words keeps getting appended.

chrisbra commented 5 years ago

Thanks.

https://github.com/sheerun/vim-polyglot/blob/ec1c94306953b678bb36572897bd218fe6c76506/after/ftplugin/jsx.vim#L12-L19

Could that be the culprit? I'll have a closer look soon.

VincentCordobes commented 5 years ago

I also experience this issue. I don't have vim-polyglot but I do have vim-jsx which has the same code obviously https://github.com/mxw/vim-jsx/blob/master/after/ftplugin/jsx.vim

I'll try commenting out that part and see if it solves the problem (as it usually appears after few minutes editing a file)

snoblenet commented 5 years ago

Sounds like vim-jsx is the culprit. Should one of us raise an issue there?

VincentCordobes commented 5 years ago

There is an open PR about it https://github.com/mxw/vim-jsx/pull/177

chrisbra commented 5 years ago

thanks for mentioning it.

chrisbra commented 5 years ago

I can confirm, that the mentioning jsx plugin adds to the b:match_words variable. However, this Per se, does not cause the error message. So if anybody can reproduce the mentioned error message, please let me know the value of b:match_words.

chrisbra commented 5 years ago

Oh, wait, yes it does cause the issue, once too many items have been accumulated into b:match_words.