torik42 / YaLafi

Yet another LaTeX filter
GNU General Public License v3.0
68 stars 12 forks source link

Emacs flycheck checker for yalafi #206

Open soli opened 3 years ago

soli commented 3 years ago

Not an issue per se but a suggestion: there's a simple way to get a flycheck (more or less emacs equivalent of ALE for vim) spell/grammar-checker with yalafi as follows.

Just add to your .emacs the following snippet (that I may, one day, try to push to flycheck's repo)

  (flycheck-define-checker tex-yalafi
    "A LaTeX grammar/spelling checker using languagetool and yalafi.

    See https://github.com/matze-dd/YaLafi"
    :modes (latex-mode plain-tex-mode)
    :command ("python3" "-m" "yalafi.shell" "--lt-command" "languagetool" source)
    :error-patterns ((warning line-start "=== " (file-name) " ===\n"
                              (one-or-more digit) ".) Line " line ", column " column
                              ", Rule ID: " (id (one-or-more (any "A-Z_")) (optional "[" (one-or-more digit)"]")) "\n"
                              "Message: " (message) line-end))
    :enabled (lambda () (and
                         (flycheck-python-find-module 'tex-yalafi "yalafi.shell")
                         (executable-find "languagetool")))
    :verify (lambda (_) (flycheck-python-verify-module 'tex-yalafi "yalafi.shell")))
  (add-to-list 'flycheck-checkers 'tex-yalafi t)
  (flycheck-add-next-checker 'tex-chktex 'tex-yalafi)

This should work directly (no shell script involved, no package dependency except flycheck). Didn't try to get a sever-based version to work (I just have the CLI version).

If you want I can make a pull request to the README, but I guess you can just add it as you like…

enikko commented 2 years ago

There’s already a flycheck module for language languagetool for emacs: https://github.com/emacs-languagetool/flycheck-languagetool

Would be nice to see if one could simply integrate this tool into that module (by making it language-aware to some extent).

soli commented 2 years ago

Sorry but I have no idea how one would do that… you can open an Issue there, but that's far beyond my emacs-lisp knowledge (which is very limited).

enikko commented 2 years ago

Nothing to be sorry for :)

just threw my two cents in. Hopefully, a module will be updated in the future.