Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#+TITLE: LanguageTool layer

#+TAGS: layer|uncategorized
#+TAGS: checker|layer

[[file:img/languagetool.png]]

Expand All @@ -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
Expand All @@ -45,23 +46,37 @@ 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
(setq-default dotspacemacs-configuration-layers
'((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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down