VIM thesaurus file

后端 未结 3 1376
挽巷
挽巷 2021-01-04 20:25

I have been poking around for a good solution for a vim thesaurus. The capability is built-in, obviously, but the file everyone seems to use is the mthesaur.txt. While it \'

3条回答
  •  暖寄归人
    2021-01-04 21:28

    I have written a plugin that can address the two issues you raised here.

    Multi-language Thesaurus Query plugin for Vim

    It improves the using experience in two regards: more sensible synonym choosing mechanism; and better and more flexible synonym source(s).

    Thesaurus_query.vim screen cast

    By default, the plugin uses vim's messagebox for candidate display, with each synonym labeled by a number. And it let user choose the suitable one to replace the word under cursor by typing in its number. It works similar to vim's default spell correction prompt. And drastically reduced the operation time for choosing proper synonym from a long list of candidates.

    To improve the quality of synonym candidates, multiple query backends were used. For English user, two are note worthy.

    • thesaurus_com Backend using Thesaurus.com as synonym source
    • mthesaur_txt Backend using mthesaur.txt as synonym source

    thesaurus_com Backend will work straight away. For Local Query Backend to work, you will need to download mthesaur.txt and tell the plugin where it is located either by setting variable thesaurus or specifying variable g:tq_mthesaur_file. Or else only Online Backend will be functional.

    By default, Online Query Backend will be used first. But if internet is not available or too slow, future query in the current vim session will be handled by Local Query Backend first to reduce latency time. Priority of these two backends can also be manually altered(see documentation).

    To address the latency issue(which usually stands out when the word is not found), I have introduced a timeout mechanism. You may set

    let g:tq_online_backends_timeout = 0.6
    

    if your internet is reasonably fast. So that the latency could be reduced to under 0.6 second.

    The plugin is written in Python, though. So you might want to use it with Vim compiled with Python and/or Python3 support.

提交回复
热议问题