YouCompleteMe considers underscores _
as word characters, which is desirable in most programming languages. But in TeX and LaTeX, this is not the case, especially where the underscore has a reserved marker for subscripts.
What I want is to remove underscores as word characters, so that it does not recognise constructions like alpha_
or sum_
as words.
How can a disable _
as a word character?
A MWE (I use Neovim wiht vim-plug
):
" ~/.config/nvim/init.vim file
call plug#begin('~/.local/share/nvim/plugged')
Plug 'sirver/ultisnips'
Plug 'ycm-core/YouCompleteMe'
call plug#end()
# custom snippet file
snippet _ "subscript" iA
_{$1}
endsnippet
% main `main.tex` file
\documentclass{article}
\begin{document}
$\sum_{n}$
$\sum_}$ % <- Here is the problem.
\end{document}
In the above problem line, if I type \sum
, YCM suggests me the word sum_
for autocompletion. Ignoring that and continue typing _
, the snippet is not expanded correctly as _{}
, but _}
, where the cursor lies just before }
. Notice that this happens only for the second and subsequent \sum
s.
Edit: This happens for any word followed by an underscore, if that word previously appeared in the code and YMC parsed it. So this produces the same problem:
Hi
Hi_} % <- Same problem
:h 'iskeyword'
. Also I'm fairly sure we have a duplicate of this question but I can't find it right now.:verbose set isk?
returns@,48-57,_,192-255
, last set by the pluginvimtex
. Do you think that changing this will fix the problem, e.g. bylet g:tex_isk='@,48-57,192-255
?