spacemacs/layers/+lang/java/funcs.el
Keith Pinson 4e57eaceea
Remove gradle-mode to stop it breaking bindings of other major modes
After using Java mode, Gradle keybindings infect or even clobber keybindings of
any subsequently used major-mode. For example, the critical Agda major mode
keybinding of `l` as `agda2-load` gets with a Gradle menu!

The cause, found by @duianto, is that `emacs-gradle-mode` sets itself to a
[global](e4d665d578/gradle-mode.el (L176-L183))
minor mode. The docs for `define-minor-mode` say about `:global:`

> If non-nil specifies that the minor mode is not meant to be
> buffer-local, so don't make the variable MODE buffer-local.
> By default, the mode is buffer-local.

I don't know why `gradle-mode` is doing this; presumably there is some reason or
need for it. But the author of that package hasn't been on GitHub since 2017,
and the last update of the package itself is from early 2015.

To seal the deal, `gradle-mode` hasn't been working anyway (at least, I've never
got it to work). I've been running Gradle by launching a terminal within Emacs.

Fixes #13750.
2020-07-18 09:30:35 +02:00

119 lines
3.4 KiB
EmacsLisp
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; funcs.el --- Java functions File for Spacemacs
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: Lukasz Klich <klich.lukasz@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defun spacemacs//java-backend ()
"Returns selected backend."
(if java-backend
java-backend
(cond
((configuration-layer/layer-used-p 'lsp) 'lsp)
(t 'meghanada))))
(defun spacemacs//java-setup-backend ()
"Conditionally setup java backend."
(pcase (spacemacs//java-backend)
(`meghanada (spacemacs//java-setup-meghanada))
(`lsp (spacemacs//java-setup-lsp))))
(defun spacemacs//java-setup-company ()
"Conditionally setup company based on backend."
(pcase (spacemacs//java-backend)
(`meghanada (spacemacs//java-setup-meghanada-company))))
(defun spacemacs//java-setup-dap ()
"Conditionally setup elixir DAP integration."
;; currently DAP is only available using LSP
(pcase (spacemacs//java-backend)
(`lsp (spacemacs//java-setup-lsp-dap))))
(defun spacemacs//java-setup-flycheck ()
"Conditionally setup flycheck based on backend."
(pcase (spacemacs//java-backend)
(`meghanada (spacemacs//java-setup-meghanada-flycheck))
(`lsp (spacemacs//java-setup-lsp-flycheck))))
;; meghanada
(defun spacemacs//java-setup-meghanada ()
"Setup Meghanada."
(require 'meghanada)
;; jump handler
(add-to-list 'spacemacs-jump-handlers
'(meghanada-jump-declaration
:async spacemacs//java-meghanada-server-livep))
;; auto-install meghanada server
(let ((dest-jar (meghanada--locate-server-jar)))
(unless dest-jar
(meghanada-install-server)))
;; enable meghanada
(meghanada-mode))
(defun spacemacs//java-setup-meghanada-company ()
"Setup Meghanada auto-completion."
(meghanada-company-enable))
(defun spacemacs//java-setup-meghanada-flycheck ()
"Setup Meghanada syntax checking."
(when (spacemacs/enable-flycheck 'java-mode)
(require 'flycheck-meghanada)
(add-to-list 'flycheck-checkers 'meghanada)
(flycheck-mode)))
(defun spacemacs//java-meghanada-server-livep ()
"Return non-nil if the Meghanada server is up."
(and meghanada--client-process (process-live-p meghanada--client-process)))
;; Maven
(defun spacemacs/mvn-clean-compile ()
"Recompile using maven."
(interactive)
(mvn-clean)
(mvn-compile))
;; Misc
(defun spacemacs//java-delete-horizontal-space ()
(when (s-matches? (rx (+ (not space)))
(buffer-substring (line-beginning-position) (point)))
(delete-horizontal-space t)))
;; LSP Java
(defun spacemacs//java-setup-lsp ()
"Setup LSP Java."
(if (configuration-layer/layer-used-p 'lsp)
(progn
(require 'lsp-java)
(lsp))
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile.")))
(defun spacemacs//java-setup-lsp-dap ()
"Setup DAP integration."
(require 'dap-java)
(spacemacs/set-leader-keys-for-major-mode 'java-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))
(defun spacemacs//java-setup-lsp-flycheck ()
"Setup LSP Java syntax checking."
(unless (configuration-layer/layer-used-p 'lsp)
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile.")))