2015-05-20 21:06:46 +00:00
|
|
|
;;; packages.el --- Java Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-05-20 21:06:46 +00:00
|
|
|
;;
|
|
|
|
;; Author: Lukasz Klich <klich.lukasz@gmail.com>
|
2016-01-12 02:40:54 +00:00
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
2015-05-20 21:06:46 +00:00
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2016-01-18 03:06:04 +00:00
|
|
|
(setq java-packages
|
|
|
|
'(
|
2017-02-09 22:22:38 +00:00
|
|
|
company
|
2019-09-30 01:30:53 +00:00
|
|
|
dap-mode
|
2017-02-09 22:22:38 +00:00
|
|
|
flycheck
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
2017-02-09 22:20:56 +00:00
|
|
|
gradle-mode
|
2017-08-26 21:18:09 +00:00
|
|
|
counsel-gtags
|
2016-04-05 04:08:34 +00:00
|
|
|
helm-gtags
|
2017-02-09 21:45:27 +00:00
|
|
|
(java-mode :location built-in)
|
2017-12-17 23:39:55 +00:00
|
|
|
maven-test-mode
|
2017-02-09 22:22:38 +00:00
|
|
|
(meghanada :toggle (not (version< emacs-version "25.1")))
|
2017-12-17 23:39:55 +00:00
|
|
|
mvn
|
2019-11-03 04:01:13 +00:00
|
|
|
(lsp-java :requires lsp-mode)
|
2018-05-30 13:07:21 +00:00
|
|
|
org
|
2017-02-09 21:45:27 +00:00
|
|
|
))
|
2015-05-20 21:06:46 +00:00
|
|
|
|
2017-02-09 22:22:38 +00:00
|
|
|
(defun java/post-init-company ()
|
|
|
|
(add-hook 'java-mode-local-vars-hook #'spacemacs//java-setup-company))
|
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun java/pre-init-dap-mode ()
|
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'java-mode)
|
|
|
|
(add-hook 'java-mode-local-vars-hook #'spacemacs//java-setup-lsp-dap))
|
|
|
|
|
2017-02-09 22:22:38 +00:00
|
|
|
(defun java/post-init-flycheck ()
|
|
|
|
(add-hook 'java-mode-local-vars-hook #'spacemacs//java-setup-flycheck))
|
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun java/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'java-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2017-02-09 22:20:56 +00:00
|
|
|
(defun java/init-gradle-mode ()
|
|
|
|
(use-package gradle-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-12-17 23:39:55 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(when (configuration-layer/package-used-p 'groovy-mode)
|
|
|
|
(add-hook 'groovy-mode-hook 'gradle-mode)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'groovy-mode "ml" "gradle")
|
2019-02-27 15:23:19 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'groovy-mode "mlc" "compile")
|
2017-12-17 23:39:55 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'groovy-mode "mlt" "tests"))
|
|
|
|
(when (configuration-layer/package-used-p 'java-mode)
|
|
|
|
(add-hook 'java-mode-hook 'gradle-mode)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "ml" "gradle")
|
2019-02-27 15:23:19 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "mlc" "compile")
|
2017-12-17 23:39:55 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "mlt" "tests")))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter gradle-mode)
|
|
|
|
(spacemacs/set-leader-keys-for-minor-mode 'gradle-mode
|
|
|
|
"lcc" 'gradle-build
|
|
|
|
"lcC" 'spacemacs/gradle-clean
|
|
|
|
"lcr" 'spacemacs/gradle-clean-build
|
|
|
|
"lta" 'gradle-test
|
|
|
|
"ltb" 'spacemacs/gradle-test-buffer
|
|
|
|
"ltt" 'gradle-single-test
|
|
|
|
"lx" 'gradle-execute))))
|
2017-02-09 22:20:56 +00:00
|
|
|
|
2017-08-26 21:18:09 +00:00
|
|
|
(defun java/post-init-counsel-gtags ()
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'java-mode))
|
|
|
|
|
2018-07-24 15:21:58 +00:00
|
|
|
(defun java/post-init-helm-gtags ()
|
2016-04-05 04:08:34 +00:00
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'java-mode))
|
|
|
|
|
2018-05-30 13:07:21 +00:00
|
|
|
(defun java/pre-init-org ()
|
|
|
|
(spacemacs|use-package-add-hook org
|
|
|
|
:post-config (add-to-list 'org-babel-load-languages '(java . t))))
|
|
|
|
|
2016-04-03 04:12:28 +00:00
|
|
|
(defun java/init-java-mode ()
|
2017-02-09 22:22:22 +00:00
|
|
|
(use-package java-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-02-09 22:22:22 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-hook 'java-mode-local-vars-hook #'spacemacs//java-setup-backend)
|
2019-09-18 20:00:05 +00:00
|
|
|
(put 'java-backend 'safe-local-variable 'symbolp))))
|
2017-02-09 22:22:22 +00:00
|
|
|
|
2017-12-17 23:39:55 +00:00
|
|
|
(defun java/init-maven-test-mode ()
|
|
|
|
(use-package maven-test-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-12-17 23:39:55 +00:00
|
|
|
:init
|
|
|
|
(when (configuration-layer/package-used-p 'java-mode)
|
|
|
|
(add-hook 'java-mode-hook 'maven-test-mode)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "mm" "maven")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "mmg" "goto")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "mmt" "tests"))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter maven-test-mode)
|
|
|
|
(spacemacs/set-leader-keys-for-minor-mode 'maven-test-mode
|
|
|
|
"mga" 'maven-test-toggle-between-test-and-class
|
|
|
|
"mgA" 'maven-test-toggle-between-test-and-class-other-window
|
|
|
|
"mta" 'maven-test-all
|
|
|
|
"mtC-a" 'maven-test-clean-test-all
|
|
|
|
"mtb" 'maven-test-file
|
|
|
|
"mti" 'maven-test-install
|
|
|
|
"mtt" 'maven-test-method))))
|
|
|
|
|
2017-02-09 22:22:38 +00:00
|
|
|
(defun java/init-meghanada ()
|
|
|
|
(use-package meghanada
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2019-04-14 07:34:52 +00:00
|
|
|
:if (eq java-backend 'meghanada)
|
2017-02-09 22:22:38 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq meghanada-server-install-dir (concat spacemacs-cache-directory
|
|
|
|
"meghanada/")
|
|
|
|
company-meghanada-prefix-length 1
|
|
|
|
;; let spacemacs handle company and flycheck itself
|
|
|
|
meghanada-use-company nil
|
|
|
|
meghanada-use-flycheck nil))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; key bindings
|
2017-04-13 21:01:22 +00:00
|
|
|
(dolist (prefix '(("mc" . "compile")
|
2017-02-09 22:22:38 +00:00
|
|
|
("mD" . "daemon")
|
|
|
|
("mg" . "goto")
|
|
|
|
("mr" . "refactor")
|
|
|
|
("mt" . "test")
|
|
|
|
("mx" . "execute")))
|
|
|
|
(spacemacs/declare-prefix-for-mode
|
2019-04-14 07:34:52 +00:00
|
|
|
'java-mode (car prefix) (cdr prefix)))
|
2017-02-09 22:22:38 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'java-mode
|
|
|
|
"cb" 'meghanada-compile-file
|
|
|
|
"cc" 'meghanada-compile-project
|
|
|
|
|
|
|
|
"Dc" 'meghanada-client-direct-connect
|
|
|
|
"Dd" 'meghanada-client-disconnect
|
|
|
|
"Di" 'meghanada-install-server
|
|
|
|
"Dk" 'meghanada-server-kill
|
|
|
|
"Dl" 'meghanada-clear-cache
|
|
|
|
"Dp" 'meghanada-ping
|
|
|
|
"Dr" 'meghanada-restart
|
|
|
|
"Ds" 'meghanada-client-connect
|
|
|
|
"Du" 'meghanada-update-server
|
|
|
|
"Dv" 'meghanada-version
|
|
|
|
|
|
|
|
"gb" 'meghanada-back-jump
|
|
|
|
|
|
|
|
"=" 'meghanada-code-beautify
|
|
|
|
"ri" 'meghanada-optimize-import
|
|
|
|
"rI" 'meghanada-import-all
|
|
|
|
|
|
|
|
"ta" 'meghanada--run-junit
|
|
|
|
"tc" 'meghanada-run-junit-class
|
|
|
|
"tl" 'meghanada-run-junit-recent
|
|
|
|
"tt" 'meghanada-run-junit-test-case
|
|
|
|
|
|
|
|
;; meghanada-switch-testcase
|
|
|
|
;; meghanada-local-variable
|
|
|
|
|
|
|
|
"x:" 'meghanada-run-task))))
|
2017-12-17 23:39:55 +00:00
|
|
|
|
2018-08-21 18:47:48 +00:00
|
|
|
(defun java/init-lsp-java ()
|
|
|
|
(use-package lsp-java
|
|
|
|
:defer t
|
2019-11-18 05:57:09 +00:00
|
|
|
:if (eq (spacemacs//java-backend) 'lsp)
|
2018-08-21 18:47:48 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; key bindings
|
2019-05-12 10:37:48 +00:00
|
|
|
(dolist (prefix '(("mc" . "compile/create")
|
2018-08-21 18:47:48 +00:00
|
|
|
("mg" . "goto")
|
|
|
|
("mr" . "refactor")
|
2019-05-12 10:37:48 +00:00
|
|
|
("mra" . "add/assign")
|
|
|
|
("mrc" . "create/convert")
|
|
|
|
("mrg" . "generate")
|
2019-02-27 15:23:19 +00:00
|
|
|
("mre" . "extract")
|
2019-09-18 20:13:24 +00:00
|
|
|
("mp" . "project")
|
2019-02-27 15:23:19 +00:00
|
|
|
("mq" . "lsp")
|
|
|
|
("mt" . "test")
|
|
|
|
("mx" . "execute")))
|
|
|
|
(spacemacs/declare-prefix-for-mode
|
|
|
|
'java-mode (car prefix) (cdr prefix)))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'java-mode
|
2019-09-18 20:13:24 +00:00
|
|
|
"pu" 'lsp-java-update-project-configuration
|
2019-05-12 10:37:48 +00:00
|
|
|
|
|
|
|
;; refactoring
|
2019-02-27 15:23:19 +00:00
|
|
|
"ro" 'lsp-java-organize-imports
|
|
|
|
"rcp" 'lsp-java-create-parameter
|
|
|
|
"rcf" 'lsp-java-create-field
|
2019-05-12 10:37:48 +00:00
|
|
|
"rci" 'lsp-java-conver-to-static-import
|
2019-02-27 15:23:19 +00:00
|
|
|
"rec" 'lsp-java-extract-to-constant
|
|
|
|
"rel" 'lsp-java-extract-to-local-variable
|
|
|
|
"rem" 'lsp-java-extract-method
|
2019-05-12 10:37:48 +00:00
|
|
|
|
|
|
|
;; assign/add
|
|
|
|
"rai" 'lsp-java-add-import
|
|
|
|
"ram" 'lsp-java-add-unimplemented-methods
|
|
|
|
"rat" 'lsp-java-add-throws
|
|
|
|
"raa" 'lsp-java-assign-all
|
|
|
|
"raf" 'lsp-java-assign-to-field
|
|
|
|
|
|
|
|
;; generate
|
|
|
|
"rgt" 'lsp-java-generate-to-string
|
|
|
|
"rge" 'lsp-java-generate-equals-and-hash-code
|
|
|
|
"rgo" 'lsp-java-generate-overrides
|
|
|
|
"rgg" 'lsp-java-generate-getters-and-setters
|
|
|
|
|
|
|
|
;; create/compile
|
2019-02-27 15:23:19 +00:00
|
|
|
"cc" 'lsp-java-build-project
|
2019-05-12 10:37:48 +00:00
|
|
|
"cp" 'lsp-java-spring-initializr
|
|
|
|
|
2019-02-27 15:23:19 +00:00
|
|
|
"an" 'lsp-java-actionable-notifications
|
|
|
|
|
|
|
|
;; dap-mode
|
|
|
|
|
|
|
|
;; debug
|
|
|
|
"ddj" 'dap-java-debug
|
|
|
|
"dtt" 'dap-java-debug-test-method
|
|
|
|
"dtc" 'dap-java-debug-test-class
|
|
|
|
;; run
|
|
|
|
"tt" 'dap-java-run-test-method
|
|
|
|
"tc" 'dap-java-run-test-class)
|
|
|
|
|
|
|
|
(setq lsp-highlight-symbol-at-point nil
|
|
|
|
lsp-ui-sideline-update-mode 'point
|
|
|
|
lsp-eldoc-render-all nil
|
|
|
|
lsp-java-completion-guess-arguments t))))
|
2018-08-21 18:47:48 +00:00
|
|
|
|
2017-12-17 23:39:55 +00:00
|
|
|
(defun java/init-mvn ()
|
|
|
|
(use-package mvn
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-12-17 23:39:55 +00:00
|
|
|
:init
|
|
|
|
(when (configuration-layer/package-used-p 'java-mode)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "mm" "maven")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'java-mode "mmc" "compile")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'java-mode
|
|
|
|
"mcc" 'mvn-compile
|
|
|
|
"mcC" 'mvn-clean
|
|
|
|
"mcr" 'spacemacs/mvn-clean-compile))))
|