-
Make sure you have installed Emacs. Tested version for this tutorial is GNU Emacs 26.3.
-
Download
CogniCryptLSP-0.0.1.jar
andconfig.zip
from https://github.com/MagpieBridge/CryptoLSPDemo/releases, unzipconfig.zip
. -
Edit Emacs initialization file ---
.emacs
by adding the following lines. Change the pathsPATH_TO_JAVA_HOME/bin/java
,PATH_TO/CogniCryptLSP-0.0.1.jar
,PATH_TO/config
to your local paths.
The following lines (1)install the Emacs eglot LSP Client support from MELPA with Emacs the built-in package manager (You can install with the command M-x package-install
ENTER eglot
ENTER alternatively). (2)launch the CogniCryptLSP with Java 1.8, so make sure you have Java 1.8 installed.
;; load emacs 24's package system. Add MELPA repository.
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
'("melpa" . "http://melpa.milkbox.net/packages/")
t))
(package-initialize)
(package-install 'eglot)
(require 'eglot)
(add-hook 'java-mode-hook 'eglot-ensure)
(add-to-list 'eglot-server-programs '(java-mode . ("PATH_TO_JAVA_HOME/bin/java" "-jar" "PATH_TO/CogniCryptLSP-0.0.1.jar" "-c" "PATH_TO/config")))
An example for .emacs
file can be downloaded from here.
- Open a Java File in Emacs will trigger CogniCryptLSP to run. You can use RSA.java to test.
- To rerun CogniCryptLSP in a changed Java File, simply save the file.
Questions? Ask Linghui Luo