lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.51k stars 389 forks source link

Provide an option to exlude a list of commands from spell checking #1749

Closed timokau closed 4 years ago

timokau commented 4 years ago

Continuing the discussion from https://github.com/lervag/vimtex/issues/562#issuecomment-659229363. I still think such an option would be desirable and it could be done in addition to exludes in package scripts.

Package scripts in vimtex are inherently limited to at least somewhat popular commands. They do not work as soon as I use \newcommand\mygls\gls. Therefore I think a low-friction way of adding additional excludes would be nice. Benefits include

This feature is strictly a nice-to-have, not a must-have. I thought it couldn't hurt to continue the discussion here, but I understand if you just close this issue.

lervag commented 4 years ago

Thanks for opening a new issue for this discussion!

I'm thinking the option should be something like this:

let g:vimtex_syntax_nospell_commands = [
      \ 'bibliographystyle',
      \ 'mycustommacro',
      \ 'myothercustommacro',
      \]

Each entry should be interpreted as a regular expression to match a macro name, where the \ is implied. Most often, you would just write the full name, but if you e.g. define several similar commands you could match all with 'mycmd\(one\|two\)'. The default value is an empty list, because vimtex aims to have quite wide support for common packages.

List of TODOs:

Note: This will add relatively top level syntax matches (except they need to be contained in the texDocument and similar), and it is not possible to combine the @NoSpell with other syntax features through this mechanism alone.

What do you think?

timokau commented 4 years ago

Sounds good! Regarding the naming I would find "commands" a bit more intuitive, since you are declaring them with newcommand. Or is there an actual difference between a "command" and a "macro"?

I don't feel very strongly about it either way though. I just think the user is more likely to search for "command", at least I would be.

lervag commented 4 years ago

Sounds good! Regarding the naming I would find "commands" a bit more intuitive, since you are declaring them with newcommand. Or is there an actual difference between a "command" and a "macro"?

Thanks, I agree.

lervag commented 4 years ago

I think this should do it. Please test.