* Tree-sitter
#+begin_src emacs-lisp
(require 'java-ts-mode)
(push '(java-mode . java-ts-mode) major-mode-remap-alist)
#+end_src
- selections:
- expreg
- expand-region (er/...)
* Folding
* Language Server
Although there are 3 language servers for Java listed on https://langserver.org/,
installation on Linux is a pain and on Windows I was not able to get it working.
* Gnu Global
I consider a better alternative to a language-server to be the use of
Gnu Global (explicit support for Java) or ctags.
The use of CEDET/EDE/senator/semantic-db was avoided because of the complexity it
introduces.
#+begin_src emacs-lisp
(require 'ggtags)
#+end_src
* Snippets
Additional YaSnippets
#+begin_src emacs-lisp
(use-package java-snippets)
#+end_src
* Linting
** Syntax Check
Use Checkstyle with sun-rules.
#+begin_src emacs-lisp
(require 'flycheck)
(flycheck-define-checker java-checkstyle
" a java checker "
:command ("java"
"-jar"
(eval (concat emacsen-dir "java\\checkstyle-9.0.1-all.jar"))
"-c" "sun_checks.xml"
"-f" "xml"
source)
:error-parser flycheck-parse-checkstyle
;; :standard-input
:modes (java-mode java-ts-mode)
)
#+end_src
* Konfiguration
#+begin_src emacs-lisp
(use-package java-ts-mode
:ensure nil
:config
(defun my/java-mode-hook ()
(add-to-list 'completion-at-point-functions #'ggtags-completion-at-point)
)
:bind (
:map java-ts-mode-map
("C-+" . expreg-expand)
("C--" . expreg-contract)
("C-c f" . er/mark-defun)
)
:hook
(java-ts-mode . my/java-mode-hook)
(java-ts-mode . ggtags-mode)
(java-ts-mode . flycheck-mode)
(java-ts-mode . yas-minor-mode)
(java-ts-mode . eldoc-mode)
)
#+end_src
* Mayor Mode Hydra
#+begin_src emacs-lisp
#+end_src
"+" '(yas-insert-snippet :wk "code snippets")
"l" '(flycheck-list-errors :wk "linter window")
;; try combobulate - ts-movement mode not useful
"b" '(:ignore t :which-key "TODO: build/run/debug")
"t" '(:ignore t :which-key "tags")
"tf" '(ggtags-find-tag :wk "find tag")
"tF" '(ggtags-find-tag-dwim :wk "find tag dwim")
"t$" '(ggtags-find-tag-regexp :wk "find tag regexp")
"td" '(ggtags-find-definition :wk "find definition")
"tr" '(ggtags-find-reference :wk "find reference")
"tg" '(ggtags-grep :wk "search db")
"t%" '(ggtags-query-replace :wk "replace")
"tu" '(ggtags-update-tags :wk "update db")
"d" '(:ignore t :which-key "doc")
"s" '(:ignore t :which-key "mark/select")
;; make this a hydra
"sp" '(mark-paragraph :wk "paragraph")
"sf" '(er/mark-defun :wk "function")
"ss" '(er/mark-symbol-with-prefix :wk "symbol")
"s+" '(expreg-expand :wk "expand region")
"s-" '(expreg-contract :wk "unexpand region")
)