works fine for tiny file, but very slow for longer text
jdhao opened this issue · 4 comments
Describe the bug
This plugin works fine for small toy text, such as the following:
just for an test.
But for real Markdown file, when I use :LanguageToolCheck
, after several minutes, I get errors when I invoke the :LanguageToolSummary
command. I guess it is because the previous command hasn't produced the result the latter command needs.
To Reproduce
Steps to reproduce the behavior:
- Use the following minimal config:
set runtimepath+=/Users/jdhao/.local/share/nvim/plugged/LanguageTool.nvim
let g:languagetool_server_jar="/usr/local/opt/languagetool/libexec/languagetool-server.jar"
- Use the following config to start Neovim, and open
test.md
containing text here. - Run
:LanguageToolSetup
, followed by:LanguageToolCheck
- After a while, use
:LanguageToolSummary
command to check the output.
Expected behavior
A preview buffer is created to list all the found error for this file, but in
fact, I get the following error:
Error detected while processing function
LanguageTool#summary[1]
E121: Undefined variable: b:errors
E15: Invalid expression: b:errors
line 13:
E121: Undefined variable: l:errors
E116: Invalid arguments for function LanguageTool#ui#displayInWindow
I am not sure if this is an issue with languagetool or this plugin.
Desktop (please complete the following information):
- OS: MacOS 10.15.6
- nvim: v0.5.0-569e75799
Hi ! Thanks for reporting.
I think that most of the problem comes actually from LanguageTool itself, which can be really slow sometimes.
Regarding the errors when starting the command, I think they will mostly be solved once we rewrite this tool in lua, because we are going to move the errors displaying logic together with this.
Hopefully this makes sense, cheers.
I also tried other plugins such as vim-grammarous. It works pretty fast for the same long text I posted.
If I understand it correctly, vim-grammarous uses the client of languagetool while this plugin uses the server mode of languagetool.
So maybe the client mode can be used instead of server mode?
That seems pretty weird. Because using the server mode actually allows LanguageTool to cache some informations, and avoid loading everything.
What I think is that this comes from some preprocessing we are doing in this plugin, and I thus think that moving to Lua (+ treesitter) might speed up processing speed by a fair amount.
When processing the same text, vim-grammarous shows the result in about 3-4 seconds. But for this plugin, I never get the result. Can you try the text posted and run LanguageTool.nvim for grammar checking to see how long does it take to get result?