emacs-languagetool / flycheck-languagetool

Flycheck support for LanguageTool
GNU General Public License v3.0
55 stars 9 forks source link

[WiP] Added a prog mode to flycheck-languagetool #25

Open mattiasdrp opened 2 years ago

mattiasdrp commented 2 years ago

This is done by filtering out the errors that don't point to a place that has not a comment, a string or a doc face. The checker is added as the next checker of the main flycheck checker for the current mode

I still have some issues as to when the function flycheck-languagetool-flycheck-enable has to be used

In my current setup what I did is:

  (use-package flycheck-languagetool
    :load-path "lisp/flycheck-languagetool/"
    ;; :custom ((flycheck-languagetool-active-modes
    ;;           '(text-mode latex-mode org-mode markdown-mode message-mode prog-mode)))
    :hook ((text-mode . flycheck-languagetool-setup)
           (lsp-mode . (lambda () (lsp-diagnostics-mode 1)
                         (require 'flycheck-languagetool)
                         (flycheck-languagetool-flycheck-enable))))
    ;; :ensure-system-package
    ;;   ("LanguageTool-5.9-stable/languagetool-commandline.jar" . "curl -L https://raw.githubusercontent.com/languagetool-org/languagetool/master/install.sh | sudo bash -a")
    :init
    (setq flycheck-languagetool-server-jar (expand-file-name "~/.emacs.d/LanguageTool-5.9-stable/languagetool-server.jar"))
    )

But this is not really good.

The issue is that if languagetool is added as a checker before the main-mode finished loading, it's not added as a next checker for the main one and the function needs to be called again.

Fixes #22

If this seems good for you, I think an improvement would be to define a predicate function

This would allow to define different predicates for different modes (prog-mode don't have the same predicates as org-mode or markdown-mode for example)