How to have the spell checker ignoring URLs and acronyms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to have the spell checker ignoring URLs and acronyms

Walter Cazzola-2
Dear Vim Experts,
bored to have acronyms and URLs marked as errors in my LaTeX files I have
looked for a solution. Here

    http://www.panozzaj.com/blog/2016/03/21/ignore-urls-and-acroynms-while-spell-checking-vim/

Suggests to add

    syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
    syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@NoSpell

in ~/.vim/after/tex.vim but it doesn't seem to work.

:scriptnames lists the file correctly loaded

    226: /usr/share/vim/vim82/ftplugin/tex.vim
    227: /usr/share/vim/vim82/ftplugin/plaintex.vim
    228: /usr/share/vim/vim82/ftplugin/initex.vim
    229: ~/.vim/bundle/vim-polyglot/after/ftplugin/tex.vim
    230: /usr/share/vim/vim82/syntax/tex.vim
    231: ~/.vim/bundle/vim-polyglot/after/syntax/tex.vim
    232: ~/.vim/after/syntax/tex.vim

But it seems ignored and all my acronyms are still marked as errors.

I've already commented out all the plugins and still they are ignored.

What am I doing wrong?

I'm using Vim 8.2 on a linux box, Vundle is my plugin manager and I've
vim-latex installed.

Any help is welcome. Thank you.

Walter

PS. Note that to add all the acronyms to the list of known words is not a
feasible option.

--

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4d485454-42cc-50aa-6685-ca8cd94e8c67%40di.unimi.it.
Reply | Threaded
Open this post in threaded view
|

Re: How to have the spell checker ignoring URLs and acronyms

Charles Campbell-2
Walter Cazzola wrote:
Dear Vim Experts,
bored to have acronyms and URLs marked as errors in my LaTeX files I have
looked for a solution. Here

   http://www.panozzaj.com/blog/2016/03/21/ignore-urls-and-acroynms-while-spell-checking-vim/

Suggests to add

   syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
   syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@NoSpell

in ~/.vim/after/tex.vim but it doesn't seem to work.
I suspect that you need to get your matches contained in various groups. For a start, consider also trying (in ~/.vim/after/tex.vim)

syn cluster texFoldGroup add=UrlNoSpell,AcronymNoSpell

You didn't provide any examples, so the above is a guess.

Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a0dd807a-26c9-53ce-696e-e1af17557077%40drchip.org.
Reply | Threaded
Open this post in threaded view
|

Re: [VIM] Re: How to have the spell checker ignoring URLs and acronyms

Walter Cazzola-2
Hi,
thanks for the reply

On Sat, 3 Apr 2021, Charles Campbell wrote:

> I suspect that you need to get your matches contained in various groups. For
> a start, consider also trying (in ~/.vim/after/tex.vim)

>       syn cluster texFoldGroup add=UrlNoSpell,AcronymNoSpell

This mostly did the trick. It now works in some cases but not everywhere, see
the minimal example below.

> You didn't provide any examples, so the above is a guess.

You are right, this is a MWE

    \documentclass[a4paper]{article}
    \begin{document}
       SUT (SUT) [SUT] {SUT} SUT,
       $SUT$
       \section{A section about SUT.}
       \begin{itemize}
          \item SUT
       \end{itemize}
       \begin{figure}\caption{whatever SUT is}\end{figure}

       ftp://erlang.org/doc/man/erl_tracer.html
       \url{ftp://erlang.org/doc/man/erl_tracer.html}
    \end{document}

in this case, the acronym SUT and the URL are correctly ignored in paragraphs
(also when followed by punctuation symbols) but not when in a command as
\section, \url or \caption. What I see is in the attached pic.

Currently, my .vim/after/syntax/tex.vim contains:

   syn cluster texFoldGroup add=UrlNoSpell,AcronymNoSpell
   syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
   syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@NoSpell

Probably, there will be another group to add these patterns. Where can I read
all the possible groups?

Thank you
Walter

--

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5c9159c7-f395-7e36-9d75-8d6be1d11e38%40di.unimi.it.

ignore-spell.png (37K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [VIM] Re: How to have the spell checker ignoring URLs and acronyms

Charles Campbell-2
Walter Cazzola wrote:
Hi,
thanks for the reply

On Sat, 3 Apr 2021, Charles Campbell wrote:

I suspect that you need to get your matches contained in various groups. For
a start, consider also trying (in ~/.vim/after/tex.vim)

      syn cluster texFoldGroup add=UrlNoSpell,AcronymNoSpell

This mostly did the trick. It now works in some cases but not everywhere, see
the minimal example below.

You didn't provide any examples, so the above is a guess.

You are right, this is a MWE

   \documentclass[a4paper]{article}
   \begin{document}
      SUT (SUT) [SUT] {SUT} SUT,
      $SUT$
      \section{A section about SUT.}
      \begin{itemize}
         \item SUT
      \end{itemize}
      \begin{figure}\caption{whatever SUT is}\end{figure}

      ftp://erlang.org/doc/man/erl_tracer.html
      \url{ftp://erlang.org/doc/man/erl_tracer.html}
   \end{document}

in this case, the acronym SUT and the URL are correctly ignored in paragraphs
(also when followed by punctuation symbols) but not when in a command as
\section, \url or \caption. What I see is in the attached pic.

Currently, my .vim/after/syntax/tex.vim contains:

  syn cluster texFoldGroup add=UrlNoSpell,AcronymNoSpell
  syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
  syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@NoSpell

Probably, there will be another group to add these patterns. Where can I read
all the possible groups?
Well, all the groups are explicitly laid out in syntax/tex.vim, albeit embedded with the rest of the syntax highlighting. What you might consider doing is using hilinks.vim (http://www.drchip.org/astronaut/vim/index.html#HILINKS, :HLT!) which will then tell you what syntax and highlighting is currently in-use under your cursor. Using your example I typed :HLT!, placed the cursor on the f in ftp:... and noted that the syntax stack has texDocZone->texSectionZone -- so you'll want to use
syn cluster texSectionZone add=UrlNoSpell,AcronymNoSpell
to your after/syntax/tex.vim file.

Regards,
Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5fdcca7c-8885-9776-455c-135213dc66bb%40drchip.org.
Reply | Threaded
Open this post in threaded view
|

Re: [VIM] Re: [VIM] Re: How to have the spell checker ignoring URLs and acronyms

Walter Cazzola-2
Hi,
thank you for the reply. Unfortunately, your suggestion didn't solve the
issue.

I have installed your HILINKS and added any name coming out from it and now my

    .vim/after/syntax/tex.vim

is

    syn cluster texDocZone add=UrlNoSpell,AcronymNoSpell
    syn cluster texFoldGroup add=UrlNoSpell,AcronymNoSpell
    syn cluster texMatcher add=UrlNoSpell,AcronymNoSpell
    syn cluster texParen add=UrlNoSpell,AcronymNoSpell
    syn cluster texSectionZone add=UrlNoSpell,AcronymNoSpell
    syn cluster texSubSectionZone add=UrlNoSpell,AcronymNoSpell
    syn cluster texSubSubSectionZone add=UrlNoSpell,AcronymNoSpell

    syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
    syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@NoSpell

but still no lucky. Still acronyms and URLs aren't recognized when inside
parenthesis (both normal parenthesis and those introduced by LaTeX commands)

In the attached movie you have the results from HLK! on the MWE.

What am I doing wrong?

Walter

On Tue, 6 Apr 2021, Charles Campbell wrote:

> Walter Cazzola wrote:
>       Hi,
>       thanks for the reply
>
>       On Sat, 3 Apr 2021, Charles Campbell wrote:
>
>             I suspect that you need to get your matches contained in
>             various groups. For
>             a start, consider also trying (in ~/.vim/after/tex.vim)
>
>
>                   syn cluster texFoldGroup
>             add=UrlNoSpell,AcronymNoSpell
>
>
>       This mostly did the trick. It now works in some cases but not
>       everywhere, see
>       the minimal example below.
>
>             You didn't provide any examples, so the above is a guess.
>
>
>       You are right, this is a MWE
>
>          \documentclass[a4paper]{article}
>          \begin{document}
>             SUT (SUT) [SUT] {SUT} SUT,
>             $SUT$
>             \section{A section about SUT.}
>             \begin{itemize}
>                \item SUT
>             \end{itemize}
>             \begin{figure}\caption{whatever SUT is}\end{figure}
>
>             ftp://erlang.org/doc/man/erl_tracer.html
>             \url{ftp://erlang.org/doc/man/erl_tracer.html}
>          \end{document}
>
>       in this case, the acronym SUT and the URL are correctly ignored in
>       paragraphs
>       (also when followed by punctuation symbols) but not when in a command
>       as
>       \section, \url or \caption. What I see is in the attached pic.
>
>       Currently, my .vim/after/syntax/tex.vim contains:
>
>         syn cluster texFoldGroup add=UrlNoSpell,AcronymNoSpell
>         syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
>         syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@NoSpell
>
>       Probably, there will be another group to add these patterns. Where can
>       I read
>       all the possible groups?
>
> Well, all the groups are explicitly laid out in syntax/tex.vim, albeit embedded
> with the rest of the syntax highlighting. What you might consider doing is using
> hilinks.vim (http://www.drchip.org/astronaut/vim/index.html#HILINKS, :HLT!) which
> will then tell you what syntax and highlighting is currently in-use under your
> cursor. Using your example I typed :HLT!, placed the cursor on the f in ftp:...
> and noted that the syntax stack has texDocZone->texSectionZone -- so you'll want
> to use
>       syn cluster texSectionZone add=UrlNoSpell,AcronymNoSpell
>
> to your after/syntax/tex.vim file.
>
> Regards,
> Chip Campbell
>
>
--

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a24bba26-d8e0-b222-2377-1bf88cd46a9a%40di.unimi.it.

hlk-out.mkv (450K) Download Attachment