rhysd / vim-grammarous

A powerful grammar checker for Vim using LanguageTool.
1.1k stars 41 forks source link

Gammarous closes down if an action is taken #78

Open Oliver-Chalkley opened 5 years ago

Oliver-Chalkley commented 5 years ago

I'm hoping that I'm not using Gammarous properly and so there is an easy fix to this. When I run :GrammarousCheck everything works fine. However when I move to a problem and fix it using the f command then it fixes it but the information window goes away and the highlighting goes. If I do :GrammarousCheck then it restarts from the beginning which is extremely annoying when editing a large document. Because of this I started to make all my changes manually but this means that as I make changes the text changes location but the highlighting stays in the same place. I am writing a PhD thesis so it doesn't take long before the highlighting is miles away from the actual error. The only way to correct this is to restart Gammarous but then it goes back to the beginning of the file. Since I am writing in LaTeX there are lots of errors that I skip and so going back to the beginning is extremely time consuming.

If I try to get around this problem by disabling rules that create false errors (due to the LaTeX commands) by using the R command then again Gammarous completely closes down (i.e. no window and no highlighting). If I run :GrammarousCheck then it starts again with the rule is active again.

Can anyone help me identify if this is an actual bug or me not using it correctly? I have read as much as I can find about using Gammarous but there is not much TBH.

Kaedo commented 5 years ago

Hi Oliver, i just had the same problem and got around it by mapping a key combination in order to automatically jump to the next/previous error, then the information window of grammarous shows up again.

I used this in my .vimrc:

function! g:grammarous#hooks.on_check(errs) abort
    nmap <buffer><A-n> <Plug>(grammarous-move-to-next-error)
    nmap <buffer><A-p> <Plug>(grammarous-move-to-previous-error)
endfunction

function! g:grammarous#hooks.on_reset(errs) abort
    nunmap <buffer><A-n>
    nunmap <buffer><A-p>
endfunction

This allows you to use Alt-n and Alt-p to move to the next and previous error.

Does this solve your problem?

Cheers Martin

krishnakumarg1984 commented 5 years ago

I think that perhaps a better solution to this problem is if the author can consider adding a regex to exclude strip \command[always optional args]{possibly optional arguments} from the text before sending to languagetool for grammar checking