Issue
The current autocompletion regex pattern for deoplete is
let g:vimtex#re#deoplete = '\\(?:'
\ . '(?:\w*cite|Cite)\w*\*?(?:\s*\[[^]]*\]){0,2}\s*{[^}]*'
\ . '|(?:\w*cites|Cites)(?:\s*\([^)]*\)){0,2}'
\ . '(?:(?:\s*\[[^]]*\]){0,2}\s*\{[^}]*\})*'
\ . '(?:\s*\[[^]]*\]){0,2}\s*\{[^}]*'
\ . '|(text|block)cquote\*?(?:\s*\[[^]]*\]){0,2}\s*{[^}]*'
\ . '|(for|hy)\w*cquote\*?{[^}]*}(?:\s*\[[^]]*\]){0,2}\s*{[^}]*'
\ . '|\w*ref(?:\s*\{[^}]*|range\s*\{[^,}]*(?:}{)?)'
\ . '|hyperref\s*\[[^]]*'
\ . '|includegraphics\*?(?:\s*\[[^]]*\]){0,2}\s*\{[^}]*'
\ . '|(?:include(?:only)?|input|subfile)\s*\{[^}]*'
\ . '|([cpdr]?(gls|Gls|GLS)|acr|Acr|ACR)[a-zA-Z]*\s*\{[^}]*'
\ . '|(ac|Ac|AC)\s*\{[^}]*'
\ . '|includepdf(\s*\[[^]]*\])?\s*\{[^}]*'
\ . '|includestandalone(\s*\[[^]]*\])?\s*\{[^}]*'
\ . '|(usepackage|RequirePackage|PassOptionsToPackage)(\s*\[[^]]*\])?\s*\{[^}]*'
\ . '|documentclass(\s*\[[^]]*\])?\s*\{[^}]*'
\ . '|begin(\s*\[[^]]*\])?\s*\{[^}]*'
\ . '|end(\s*\[[^]]*\])?\s*\{[^}]*'
\ . '|\w*'
\ .')'
Here the second last line '|\w*' basically matches everything, which doesn't make sense (everything will trigger). I think it should be something like
'|\\\w*'
to match something only after a backslash.
Similar issue applies to neocomplete as well.
Hi, the first line of the regex starts with \\, which is followed by a huge parenthesis enclosing all the other lines (which are delimited by |), including the second to the last line \w*. So in the end, the line seems equivalent to \\\w* as you have suggested.
@j1-lee I see your point, thanks! But the problem is that it actually triggers autocompletion on whatever I typed (even without the leading '\'). When I made the change I proposed, this problem went away. I am not sure where the bug is now.
@chunhaow The comment by @j1-lee is accurate. The regex should be equivalent to \\\w*. Can you please provide a minimal example to reproduce your problem?
@lervag @j1-lee Thank you so much for your input. The code here is completely fine. I just realized it's a bug of coc-vimtex, which deletes the leading "\" of the regex. I have posted an issue there: https://github.com/neoclide/coc-vimtex/issues/17
That's strange. I also use coc-vimtex, and I never recognized the issue. How do you recognize it?
Hi @lervag , please see my description at https://github.com/neoclide/coc-vimtex/issues/17
Note to self and bypassers: The issue is now resolved upstream.