2022-05-24 02:40:57 +02:00
|
|
|
;;; GNU/EMACS --- Rawley Fowler's init.el.
|
2022-05-21 22:33:15 +02:00
|
|
|
;; I was a long time Vim user. But emacs stole my heart.
|
2022-05-24 02:40:57 +02:00
|
|
|
|
|
|
|
;;; Code:
|
2022-05-29 02:17:33 +02:00
|
|
|
;; Borrowed this from https://github.com/aaronbieber/dotfiles/blob/master/configs/emacs.d/init.el
|
|
|
|
(setq initial-scratch-message
|
|
|
|
(concat
|
|
|
|
";; This buffer is for text that is not saved, and for Lisp evaluation.\n"
|
|
|
|
";; To create a file, visit it with C-x C-f and enter text in its buffer.\n"
|
|
|
|
";;\n"
|
|
|
|
";; __ __ _ \n"
|
|
|
|
";; \\ \\ / / | | \n"
|
|
|
|
";; \\ \\ /\\ / /__| | ___ ___ _ __ ___ ___ \n"
|
|
|
|
";; \\ \\/ \\/ / _ \\ |/ __/ _ \\| '_ ` _ \\ / _ \\ \n"
|
|
|
|
";; \\ /\\ / __/ | (_| (_) | | | | | | __/_ \n"
|
|
|
|
";; \\/ \\/ \\___|_|\\___\\___/|_| |_| |_|\\___(_)\n"))
|
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
(when (version<= "26.0.50" emacs-version)
|
|
|
|
(global-display-line-numbers-mode)) ;; Line numbers
|
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
2022-05-26 22:31:09 +02:00
|
|
|
(add-to-list 'default-frame-alist '(fullscreen . maximized))
|
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
;; Backups
|
|
|
|
(setq backup-directory-alist
|
|
|
|
`((".*" . ,temporary-file-directory)))
|
|
|
|
(setq auto-save-file-name-transforms
|
|
|
|
`((".*" ,temporary-file-directory t)))
|
|
|
|
|
|
|
|
;; Disabling bars
|
|
|
|
(menu-bar-mode -1)
|
|
|
|
(scroll-bar-mode -1)
|
|
|
|
(tool-bar-mode -1)
|
|
|
|
|
|
|
|
;; UTF-8 and spacing
|
|
|
|
(set-language-environment "UTF-8")
|
|
|
|
(set-terminal-coding-system 'utf-8)
|
|
|
|
(set-keyboard-coding-system 'utf-8)
|
|
|
|
(set-selection-coding-system 'utf-8)
|
|
|
|
(prefer-coding-system 'utf-8)
|
|
|
|
(transient-mark-mode)
|
|
|
|
(show-paren-mode 1)
|
|
|
|
|
|
|
|
(setq font-lock-maximum-decoration t)
|
|
|
|
(setq-default indent-tabs-mode nil)
|
|
|
|
(setq tab-width 4)
|
|
|
|
(setq c-basic-offset 4)
|
2022-05-24 02:54:48 +02:00
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
;;;; Package management
|
|
|
|
(require 'package)
|
|
|
|
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
|
|
|
|
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
|
|
|
|
(package-initialize)
|
|
|
|
|
|
|
|
(unless (package-installed-p 'use-package)
|
|
|
|
(package-refresh-contents)
|
|
|
|
(package-install 'use-package))
|
|
|
|
|
|
|
|
(eval-and-compile
|
|
|
|
(setq use-package-always-ensure t
|
|
|
|
use-package-expand-minimally t))
|
|
|
|
|
|
|
|
(require 'use-package)
|
|
|
|
|
|
|
|
;;;; Packages.
|
|
|
|
;; EVIL!!!
|
|
|
|
(use-package evil
|
|
|
|
:ensure t ;; Install evil if not installed
|
|
|
|
:init ;; Tweak the config before loading it
|
|
|
|
(setq evil-want-integration t)
|
|
|
|
(setq evil-want-keybinding nil)
|
|
|
|
(setq evil-vsplit-window-right t)
|
|
|
|
(setq evil-split-window-below t)
|
|
|
|
(evil-mode))
|
2022-05-28 19:09:24 +02:00
|
|
|
|
2022-05-29 02:17:33 +02:00
|
|
|
(defun selective-window-kill ()
|
2022-05-29 02:51:51 +02:00
|
|
|
(interactive)
|
|
|
|
(when (> (count-windows) 1)
|
2022-05-29 02:17:33 +02:00
|
|
|
(delete-window)))
|
|
|
|
|
2022-05-29 02:51:51 +02:00
|
|
|
(defun save-kill-buffer () ;; Saves and kills a buffer, vim style
|
2022-05-28 19:03:05 +02:00
|
|
|
(interactive)
|
|
|
|
(save-buffer)
|
2022-05-29 02:17:33 +02:00
|
|
|
(selective-window-kill))
|
2022-05-28 19:09:24 +02:00
|
|
|
|
2022-05-28 19:03:05 +02:00
|
|
|
(evil-ex-define-cmd "wq" 'save-and-kill-buffer)
|
2022-05-29 02:51:51 +02:00
|
|
|
(evil-ex-define-cmd "q" 'selective-window-kill)
|
|
|
|
(evil-ex-define-cmd "kb" '(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(kill-buffer-and-window)))
|
2022-05-28 19:09:24 +02:00
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
(use-package evil-collection
|
|
|
|
:after evil
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(evil-collection-init))
|
|
|
|
|
2022-05-29 02:51:51 +02:00
|
|
|
(use-package evil-org)
|
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
;; Project mangement
|
|
|
|
(use-package projectile
|
|
|
|
:config
|
|
|
|
(projectile-mode +1)
|
|
|
|
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map))
|
|
|
|
|
2022-05-22 18:30:17 +02:00
|
|
|
(use-package hydra)
|
|
|
|
|
2022-05-23 02:58:05 +02:00
|
|
|
;; Treemacs
|
2022-05-22 18:30:17 +02:00
|
|
|
(use-package lsp-treemacs)
|
|
|
|
(use-package treemacs
|
2022-05-23 02:58:05 +02:00
|
|
|
:ensure t
|
|
|
|
:defer t
|
2022-05-21 22:33:15 +02:00
|
|
|
:config
|
2022-05-23 02:58:05 +02:00
|
|
|
(progn
|
|
|
|
(setq treemacs-display-in-side-window t
|
|
|
|
treemacs-follow-after-init t
|
|
|
|
treemacs-expand-after-init t
|
|
|
|
treemacs-indentation 2
|
|
|
|
treemacs-hide-dot-git-directory t
|
|
|
|
treemacs-indentation-string " "
|
|
|
|
treemacs-max-git-entries 5000
|
|
|
|
treemacs-width 40
|
|
|
|
treemacs-width-increment 1
|
|
|
|
treemacs-width-is-initially-locked t))
|
|
|
|
:bind
|
|
|
|
(:map global-map
|
2022-05-24 02:40:57 +02:00
|
|
|
("C-x w s" . treemacs-select-window)
|
2022-05-23 02:58:05 +02:00
|
|
|
("C-x w 1" . treemacs-delete-other-windows)
|
2022-05-24 02:40:57 +02:00
|
|
|
("C-x w w" . treemacs)))
|
2022-05-24 02:54:48 +02:00
|
|
|
|
2022-05-23 02:58:05 +02:00
|
|
|
(require 'treemacs)
|
|
|
|
(treemacs-follow-mode t)
|
|
|
|
(treemacs-filewatch-mode t)
|
|
|
|
(treemacs-fringe-indicator-mode 'always)
|
|
|
|
(treemacs-git-mode 'simple)
|
|
|
|
(define-key treemacs-mode-map [mouse-1] #'treemacs-single-click-expand-action)
|
|
|
|
(use-package treemacs-evil
|
|
|
|
:after (treemacs evil)
|
|
|
|
:ensure t)
|
|
|
|
(use-package treemacs-projectile
|
|
|
|
:after (treemacs projectile)
|
|
|
|
:ensure t)
|
2022-05-21 22:33:15 +02:00
|
|
|
|
|
|
|
;; Icons
|
|
|
|
(use-package all-the-icons
|
|
|
|
:if (display-graphic-p))
|
|
|
|
|
|
|
|
;; Ivy
|
|
|
|
(use-package ivy)
|
|
|
|
(use-package counsel)
|
|
|
|
(use-package swiper)
|
|
|
|
|
|
|
|
(require 'ivy)
|
|
|
|
(ivy-mode 1)
|
|
|
|
(setq ivy-use-virtual-buffers t)
|
|
|
|
(setq ivy-count-format "(%d/%d) ")
|
|
|
|
|
|
|
|
;; Parens
|
|
|
|
(use-package paren
|
|
|
|
:ensure nil
|
|
|
|
:init
|
|
|
|
(setq show-paren-delay 0)
|
|
|
|
:config
|
|
|
|
(show-paren-mode +1))
|
|
|
|
|
|
|
|
(use-package smartparens
|
|
|
|
:config
|
|
|
|
(smartparens-global-mode 1))
|
|
|
|
(require 'smartparens)
|
|
|
|
(use-package evil-smartparens
|
|
|
|
:hook ('smartparens-enabled-hook #'evil-smartparens-mode))
|
|
|
|
|
2022-05-22 18:30:17 +02:00
|
|
|
;; Which key
|
2022-05-21 22:33:15 +02:00
|
|
|
(use-package which-key)
|
|
|
|
|
2022-05-22 18:30:17 +02:00
|
|
|
;; LSP/Complete packages
|
|
|
|
(use-package yasnippet
|
|
|
|
:config
|
|
|
|
(yas-global-mode))
|
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
(use-package lsp-mode
|
|
|
|
:commands (lsp lsp-deferred)
|
|
|
|
:init
|
|
|
|
(setq lsp-keymap-prefix "C-c l")
|
|
|
|
:config
|
2022-05-22 18:30:17 +02:00
|
|
|
(lsp-enable-which-key-integration t))
|
|
|
|
|
|
|
|
(use-package company)
|
|
|
|
(add-hook 'after-init-hook 'global-company-mode)
|
2022-05-21 22:33:15 +02:00
|
|
|
|
|
|
|
(use-package lsp-ui)
|
2022-05-22 18:30:17 +02:00
|
|
|
(require 'lsp-ui)
|
|
|
|
(lsp-ui-sideline-enable t)
|
|
|
|
|
|
|
|
(use-package lsp-java)
|
|
|
|
(add-hook 'java-mode-hook #'lsp)
|
|
|
|
|
|
|
|
(use-package dap-mode
|
|
|
|
:after lsp-mode
|
|
|
|
:config
|
|
|
|
(dap-auto-configure-mode))
|
|
|
|
(use-package dap-java
|
|
|
|
:ensure nil)
|
2022-05-21 22:33:15 +02:00
|
|
|
|
2022-05-22 18:30:17 +02:00
|
|
|
(use-package helm-lsp)
|
|
|
|
(use-package helm
|
2022-05-21 22:33:15 +02:00
|
|
|
:config
|
2022-05-22 18:30:17 +02:00
|
|
|
(helm-mode))
|
2022-05-21 22:33:15 +02:00
|
|
|
|
|
|
|
;; Language modes
|
2022-05-22 18:30:17 +02:00
|
|
|
; Java stuff
|
|
|
|
(use-package meghanada)
|
|
|
|
(add-hook 'java-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(meghanada-mode t)
|
|
|
|
(setq c-basic-offset 2)
|
|
|
|
(add-hook 'before-save-hook 'meghanada-code-beautify-before-save)))
|
|
|
|
(setq meghanada-java-path "java")
|
|
|
|
(setq meghanada-maven-path "mvn")
|
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
(use-package typescript-mode
|
|
|
|
:mode ("\\.tsx?\\'" . typescript-mode)
|
|
|
|
:hook (typescript-mode . lsp-deferred)
|
|
|
|
:config
|
|
|
|
(setq typescript-indent-level 2))
|
|
|
|
|
|
|
|
(use-package clojure-mode
|
|
|
|
:mode ("\\.cljs?\\'" . clojure-mode)
|
|
|
|
:hook (clojure-mode . lsp-deferred)
|
|
|
|
:config
|
|
|
|
(setq clojure-indent-level 2))
|
|
|
|
|
|
|
|
(use-package go-mode
|
|
|
|
:mode ("\\.go\\'" . go-mode)
|
|
|
|
:hook (go-mode . lsp-deferred))
|
|
|
|
|
|
|
|
(use-package markdown-mode
|
|
|
|
:mode ("\\.md\\'" . markdown-mode)
|
|
|
|
:hook (markdown-mode . auto-fill-mode))
|
|
|
|
|
2022-05-28 19:03:05 +02:00
|
|
|
(use-package dart-mode)
|
2022-05-21 22:33:15 +02:00
|
|
|
(use-package json-mode)
|
|
|
|
(use-package vimrc-mode)
|
|
|
|
(use-package yaml-mode)
|
|
|
|
|
2022-05-22 18:30:17 +02:00
|
|
|
(use-package flycheck
|
|
|
|
:config
|
|
|
|
(global-flycheck-mode))
|
|
|
|
(use-package exec-path-from-shell
|
|
|
|
:config
|
|
|
|
(exec-path-from-shell-initialize))
|
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
;;;; Bindings
|
2022-05-22 18:30:17 +02:00
|
|
|
|
|
|
|
;; Splits
|
|
|
|
(defun split-and-follow-horizontally ()
|
|
|
|
(interactive)
|
|
|
|
(split-window-below)
|
|
|
|
(balance-windows)
|
|
|
|
(other-window 1))
|
|
|
|
(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)
|
|
|
|
|
|
|
|
(defun split-and-follow-vertically ()
|
|
|
|
(interactive)
|
|
|
|
(split-window-right)
|
|
|
|
(balance-windows)
|
|
|
|
(other-window 1))
|
|
|
|
(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)
|
|
|
|
|
|
|
|
;; Split and open terminal
|
|
|
|
(defun split-and-open-terminal ()
|
|
|
|
(interactive)
|
|
|
|
(split-window-below)
|
|
|
|
(other-window 1)
|
|
|
|
(shell))
|
|
|
|
(global-set-key (kbd "C-x t") 'split-and-open-terminal)
|
|
|
|
|
2022-05-21 22:33:15 +02:00
|
|
|
;; Ivy
|
|
|
|
(global-set-key (kbd "C-s") 'swiper-isearch)
|
|
|
|
(global-set-key (kbd "M-x") 'counsel-M-x)
|
|
|
|
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
|
|
|
|
(global-set-key (kbd "M-y") 'counsel-yank-pop)
|
|
|
|
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
|
|
|
|
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
|
|
|
|
(global-set-key (kbd "<f1> l") 'counsel-find-library)
|
|
|
|
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
|
|
|
|
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
|
|
|
|
(global-set-key (kbd "<f2> j") 'counsel-set-variable)
|
|
|
|
(global-set-key (kbd "C-x b") 'ivy-switch-buffer)
|
|
|
|
(global-set-key (kbd "C-c v") 'ivy-push-view)
|
|
|
|
(global-set-key (kbd "C-c V") 'ivy-pop-view)
|
|
|
|
|
|
|
|
(global-set-key (kbd "C-c c") 'counsel-compile)
|
|
|
|
(global-set-key (kbd "C-c g") 'counsel-git)
|
|
|
|
(global-set-key (kbd "C-c j") 'counsel-git-grep)
|
|
|
|
(global-set-key (kbd "C-c L") 'counsel-git-log)
|
|
|
|
(global-set-key (kbd "C-c k") 'counsel-rg)
|
|
|
|
(global-set-key (kbd "C-c m") 'counsel-linux-app)
|
|
|
|
(global-set-key (kbd "C-c n") 'counsel-fzf)
|
|
|
|
(global-set-key (kbd "C-x l") 'counsel-locate)
|
|
|
|
(global-set-key (kbd "C-c J") 'counsel-file-jump)
|
|
|
|
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
|
|
|
|
(global-set-key (kbd "C-c w") 'counsel-wmctrl)
|
|
|
|
|
|
|
|
(global-set-key (kbd "C-c C-r") 'ivy-resume)
|
|
|
|
(global-set-key (kbd "C-c b") 'counsel-bookmark)
|
|
|
|
(global-set-key (kbd "C-c d") 'counsel-descbinds)
|
|
|
|
(global-set-key (kbd "C-c g") 'counsel-git)
|
|
|
|
(global-set-key (kbd "C-c o") 'counsel-outline)
|
|
|
|
(global-set-key (kbd "C-c t") 'counsel-load-theme)
|
|
|
|
(global-set-key (kbd "C-c F") 'counsel-org-file)
|
|
|
|
|
|
|
|
;;;; Themes
|
|
|
|
;; I use the default emacs color scheme, with Consolas font.
|
|
|
|
(custom-set-variables
|
|
|
|
;; custom-set-variables was added by Custom.
|
|
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
|
|
;; Your init file should contain only one such instance.
|
|
|
|
;; If there is more than one, they won't work right.
|
2022-05-22 18:30:17 +02:00
|
|
|
'(helm-minibuffer-history-key "M-p")
|
2022-05-21 22:33:15 +02:00
|
|
|
'(package-selected-packages
|
|
|
|
'(yaml-mode vimrc-mode json-mode clojure-mode typescript-mode use-package restart-emacs lsp-mode evil-collection)))
|
|
|
|
(custom-set-faces
|
|
|
|
;; custom-set-faces was added by Custom.
|
|
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
|
|
;; Your init file should contain only one such instance.
|
|
|
|
;; If there is more than one, they won't work right.
|
|
|
|
)
|