diff --git a/layers/+tools/languagetool/README.org b/layers/+checkers/languagetool/README.org similarity index 68% rename from layers/+tools/languagetool/README.org rename to layers/+checkers/languagetool/README.org index 74187ddd242f..b87e7334f694 100644 --- a/layers/+tools/languagetool/README.org +++ b/layers/+checkers/languagetool/README.org @@ -1,6 +1,6 @@ #+TITLE: LanguageTool layer -#+TAGS: layer|uncategorized +#+TAGS: checker|layer [[file:img/languagetool.png]] @@ -25,7 +25,8 @@ To use this configuration layer, add it to your =~/.spacemacs=. You will need to add =languagetool= to the existing =dotspacemacs-configuration-layers= list in this file. You can set the default language by setting ~langtool-default-language~. This value will be used when no custom language has -been set using ~SPC S d~: +been set using ~SPC S d~ (or via variables =ispell-local-dictionary= and +=ispell-dictionary=): #+BEGIN_SRC elisp (setq-default dotspacemacs-configuration-layers @@ -45,10 +46,11 @@ a~ and ~] a~ by setting ~languagetool-show-error-on-jump~: ** LanguageTool LanguageTool and JRE 8+ are required to use this layer. You can install LanguageTool using your system's package manager or by extracting the standalone -archive found on [[https://www.languagetool.org/][LanguageTool's website]]. You can tell the layer where -LanguageTool is installed by setting the =langtool-language-tool-jar= variable -to the location of =languagetool-commandline.jar=, by setting -=langtool-java-classpath=, or setting a host and port for a running server: +archive found on [[https://www.languagetool.org/][LanguageTool's website]]. + +If there is no executable standalone launcher =languagetool= in your PATH +(provided by some distributions, e.g., ArchLinux and Gentoo), [[https://github.com/mhayashi1120/Emacs-langtool#settings-required][setting]] is +required. You can choose one of the following methods: #+BEGIN_SRC elisp ;; Standalone installation @@ -56,12 +58,25 @@ to the location of =languagetool-commandline.jar=, by setting '((languagetool :variables langtool-language-tool-jar "/home/username/languagetool/languagetool-commandline.jar"))) - ;; Classpath (e.g. after installing with `pacman -S languagetool') + ;; Classpath (e.g. ArchLinux) (setq-default dotspacemacs-configuration-layers '((languagetool :variables langtool-java-classpath "/usr/share/languagetool:/usr/share/java/languagetool/*"))) - ;; Server running in background + ;; Executable standalone launcher (e.g. ArchLinux, Gentoo) + (setq-default dotspacemacs-configuration-layers + '((languagetool :variables + langtool-bin "/usr/bin/languagetool"))) + + ;; Standalone installation (run server in background) + ;; This is very fast after listen server, but has security risk if there are multiple user on a same host. + (setq-default dotspacemacs-configuration-layers + '((languagetool :variables + ;; You can change HTTP server port number like following. + ;; langtool-server-user-arguments '("-p" "8081") + langtool-language-tool-server-jar "/path/to/languagetool-server.jar"))) + + ;; Running HTTP LanguageTool server instance on any machine (setq-default dotspacemacs-configuration-layers '((languagetool :variables langtool-http-server-host "localhost" diff --git a/layers/+tools/languagetool/config.el b/layers/+checkers/languagetool/config.el similarity index 100% rename from layers/+tools/languagetool/config.el rename to layers/+checkers/languagetool/config.el diff --git a/layers/+tools/languagetool/funcs.el b/layers/+checkers/languagetool/funcs.el similarity index 84% rename from layers/+tools/languagetool/funcs.el rename to layers/+checkers/languagetool/funcs.el index 845cf4ca31d0..e0a3fe9ee364 100644 --- a/layers/+tools/languagetool/funcs.el +++ b/layers/+checkers/languagetool/funcs.el @@ -53,15 +53,24 @@ (error "LanguageTool has not been set up yet"))) (defun spacemacs//languagetool-detect () - "Detects whether the LanguageTool binary exists." - (cond ((boundp 'langtool-java-classpath) t) + "Detects whether the LanguageTool is set up + or whether the executable file 'languagetool' exists + (and set the corresponding variable as the default)." + (cond ((boundp 'langtool-language-tool-jar) + (or (file-readable-p langtool-language-tool-jar) + (spacemacs-buffer/warning "LanguageTool isn't set up correctly"))) + ((boundp 'langtool-java-classpath) t) + ((boundp 'langtool-bin) + (or (executable-find langtool-bin) + (spacemacs-buffer/warning "LanguageTool isn't set up correctly"))) + ((boundp 'langtool-language-tool-server-jar) + (or (file-readable-p langtool-language-tool-server-jar) + (spacemacs-buffer/warning "LanguageTool isn't set up correctly"))) ((and (boundp 'langtool-http-server-host) (boundp 'langtool-http-server-port)) t) - ((boundp 'langtool-language-tool-jar) - (if (file-readable-p langtool-language-tool-jar) - t - (spacemacs-buffer/warning "LanguageTool binary not found"))) - (t (spacemacs-buffer/warning "LanguageTool binary not set")))) + (t (if-let* ((exe (executable-find "languagetool"))) + (setq langtool-bin exe) + (spacemacs-buffer/warning "LanguageTool isn't set up"))))) (defun spacemacs//languagetool-get-language () "Tries to parse the current spell checking language for a diff --git a/layers/+tools/languagetool/img/languagetool.png b/layers/+checkers/languagetool/img/languagetool.png similarity index 100% rename from layers/+tools/languagetool/img/languagetool.png rename to layers/+checkers/languagetool/img/languagetool.png diff --git a/layers/+tools/languagetool/packages.el b/layers/+checkers/languagetool/packages.el similarity index 100% rename from layers/+tools/languagetool/packages.el rename to layers/+checkers/languagetool/packages.el