2015-05-20 21:06:46 +00:00
|
|
|
;;; packages.el --- Java Layer packages File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 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.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-05-20 21:06:46 +00:00
|
|
|
|
2020-05-16 21:32:30 +00:00
|
|
|
(defconst java-packages
|
|
|
|
'(
|
|
|
|
company
|
|
|
|
dap-mode
|
|
|
|
flycheck
|
|
|
|
ggtags
|
|
|
|
counsel-gtags
|
|
|
|
helm-gtags
|
|
|
|
(java-mode :location built-in)
|
|
|
|
maven-test-mode
|
|
|
|
(meghanada :toggle (not (version< emacs-version "25.1")))
|
|
|
|
mvn
|
|
|
|
(lsp-java :requires lsp-mode)
|
|
|
|
org
|
|
|
|
smartparens))
|
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 ()
|
2021-03-18 04:16:40 +00:00
|
|
|
(when (eq java-backend 'lsp)
|
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'java-mode))
|
2020-05-16 21:32:30 +00:00
|
|
|
(add-hook 'java-mode-local-vars-hook #'spacemacs//java-setup-dap))
|
2019-09-30 01:30:53 +00:00
|
|
|
|
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
|
|
|
|
2019-11-27 06:25:59 +00:00
|
|
|
(defun java/post-init-smartparens ()
|
|
|
|
(with-eval-after-load 'smartparens
|
|
|
|
(sp-local-pair 'java-mode "/** " " */" :trigger "/**")))
|
|
|
|
|
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
|
2020-01-04 12:34:38 +00:00
|
|
|
"mga" 'maven-test-toggle-between-test-and-class
|
|
|
|
"mgA" 'maven-test-toggle-between-test-and-class-other-window
|
|
|
|
"mta" 'maven-test-all
|
|
|
|
"mt C-a" 'maven-test-clean-test-all
|
|
|
|
"mtb" 'maven-test-file
|
|
|
|
"mti" 'maven-test-install
|
|
|
|
"mtt" 'maven-test-method))))
|
2017-12-17 23:39:55 +00:00
|
|
|
|
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
|
2021-03-18 04:16:40 +00:00
|
|
|
:if (eq java-backend 'lsp)
|
2018-08-21 18:47:48 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; key bindings
|
2020-01-04 14:48:20 +00:00
|
|
|
(dolist (prefix '(("ma" . "actionable")
|
|
|
|
("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
|
2021-02-28 11:10:44 +00:00
|
|
|
"raF" 'lsp-java-assign-statement-to-field
|
|
|
|
"ral" 'lsp-java-assign-statement-to-local
|
2019-05-12 10:37:48 +00:00
|
|
|
|
|
|
|
;; 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-12-29 09:42:00 +00:00
|
|
|
"an" 'lsp-java-actionable-notifications))))
|
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))))
|