Created
May 11, 2020 03:55
-
-
Save twlz0ne/b4612f5bba2903c8d21f77f9905e2f5f to your computer and use it in GitHub Desktop.
Test jdtls installation #Emacs #LSP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; test-lsp-jdtls-installation.el --- Test lsp jdtls installation -*- lexical-binding: t; -*- | |
;;; Date: 2020-05-11_09.12.50 | |
;;; Usage: | |
;; ┌──── | |
;; │ $ emacs -nw -Q -l \ | |
;; │ --eval '(setq with-proxy-http-server "127.0.0.1:XXXX")' \ | |
;; │ /path/to/test-lsp-jdtls-installation.el | |
;; └──── | |
(toggle-debug-on-error) | |
(setq user-emacs-directory (format "~/.emacs.d/%s/%s/" (file-name-base load-file-name) emacs-version)) | |
;; ------------------------------------------------------------------ | |
;; elpa | |
(setq package-user-dir (concat user-emacs-directory "elpa/")) | |
(unless (load "~/.emacs.d/elpa.el" t) | |
(setq package-archives | |
'(("gnu" . "https://elpa.gnu.org/packages/") | |
("melpa" . "https://melpa.org/packages/")))) | |
(package-initialize) | |
(defun require-packages (&rest packages) | |
(dolist (pkg packages) | |
(unless (package-installed-p pkg) | |
(package-refresh-contents) | |
(package-install pkg)) | |
(require pkg))) | |
;; ------------------------------------------------------------------ | |
;; steps | |
(require-packages | |
'lsp-mode | |
'lsp-java | |
'with-proxy) | |
(defvar lsp-install-server-default nil) | |
(define-advice lsp-install-server (:around (fn update?) default-no-select) | |
(interactive "P") | |
(if lsp-install-server-default | |
(lsp--install-server-internal | |
(->> lsp-clients | |
(ht-values) | |
(--map | |
(when (string= lsp-install-server-default | |
(funcall (-compose | |
#'symbol-name | |
#'lsp--client-server-id) | |
it)) | |
it)) | |
(-non-nil) | |
(-first-item)) | |
t) | |
(funcall fn update?))) | |
(add-hook 'after-init-hook | |
(lambda () | |
(require 'lsp) | |
(require 'lsp-java) | |
(with-temp-buffer | |
(java-mode) | |
(let ((lsp-install-server-default "jdtls")) | |
(with-proxy | |
(display-buffer | |
(process-buffer | |
(call-interactively 'lsp-install-server)))))))) | |
(run-hooks 'after-init-hook) | |
;;; test-lsp-jdtls-installation.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment