Ron89 / thesaurus_query.vim

Multi-language Thesaurus Query and Replacement plugin for Vim/NeoVim
http://www.vim.org/scripts/script.php?script_id=5341
Apache License 2.0
220 stars 23 forks source link

bs4 dependency install request for disabled backend #45

Closed nkoester closed 4 years ago

nkoester commented 4 years ago

Using the plugin in neovim works great, however all my configuration efforts do not seem to avoid the following error to spawn on every new session (which is quite annoying):

Required package bs4 can not be imported. Please use '/usr/bin/python3 -m pip install bs4 --user --upgrade' to install the latest bs4.
 Do you want to try to import it again?
[Y]es, (D)isable 'cnrtl_fr' backend for this Vim session:

I do not plan on using this backend ever and I do not want to install the dependency. My config does not enable the cnrtl_fr package, yet it asks for its dependency:

let g:tq_enabled_backends=[ "openoffice_en",
            \"openoffice_de",
            \"datamuse_com",
            \"openthesaurus_de",
            \"mthesaur_txt",] 
let g:tq_language=['en', 'de']

When I echo the variables in vim they are correctly set. Their content seems to but are ignored? How can I avoid this behaviour? Is this a configuration issue?

Nevertheless: Great plugin, really useful to me. Thanks!

Further information on my setup:

$ nvim --version
NVIM v0.4.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.2/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"
$ uname -a
Linux 5.3.8-arch1-1 #1 SMP PREEMPT @1572357769 x86_64 GNU/Linux
Ron89 commented 4 years ago

Right, I should have made this check taking place on loading instead of on initialization. Will make that change this week.

Thanks for the suggestion. 😁

-------- Original Message -------- On 7 Nov 2019, 7:20 pm, Norman < notifications@github.com> wrote:

Using the plugin in neovim works great, however all my configuration efforts do not seem to avoid the following error to spawn on every new session (which is quite annoying):

Required package bs4 can not be imported. Please use '/usr/bin/python3 -m pip install bs4 --user --upgrade' to install the latest bs4.
 Do you want to try to import it again?
[Y]es, (D)isable 'cnrtl_fr' backend for this Vim session:

I do not plan on using this backend ever and I do not want to install the dependency. My config does not enable the cnrtl_fr package, yet it asks for its dependency:

let g:tq_enabled_backends=[ "openoffice_en",
            \"openoffice_de",
            \"datamuse_com",
            \"openthesaurus_de",
            \"mthesaur_txt",]
let g:tq_language=['en', 'de']

When I echo the variables in vim they are correctly set. Their content seems to but are ignored? How can I avoid this behaviour? Is this a configuration issue?

Nevertheless: Great plugin, really useful to me. Thanks!

Further information on my setup:

$ nvim --version
NVIM v0.4.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.2/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"
$ uname -a
Linux 5.3.8-arch1-1 #1 SMP PREEMPT @1572357769 x86_64 GNU/Linux

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.AAUSJPOTARPTBD2RWMS5N6LQSP2YZA5CNFSM4JKFDNVKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HXSN4QA.gif

Ron89 commented 4 years ago

@nkoester , the affected backends are patched. The problem should be resolved. Please update the plugin and try again.

nkoester commented 4 years ago

Yes, it works as expected. thanks for the quick fix! :)

One nit-pick: The first call of the plugin has in a bigger delay than the following calls. Is this tweakable?

Ron89 commented 4 years ago

@nkoester , glad it solves your problem.

I noticed something weird in your configuration. I actually didn't write backend for openoffice_de. So it never works. So I wonder, did you actually setup openoffice_en to work properly? Local plugin setup is a bit tricky, because you will need to manually download the thesaurus database, then make this plugin to point to the local plugin resource before you can use:

" if your openoffice thesaurus file is at ~/.vim/thesaurus folder
   let g:tq_openoffice_en_file="~/.vim/thesaurus/th_en_US_new"

So, assuming you have defunct local backends, the delay could have been caused by the querying on not functional plugin. For example, if you didn't configure openoffice thesaurus database correctly, it might take some time to query and skip it before it hits datamuse.com. Now if you are querying German, then it will take datamuse.com some time to return negative result before the German backend is tried and return positive. Subsequent query will skip defunct backend and jump straight to the opensthesaurus_de backend that previously yields positive result.

For a better response speed, you can setup the local backend before the online backend. For online backends, you can set the more frequently used one before the less frequently used one.

nkoester commented 4 years ago

You are correct, the openoffice_de was wrong and I deleted that. All in all I am quite happy with the performance. Feel free to close the issue.