6

I use the vimtex plugin for TeX editing and vim-lexical for spell-checking.

This works generally fine, but there are several commands vim-lexical tries to spellcheck. For example, in \includepdf{pathToPdfFile} it marks the path to the file as spelling mistake. How can I tell vim-lexical that it should ignore everything in some commands (such as \includepdf) but consider in some others (everything in \bf should be checked)?

1 Answer 1

5

First: This is not related to vim-lexical. Syntax rules define where spell checking should be done, and so the current behaviour is defined by the internal syntax plugin for LaTeX.

The default syntax rule for tex command arguments allows spell checking. Some commands, e.g. \include{...}, are not spell checked. This is controlled by the @Spell and @NoSpell syntax clusters, see :h spell-syntax and :h syn-spell.

In order to add your own rules, you can create the file .vim/after/syntax/tex.vim. An example rule that will match \includepdf and prevent spelling is:

syntax match texInputFile /\\includepdf\%(\[.\{-}\]\)\=\s*{.\{-}}/
      \ contains=texStatement,texInputCurlies,texInputFileOpt

Note that this rule makes the syntax matching of \includepdf correspond to \include and similar commands. To prevent spelling of other commands where such a correspondence does not make sense, you could also use:

syntax match texStatement '\\includepdf' nextgroup=texMyNoSpell
syntax region texMyNoSpell matchgroup=Delimiter start='{' end='}' contained
      \ contains=@NoSpell

Note: Please don't hesitate to open issues with vimtex for things like this. vimtex provides some updates to the syntax rules on top of the internal syntax plugin, and the \includepdf command is a good example of commands I personally think should be matched.

2
  • Thanks. Maybe it's worth mentioning that it's actually not the fault of vimtex neither. Most of the syntax definitions come with vim and are located at /usr/share/vim/vim74/syntax/ (at least for ubuntu)
    – Jonas
    Commented Feb 12, 2016 at 11:48
  • I think it is implied in the answer. I have already updated vimtex so that it fixes the spell checking for the \includepdf command. Commented Feb 12, 2016 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.