Table of Contents

1. From vanilla Emacs to Java IDE in 5 minutes

1.1. DONE Set up package manager

(condition-case nil
    (require 'use-package)
   (require 'package)
   (add-to-list 'package-archives '("melpa" . ""))
   (package-install 'use-package)
   (setq use-package-always-ensure t)
   (require 'use-package)))

1.2. DONE Font & theme

 :family "Source Code Pro"
 :height 150
 :weight 'medium
 :width 'normal)
(use-package sweet-theme :ensure t :init (load-theme 'sweet t))

1.3. DONE Show shortcuts

(load "/usr/local/src/interaction-log.el/interaction-log.el")

1.4. TODO Install lsp-java & dap-java

(use-package projectile)
(use-package flycheck)
(use-package yasnippet :config (yas-global-mode))
(use-package lsp-mode :hook ((lsp-mode . lsp-enable-which-key-integration))
  :config (setq lsp-completion-enable-additional-text-edit nil))
(use-package hydra)
(use-package company)
(use-package lsp-ui)
(use-package which-key :config (which-key-mode))
(use-package lsp-java :config (add-hook 'java-mode-hook 'lsp))
(use-package dap-mode :after lsp-mode :config (dap-auto-configure-mode))
(use-package dap-java :ensure nil)
(use-package helm-lsp)
(use-package helm
  :config (helm-mode))
(use-package lsp-treemacs)

1.5. TODO Project navigation

(use-package projectile
    :ensure t
    :init (projectile-mode +1)
        (kbd "C-c p")

1.6. TODO Git integration

(use-package magit)

1.7. TODO gitignore to exclude target

1.8. TODO Build project

1.9. TODO Fix errors and warnings

1.10. TODO Fancy GUI is there if you want it

1.11. TODO Run JUnit test

1.12. TODO Fix compile escape codes

(add-hook 'compilation-filter-hook
          (lambda () (ansi-color-apply-on-region (point-min) (point-max))))

1.13. TODO Debug JUnit test

1.14. TODO IDEA style shortcuts

(use-package lsp-mode
    (:map lsp-mode-map
          (("\C-\M-b" . lsp-find-implementation)
           ("M-RET" . lsp-execute-code-action))))

(use-package dap-java
  :ensure nil
  :after (lsp-java)

  (global-set-key (kbd "<f7>") 'dap-step-in)
  (global-set-key (kbd "<f8>") 'dap-next)
  (global-set-key (kbd "<f9>") 'dap-continue))  

1.15. TODO Create code snippets

1.16. TODO My Java mode hook

(defun my-java-mode-hook ()
  (set-fringe-style '(8 . 0))
  (define-key c-mode-base-map (kbd "C-M-j") 'tkj-insert-serial-version-uuid)
  (define-key c-mode-base-map (kbd "C-m") 'c-context-line-break)
  (define-key c-mode-base-map (kbd "S-<f7>") 'gtags-find-tag-from-here)

  ;; Fix indentation for anonymous classes
  (c-set-offset 'substatement-open 0)
  (if (assoc 'inexpr-class c-offsets-alist)
      (c-set-offset 'inexpr-class 0))

  ;; Indent arguments on the next line as indented body.
  (c-set-offset 'arglist-intro '++))
(add-hook 'java-mode-hook 'my-java-mode-hook)  

1.17. TODO If your Emacs Java setup isn't working

Author: Torstein Krause Johansen

Created: 2022-05-17 Tue 18:57