1
0
Fork 0
emacs-config/oni-java.el

70 lines
2.2 KiB
EmacsLisp
Raw Normal View History

2019-02-22 08:43:45 +01:00
;;; oni-java.el --- Java configuration -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 20190710075522
2019-06-23 18:33:15 +02:00
;; Package-Requires: (oni-fci oni-data-dir lsp-java company-lsp lsp-ui hydra)
2019-02-22 08:43:45 +01: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 <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Java configuration.
;;; Code:
2019-06-23 18:33:15 +02:00
(require 'hydra)
(require 'lsp-java)
(require 'oni-data-dir)
(defun oni-java-enable-buffer-formatting ()
"Format the buffer before save."
(add-hook 'before-save-hook 'lsp-format-buffer nil :local))
2019-02-22 08:43:45 +01:00
2019-06-11 17:12:01 +02:00
(defun oni-java-only-fill-comments ()
"Set `comment-auto-fill-only-comments' to true locally."
(setq-local comment-auto-fill-only-comments t))
2019-06-23 18:33:15 +02:00
(defhydra java-refactor-hydra (:color blue)
("r" lsp-rename "Rename object")
("m" lsp-java-extract-method "Extract method"))
2019-06-23 18:33:15 +02:00
(setq lsp-java-server-install-dir
(oni-data-dir-locate "lsp-java/server/"))
(setq lsp-java-workspace-dir
(oni-data-dir-locate "lsp-java/workspace/"))
(setq lsp-java-workspace-cache-dir
(oni-data-dir-locate "lsp-java/workspace/cache/"))
2019-06-11 17:12:01 +02:00
(add-hook 'java-mode-hook #'oni-java-enable-buffer-formatting)
(add-hook 'java-mode-hook #'oni-java-only-fill-comments)
(add-hook 'java-mode-hook 'auto-fill-mode)
2019-02-22 08:43:45 +01:00
(add-hook 'java-mode-hook 'electric-indent-local-mode)
2019-06-11 17:12:01 +02:00
(add-hook 'java-mode-hook 'electric-pair-local-mode)
2019-02-22 08:43:45 +01:00
(add-hook 'java-mode-hook 'fci-mode)
(add-hook 'java-mode-hook 'lsp)
2019-02-22 08:43:45 +01:00
(add-to-list 'company-backends 'company-lsp)
2019-02-22 08:43:45 +01:00
2019-06-23 18:33:15 +02:00
(define-key java-mode-map (kbd "C-c r") 'java-refactor-hydra/body)
2019-02-22 08:43:45 +01:00
;;;###autoload(with-eval-after-load 'cc-mode (require 'oni-java))
(provide 'oni-java)
;;; oni-java.el ends here