~/.emacs.d/
- Introduction
- Quick install
- Dependencies
- QoL section
- Enable line numbers
- Show parent parentheses
- Disable the default startup screen
- Disable most gui elements
- Enable copypasting outside of Emacs
- Disable automatic creation of backup files
- Enable conservative scrolling
- Disable ring-bell
- Indentation
- Enable prettify symbols mode
- Enable bracket pair-matching
- Creating a new window switches your cursor to it
- Transform yes-or-no questions into y-or-n
- Highlight current line
- Defer loading most packages for quicker startup times
- Fill spaces
- =Org= mode
- Eshell
- vterm
- Use-package section
- Programming
My personal emacs config, based on Witchmacs and Yukimacs.
git clone https://github.com/tsunagatteru/phantasm-emacs ~/.emacs.d
clang
as backend for C and C++ autocompletionllvm
to install irony servermit-scheme
for geiser to worklibvterm
for vtermpyright
python lsp
Minor quality-of-life modifications for a more pleasant Emacs experience
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'text-mode-hook 'display-line-numbers-mode)
(show-paren-mode 1)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(setq x-select-enable-clipboard t)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq scroll-conservatively 100)
(setq ring-bell-function 'ignore)
(setq-default tab-width 4)
(setq-default standard-indent 4)
(setq c-basic-offset tab-width)
(setq-default electric-indent-inhibit t)
(setq-default indent-tabs-mode t)
(setq backward-delete-char-untabify-method 'nil)
(global-prettify-symbols-mode t)
(setq electric-pair-pairs '(
(?\{ . ?\})
(?\( . ?\))
(?\[ . ?\])
(?\" . ?\")
))
(electric-pair-mode t)
(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)
(defalias 'yes-or-no-p 'y-or-n-p)
(global-hl-line-mode t)
(setq use-package-always-defer t)
(setq frame-resize-pixelwise t)
Everything org mode related
;; Source block expansion
(require 'org-tempo)
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
Typing the below + TAB | Expands to … |
---|---|
<a | ’#+BEGIN_EXPORT ascii’ … ‘#+END_EXPORT |
<c | ’#+BEGIN_CENTER’ … ‘#+END_CENTER’ |
<C | ’#+BEGIN_COMMENT’ … ‘#+END_COMMENT’ |
<e | ’#+BEGIN_EXAMPLE’ … ‘#+END_EXAMPLE’ |
<E | ’#+BEGIN_EXPORT’ … ‘#+END_EXPORT’ |
<h | ’#+BEGIN_EXPORT html’ … ‘#+END_EXPORT’ |
<l | ’#+BEGIN_EXPORT latex’ … ‘#+END_EXPORT’ |
<q | ’#+BEGIN_QUOTE’ … ‘#+END_QUOTE’ |
<s | ’#+BEGIN_SRC’ … ‘#+END_SRC’ |
<v | ’#+BEGIN_VERSE’ … ‘#+END_VERSE’ |
<el | ’#+BEGIN_SRC emacs-lisp’ … ‘#+END_SRC’ |
(use-package org
:config
(add-hook 'org-mode-hook 'org-indent-mode)
(add-hook 'org-mode-hook
#'(lambda ()
(visual-line-mode 1))))
(setq org-todo-keywords
'((sequence
"TODO(t)"
"WAIT(w)"
"PROCES(p)"
"|"
"DONE(d)"
"CANCELLED(c)" )))
(use-package toc-org
:after (org-mode markdown-mode)
:hook
(org-mode-hook . toc-org-mode)
(markdown-mode-hook . toc-org-mode))
(use-package org-indent
:ensure nil
:diminish org-indent-mode)
(use-package htmlize)
(use-package evil-org
:ensure t
:after org
:config
(require 'evil-org-agenda)
(evil-org-agenda-set-keys))
(add-hook `org-mode-hook `evil-org-mode)
(setq eshell-prompt-regexp "^[^αλ\n]*[αλ] ")
(setq eshell-prompt-function
(lambda nil
(concat
(if (string= (eshell/pwd) (getenv "HOME"))
(propertize "~" 'face `(:foreground "#99CCFF"))
(replace-regexp-in-string
(getenv "HOME")
(propertize "~" 'face `(:foreground "#99CCFF"))
(propertize (eshell/pwd) 'face `(:foreground "#99CCFF"))))
(if (= (user-uid) 0)
(propertize " α " 'face `(:foreground "#FF6666"))
(propertize " λ " 'face `(:foreground "#A6E22E"))))))
(setq eshell-highlight-prompt nil)
(defalias 'open 'find-file-other-window)
(defalias 'clean 'eshell/clear-scrollback)
(defun eshell/sudo-open (filename)
"Open a file as root in Eshell."
(let ((qual-filename (if (string-match "^/" filename)
filename
(concat (expand-file-name (eshell/pwd)) "/" filename))))
(switch-to-buffer
(find-file-noselect
(concat "/sudo::" qual-filename)))))
(defun eshell-other-window ()
"Create or visit an eshell buffer."
(interactive)
(if (not (get-buffer "*eshell*"))
(progn
(split-window-sensibly (selected-window))
(other-window 1)
(eshell))
(switch-to-buffer-other-window "*eshell*")))
(global-set-key (kbd "<s-C-return>") 'eshell-other-window)
(defun config-visit()
(interactive)
(find-file "~/.emacs.d/config.org"))
(global-set-key (kbd "C-c e") 'config-visit)
(defun config-reload ()
"Reloads ~/.emacs.d/config.org at runtine"
(interactive)
(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
(global-set-key (kbd "C-c r") 'config-reload)
A fully-fledged terminal inside Emacs.
(use-package vterm
:defer t
:config
(setq vterm-always-compile-module t)
(setq vterm-shell "/usr/bin/zsh"))
(use-package multi-vterm
:after vterm
:defer t)
Automatically updates and removes old packages
(use-package auto-package-update
:defer nil
:config
(setq auto-package-update-delete-old-versions t)
(setq auto-package-update-hide-results t)
(auto-package-update-maybe))
Hides minor modes to prevent cluttering your mode line
(use-package diminish)
Spaceline, to use it`s theme
(use-package spaceline)
Thing at the bottom that shows current mode and other stuff
(use-package powerline
:init
(spaceline-spacemacs-theme)
:hook
('after-init-hook) . 'powerline-reset)
The frontend of Emacs
(use-package dashboard
:defer nil
:preface
(defun update-config ()
"Update to the latest version."
(interactive)
(let ((dir (expand-file-name user-emacs-directory)))
(if (file-exists-p dir)
(progn
(message "Updating!")
(cd dir)
(shell-command "git pull")
(message "Update finished. Switch to the messages buffer to see changes and then restart Emacs"))
(message "\"%s\" doesn't exist." dir))))
(defun create-scratch-buffer ()
"Create a scratch buffer"
(interactive)
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))
:config
(dashboard-setup-startup-hook)
(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))
(setq dashboard-items '((recents . 5)))
(setq dashboard-center-content t)
(setq dashboard-banner-logo-title "\t ")
(setq dashboard-startup-banner "~/.emacs.d/yukari.png")
(setq dashboard-show-shortcuts nil)
(setq dashboard-set-init-info t)
(setq dashboard-init-info (format "%d packages loaded in %s"
(length package-activated-list) (emacs-init-time)))
(setq dashboard-set-footer nil)
(setq dashboard-set-navigator t)
(setq dashboard-navigator-buttons
`(;; line1
((,nil
"Github"
"Open github page on your browser"
(lambda (&rest _) (browse-url "https://github.com/tsunagatteru/phantasm-emacs"))
'default)
(nil
"Update"
"Get the latest update. Check out the github commits for changes!"
(lambda (&rest _) (update-config))
'default)
)
;; line 2
((,nil
"Open scratch buffer"
"Switch to the scratch buffer"
(lambda (&rest _) (create-scratch-buffer))
'default)
(nil
"Open config.org"
"Open configuration file for easy editing"
(lambda (&rest _) (find-file "~/.emacs.d/config.org"))
'default)))))
Command completeion
(use-package which-key
:diminish which-key-mode
:init
(which-key-mode))
Minibuffer for C-s search
(use-package swiper
:bind ("C-s" . 'swiper))
Vim keybindings
(use-package evil
:defer nil
:init
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
:config
(evil-mode 1))
Highlights the cursor position when switching to a new window or buffer
(use-package beacon
:diminish beacon-mode
:init
(beacon-mode 1))
C-x o window switching keys
(use-package switch-window
:config
(setq switch-window-input-style 'minibuffer)
(setq switch-window-increase 4)
(setq switch-window-threshold 2)
(setq switch-window-shortcut-style 'qwerty)
(setq switch-window-qwerty-shortcuts
'("a" "s" "d" "f" "j" "k" "l"))
:bind
([remap other-window] . switch-window))
Utilize asynchronous processes whenever possible
(use-package async
:init
(dired-async-mode 1))
(use-package page-break-lines
:diminish (page-break-lines-mode visual-line-mode))
(use-package undo-tree
:diminish undo-tree-mode)
Side-bar file and project explorer
(use-package treemacs
:defer t
:init
(with-eval-after-load 'winum
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
:config
(progn
(setq treemacs-collapse-dirs (if (executable-find "python3") 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-display-in-side-window t
treemacs-eldoc-display t
treemacs-file-event-delay 5000
treemacs-file-follow-delay 0.2
treemacs-follow-after-init t
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch nil
treemacs-silent-refresh nil
treemacs-sorting 'alphabetic-desc
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-width 30)
(treemacs-resize-icons 11)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode t)
(pcase (cons (not (null (executable-find "git")))
(not (null (executable-find "python3"))))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple))))
:bind
(:map global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("C-x t t" . treemacs)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag)))
(use-package treemacs-evil
:after treemacs evil
:ensure t)
(use-package treemacs-icons-dired
:after treemacs dired
:ensure t
:config (treemacs-icons-dired-mode))
Better buffer switching and killing
(use-package ido
:init
(ido-mode 1)
:config
(setq ido-enable-flex-matching nil)
(setq ido-create-new-buffer 'always)
(setq ido-everywhere t))
(use-package ido-vertical-mode
:init
(ido-vertical-mode 1))
(setq ido-vertical-define-keys 'C-n-C-p-up-and-down)
(use-package eldoc
:diminish eldoc-mode)
(use-package abbrev
:ensure nil
:diminish abbrev-mode)
File manager
(use-package ranger
:init
(ranger-override-dired-mode t)
(setq ranger-cleanup-on-disable t)
(setq ranger-show-hidden t)
(setq ranger-preview-file t)
(setq ranger-show-literal nil)
(setq ranger-dont-show-binary t))
Project management.
(use-package projectile
:config
(projectile-mode t)
(define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map)
;(setq projectile-track-known-projects-automatically nil)
(setq projectile-enable-caching t)
(setq projectile-require-project-root t)
(setq projectile-dynamic-mode-line nil))
Useful snippets.
(use-package yasnippet
:config
;;(use-package yasnippet-snippets)
;;(use-package auto-yasnippet)
(yas-reload-all)
(yas-global-mode))
(global-set-key (kbd "C-c y") 'yas-insert-snippet)
Syntax checking.
(use-package flycheck
:hook (after-init . global-flycheck-mode)
:custom
(flycheck-check-syntax-automatically '(save mode-enabled)))
Display documentation (e.g. arguments of a function).
(use-package eldoc
:hook (after-init . global-eldoc-mode))
Language server. Will provide us with IDE-like features.
(use-package lsp-mode
:commands lsp
:custom
(lsp-auto-guess-root t)
(lsp-log-io t)
(read-process-output-max (* 1024 1024))
(lsp-idle-delay 0.5)
(lsp-prefer-flymake nil))
;; Enhance UI
(use-package lsp-ui
:after (lsp-mode)
:hook (lsp-mode . lsp-ui-mode)
:custom
(lsp-ui-doc-enable nil)
(lsp-ui-doc-header t)
;(lsp-ui-doc-delay 2.0)
(lsp-ui-doc-include-signature t)
(lsp-ui-flycheck-enable t)
(lsp-ui-peek-always-show t)
(lsp-ui-sideline-show-code-actions t)
(lsp-ui-sideline-delay 0.05))
;(use-package dap-mode
; :after lsp-mode
; :config
; (dap-mode t)
; (dap-ui-mode t))
(use-package lsp-treemacs
:after (lsp-mode)
:commands lsp-treemacs
:config
(lsp-treemacs-sync-mode 1))
(setq lsp-lens-enable nil)
;(setq lsp-enable-file-watchers nil)
Provides completion.
(use-package company
:after lsp-mode
:bind
(:map company-active-map
("C-n". company-select-next)
("C-p". company-select-previous)
("M-<". company-select-first)
("M->". company-select-last)
("<tab>" . company-complete-selection))
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common))
:config
(setq company-dabbrev-other-buffers t
company-dabbrev-code-other-buffers t)
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.3)
:hook ((text-mode . company-mode)
(prog-mode . company-mode)
(org-mode . company-mode)
(company-mode . yas-minor-mode)
(lsp-mode . company-mode)))
(use-package company-box
:hook (company-mode . company-box-mode))
(use-package company-prescient
:after (selectrum company)
:config
(company-prescient-mode 1)
(prescient-persist-mode))
(add-hook 'after-init-hook 'global-company-mode)
(use-package sqlite3)
(use-package ccls
:config
(setq ccls-executable "ccls")
(setq lsp-prefer-flymake nil)
(setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc))
(setq ccls-sem-highlight-method 'overlay)
:hook ((c-mode c++-mode) .
(lambda () (require 'ccls) (lsp) (yas-minor-mode))))
(setq-default c-basic-offset 4)
(use-package cmake-mode)
(use-package lsp-pyright
:hook (python-mode . (lambda () (require 'lsp-pyright) (lsp)))
:init (when (executable-find "python3")
(setq lsp-pyright-python-executable-cmd "python3")))
(use-package pyvenv)
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
(add-hook 'emacs-lisp-mode-hook 'yas-minor-mode)
(use-package slime
:config
(setq inferior-lisp-program "/usr/bin/sbcl") ;; install SBCL from your repos
(setq slime-contribs '(slime-fancy)))
(use-package helpful
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind
([remap describe-function] . counsel-describe-function)
([remap describe-command] . helpful-command)
([remap describe-variable] . counsel-describe-variable)
([remap describe-key] . helpful-key))
(use-package geiser-mit)
(use-package go-mode
:hook (go-mode . lsp-deferred))
;; Set up before-save hooks to format buffer and add/delete imports.
;; Make sure you don't have other gofmt/goimports hooks enabled.
(defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
(use-package json-mode
:mode (("\\.json\\'" . json-mode)))
(use-package markdown-mode
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
(use-package auctex
:hook
(TeX-mode . TeX-PDF-mode)
(TeX-mode . company-mode)
(LaTeX-mode . (lambda ()
(push (list 'output-pdf "Zathura")
TeX-view-program-selection)))
:init
(setq reftex-plug-into-AUCTeX t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq TeX-open-quote "<<")
(setq TeX-close-quote ">>")
(setq TeX-electric-sub-and-superscript t)
(setq font-latex-fontify-script nil)
(setq TeX-show-compilation nil)
(setq reftex-label-alist '(AMSTeX)))
(use-package company-auctex
:init
(company-auctex-init))
(use-package company-reftex
:init
(add-to-list 'company-backends 'company-reftex-citations)
(add-to-list 'company-backends 'company-reftex-labels))
(use-package magit
:config
(setq magit-push-always-verify nil)
(setq git-commit-summary-max-length 50)
:bind
("M-g" . magit-status))
(use-package treemacs-magit
:after treemacs magit)
(use-package ghub
:demand t
:after magit)
(use-package web-mode)
(use-package pyvenv)
(use-package csharp-mode)
(use-package yaml-mode
:commands yaml-mode)
(use-package terraform-mode)
(use-package dockerfile-mode
:mode (("Dockerfile.*\\'" . dockerfile-mode)))
(use-package systemd)
(use-package powershell)
(use-package nginx-mode)
(use-package jenkinsfile-mode
:mode (("Jenkinsfile.*\\'" . jenkinsfile-mode)))