aboutsummaryrefslogtreecommitdiff
path: root/Emacs
diff options
context:
space:
mode:
Diffstat (limited to 'Emacs')
-rw-r--r--Emacs/.config/emacs/+org.el78
-rw-r--r--Emacs/.config/emacs/Grayscale-theme.el56
-rw-r--r--Emacs/.config/emacs/config.org746
-rw-r--r--Emacs/.config/emacs/init.el34
4 files changed, 605 insertions, 309 deletions
diff --git a/Emacs/.config/emacs/+org.el b/Emacs/.config/emacs/+org.el
deleted file mode 100644
index aa5e755..0000000
--- a/Emacs/.config/emacs/+org.el
+++ /dev/null
@@ -1,78 +0,0 @@
-(defun dx:org-insert-item (direction)
- "Shamelessly copied from Doom Emacs, better insert item"
- (let* ((context
- (save-excursion
- (when (bolp)
- (back-to-indentation)
- (forward-char))
- (org-element-lineage
- (org-element-context)
- '(table table-row headline inlinetask item plain-list)
- t)))
- (type (org-element-type context)))
- (cond ((memq type '(item plain-list))
- (let ((marker (org-element-property :bullet context))
- (pad (save-excursion
- (org-beginning-of-item)
- (back-to-indentation)
- (- (point) (line-beginning-position)))))
- (save-match-data
- (pcase direction
- (`below
- (org-end-of-item)
- (backward-char)
- (end-of-line)
- (if (and marker (string-match "\\([0-9]+\\)\\([).] *\\)" marker))
- (let ((l (line-number-at-pos)))
- (org-insert-item)
- (when (= l (line-number-at-pos))
- (org-next-item)
- (org-end-of-line)))
- (insert "\n" (make-string pad 32) (or marker ""))))
- (`above
- (org-beginning-of-item)
- (if (and marker (string-match-p "[0-9]+[).]" marker))
- (org-insert-item)
- (insert (make-string pad 32) (or marker ""))
- (save-excursion (insert "\n")))))))
- (when (org-element-property :checkbox context)
- (insert "[ ] ")))
-
- ((memq type '(table table-row))
- (pcase direction
- ('below (save-excursion (org-table-insert-row t))
- (org-table-next-row))
- ('above (save-excursion (org-shiftmetadown))
- (+org/table-previous-row))))
-
- ((let ((level (or (org-current-level) 1)))
- (pcase direction
- (`below
- (let (org-insert-heading-respect-content)
- (goto-char (line-end-position))
- (org-end-of-subtree)
- (insert "\n" (make-string level ?*) " ")))
- (`above
- (org-back-to-heading)
- (insert (make-string level ?*) " ")
- (save-excursion (insert "\n"))))
- (when-let* ((todo-keyword (org-element-property :todo-keyword context))
- (todo-type (org-element-property :todo-type context)))
- (org-todo (cond ((eq todo-type 'done)
- (car (+org-get-todo-keywords-for todo-keyword)))
- (todo-keyword)
- ('todo)))))))
-
- (when (org-invisible-p)
- (org-show-hidden-entry))
- (when (and (bound-and-true-p evil-local-mode)
- (not (evil-emacs-state-p)))
- (evil-insert 1))))
-
-(defun dx:org-insert-item-below ()
- (interactive)
- (dx:org-insert-item 'below))
-
-(defun dx:org-insert-item-above ()
- (interactive)
- (dx:org-insert-item 'above))
diff --git a/Emacs/.config/emacs/Grayscale-theme.el b/Emacs/.config/emacs/Grayscale-theme.el
new file mode 100644
index 0000000..9cacbc7
--- /dev/null
+++ b/Emacs/.config/emacs/Grayscale-theme.el
@@ -0,0 +1,56 @@
+(deftheme Grayscale
+ "Created 2020-08-01.")
+
+(custom-theme-set-faces
+ 'Grayscale
+ '(cursor ((((background light)) (:background "black")) (((background dark)) (:background "white"))))
+ '(fixed-pitch ((t (:family "Monospace"))))
+ '(variable-pitch ((((type w32)) (:foundry "outline" :family "Arial")) (t (:family "Sans Serif"))))
+ '(escape-glyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown"))))
+ '(homoglyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown"))))
+ '(minibuffer-prompt ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "medium blue"))))
+ '(highlight ((((class color) (min-colors 88) (background light)) (:background "darkseagreen2")) (((class color) (min-colors 88) (background dark)) (:background "darkolivegreen")) (((class color) (min-colors 16) (background light)) (:background "darkseagreen2")) (((class color) (min-colors 16) (background dark)) (:background "darkolivegreen")) (((class color) (min-colors 8)) (:foreground "black" :background "green")) (t (:inverse-video t))))
+ '(region ((t (:extend t :background "gray20"))))
+ '(shadow ((((class color grayscale) (min-colors 88) (background light)) (:foreground "grey50")) (((class color grayscale) (min-colors 88) (background dark)) (:foreground "grey70")) (((class color) (min-colors 8) (background light)) (:foreground "green")) (((class color) (min-colors 8) (background dark)) (:foreground "yellow"))))
+ '(secondary-selection ((((class color) (min-colors 88) (background light)) (:extend t :background "yellow1")) (((class color) (min-colors 88) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 16) (background light)) (:extend t :background "yellow")) (((class color) (min-colors 16) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 8)) (:extend t :foreground "black" :background "cyan")) (t (:inverse-video t))))
+ '(trailing-whitespace ((((class color) (background light)) (:background "red1")) (((class color) (background dark)) (:background "red1")) (t (:inverse-video t))))
+ '(font-lock-builtin-face ((((class grayscale) (background light)) (:weight bold :foreground "LightGray")) (((class grayscale) (background dark)) (:weight bold :foreground "DimGray")) (((class color) (min-colors 88) (background light)) (:foreground "dark slate blue")) (((class color) (min-colors 88) (background dark)) (:foreground "LightSteelBlue")) (((class color) (min-colors 16) (background light)) (:foreground "Orchid")) (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue")) (((class color) (min-colors 8)) (:weight bold :foreground "blue")) (t (:weight bold))))
+ '(font-lock-comment-delimiter-face ((t (:slant italic :foreground "gray24"))))
+ '(font-lock-comment-face ((t (:slant italic :foreground "#868686"))))
+ '(font-lock-constant-face ((t (:family "Source Code Pro" :height 0.9 :weight bold :foreground "#868686"))))
+ '(font-lock-doc-face ((t (:inherit (font-lock-string-face)))))
+ '(font-lock-function-name-face ((t (:weight semi-bold))))
+ '(font-lock-keyword-face ((t (:family "Fira Code" :height 0.95 :weight bold :foreground "DeepSkyBlue4"))))
+ '(font-lock-negation-char-face ((t nil)))
+ '(font-lock-preprocessor-face ((t (:family "Source Code Pro" :foreground "#868686"))))
+ '(font-lock-regexp-grouping-backslash ((t (:inherit (bold)))))
+ '(font-lock-regexp-grouping-construct ((t (:inherit (bold)))))
+ '(font-lock-string-face ((t (:family "Fira Code" :foreground "yellow4"))))
+ '(font-lock-type-face ((t (:family "Hack" :height 0.95 :foreground "chartreuse"))))
+ '(font-lock-variable-name-face ((t (:family "Source Code Variable" :foreground "#e6e6e6"))))
+ '(font-lock-warning-face ((t (:inherit (error)))))
+ '(button ((t (:inherit (link)))))
+ '(link ((t (:underline (:color foreground-color :style line) :foreground "cyan1"))))
+ '(link-visited ((t (:foreground "violet" :inherit (link)))))
+ '(fringe ((((class color) (background light)) (:background "grey95")) (((class color) (background dark)) (:background "grey10")) (t (:background "gray"))))
+ '(header-line ((t (:box nil :foreground "grey90" :background "grey20" :inherit (mode-line)))))
+ '(tooltip ((t (:foreground "black" :background "lightyellow" :inherit (variable-pitch)))))
+ '(mode-line ((t (:box (:line-width -1 :color nil :style released-button) :foreground "white" :background "black"))))
+ '(mode-line-buffer-id ((t (:weight bold))))
+ '(mode-line-emphasis ((t (:weight bold))))
+ '(mode-line-highlight ((((class color) (min-colors 88)) (:box (:line-width 2 :color "grey40" :style released-button))) (t (:inherit (highlight)))))
+ '(mode-line-inactive ((t (:weight light :box (:line-width -1 :color "grey40" :style nil) :foreground "grey30" :background "grey7" :inherit (mode-line)))))
+ '(isearch ((t (:foreground "brown4" :background "white"))))
+ '(isearch-fail ((((class color) (min-colors 88) (background light)) (:background "RosyBrown1")) (((class color) (min-colors 88) (background dark)) (:background "red4")) (((class color) (min-colors 16)) (:background "red")) (((class color) (min-colors 8)) (:background "red")) (((class color grayscale)) (:foreground "grey")) (t (:inverse-video t))))
+ '(lazy-highlight ((((class color) (min-colors 88) (background light)) (:background "paleturquoise")) (((class color) (min-colors 88) (background dark)) (:background "paleturquoise4")) (((class color) (min-colors 16)) (:background "turquoise3")) (((class color) (min-colors 8)) (:background "turquoise3")) (t (:underline (:color foreground-color :style line)))))
+ '(match ((((class color) (min-colors 88) (background light)) (:background "yellow1")) (((class color) (min-colors 88) (background dark)) (:background "RoyalBlue3")) (((class color) (min-colors 8) (background light)) (:foreground "black" :background "yellow")) (((class color) (min-colors 8) (background dark)) (:foreground "white" :background "blue")) (((type tty) (class mono)) (:inverse-video t)) (t (:background "gray"))))
+ '(next-error ((t (:inherit (region)))))
+ '(query-replace ((t (:inherit (isearch)))))
+ '(default ((t (:family "Source Code Pro" :foundry "ADBO" :width normal :height 113 :weight normal :slant normal :underline nil :overline nil :extend nil :strike-through nil :box nil :inverse-video nil :foreground "#b6b6b6" :background "#000000" :stipple nil :inherit nil))))
+ '(company-tooltip ((t (:background "navy blue" :foreground "white"))))
+ '(company-tooltip-selection ((t (:background "gray31"))))
+ '(company-tooltip-annotation ((t (:foreground "grey" :slant italic))))
+ '(company-preview ((((background light)) (:inherit (company-tooltip-selection company-tooltip))) (((background dark)) (:foreground "wheat" :background "blue4"))))
+ '(company-preview-common ((t (:inherit company-preview :foreground "grey")))))
+
+(provide-theme 'Grayscale)
diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org
index c99bbe7..52c7425 100644
--- a/Emacs/.config/emacs/config.org
+++ b/Emacs/.config/emacs/config.org
@@ -1,248 +1,576 @@
-#+TITLE: Config for Emacs
+#+TITLE: Emacs configuration
#+AUTHOR: Oreodave
-#+DESCRIPTION: My bespoke config for Emacs
-#+PROPERTY: header-args :tangle yes
+#+DESCRIPTION: My new Emacs configuration
-* Notes
- This setup uses emacs 27, with use-package and melpa.
- Code structure is pretty simple:
- - parent packages or packages that other packages leverage greatly are configured first.
- I use =:after= as a depdence generator: in most circumstances.
-
-* Init
-** Set some details
- Some basic details set for the purposes of Emacs
- #+BEGIN_SRC emacs-lisp
- (setq user-emacs-directory (expand-file-name "~/.config/emacs/")
- ring-bell-function 'ignore
- inhibit-startup-screen t)
- #+END_SRC
-
-** Turn off those annoying bars
- Annoying menu bars, tool bars, etc
+* Initial
+** Setup straight
+ Bootstrap of straight (from github)
+ #+BEGIN_SRC emacs-lisp
+ (defvar bootstrap-version)
+ (let ((bootstrap-file
+ (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
+ (bootstrap-version 5))
+ (unless (file-exists-p bootstrap-file)
+ (with-current-buffer
+ (url-retrieve-synchronously
+ "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
+ 'silent 'inhibit-cookies)
+ (goto-char (point-max))
+ (eval-print-last-sexp)))
+ (load bootstrap-file nil 'nomessage))
+ #+END_SRC
+** Setup use package
+ Straight clone use-package and state that all use-package statements implicity use straight.
+ #+BEGIN_SRC emacs-lisp
+ (straight-use-package 'use-package)
+ (setq straight-use-package-by-default t)
+ #+END_SRC
+** Setup alpha and yes-or-no-p
+ This just sets the alpha to 85% and all yes or no questions to single letter responses.
+ #+BEGIN_SRC emacs-lisp
+ (add-to-list 'default-frame-alist '(alpha . 85))
+ (fset 'yes-or-no-p 'y-or-n-p)
+ #+END_SRC
+** Hs Minor mode
+ Turn on hs minor mode for all prog-mode.
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'prog-mode-hook #'hs-minor-mode)
+ #+END_SRC
+** Set backup directory
+ Set the backup directory to =user-emacs-directory=/saves so I don't get those annoying '~' files.
+ #+BEGIN_SRC emacs-lisp
+ (setq backup-directory-alist `(("." . "~/.config/emacs/saves")))
+ #+END_SRC
+** Turn off the bars
+ Turn off all the bars, don't need them anymore!
#+BEGIN_SRC emacs-lisp
(tool-bar-mode -1)
(scroll-bar-mode -1)
- (tab-bar-mode -1)
(menu-bar-mode -1)
#+END_SRC
-
-** Set fonts and alpha
- Make two constants that hold the values for font and alpha, then set them in Emacs.
+** Themes
+ Load my custom "Grayscale" theme (look at [[file:Grayscale-theme.el][this file]]).
#+BEGIN_SRC emacs-lisp
- (defconst dx:font "IBM Plex Mono-12" "Default font for Emacs")
- (defconst dx:alpha 0.9 "Default alpha transparency for Emacs")
+ (load-theme 'Grayscale t)
+ #+END_SRC
+* Emacs Mode-line
+ Firstly, declare a variable for the number of spaces between each module in the modeline.
+ #+BEGIN_SRC emacs-lisp
+ (defconst +modeline/sep-spaces 4 "Number of spaces separating modules.")
+ #+END_SRC
- (add-to-list 'default-frame-alist (cons 'font dx:font))
- (add-to-list 'default-frame-alist (cons 'alpha dx:alpha))
- (set-face-attribute 'default t :font dx:font)
+ Then, declare a list of reserved characters for which the previously declared seperator won't be applied when placed at the end of a module string.
+ #+BEGIN_SRC emacs-lisp
+ (defconst +modeline/reserved-chars (list "[" "(")
+ "Characters that, when at the end of a module string, won't have the separator applied to them.")
+ #+END_SRC
- (add-hook 'prog-mode-hook #'hs-minor-mode)
- (add-hook 'prog-mode-hook #'display-line-numbers-mode)
+ Now declare a function that applies the separator with respect to the reserved characters to any one string.
+ #+BEGIN_SRC emacs-lisp
+ (defun +modeline/handle-string (STR)
+ (condition-case nil
+ (progn
+ (string-blank-p STR)
+ (cond ((cl-member (car (last (split-string STR "" t))) +modeline/reserved-chars :test #'string=) STR)
+ (t (concat STR (cl-reduce #'concat (cl-loop for i from 1 to +modeline/sep-spaces collect " "))))))
+ (error STR)))
+ #+END_SRC
+
+ Finally, set the mode-line-format.
+ #+BEGIN_SRC emacs-lisp
+ (setq-default
+ mode-line-format
+ (mapcar #'+modeline/handle-string
+ (list "%l:%c"
+ "%p["
+ '(:eval (upcase
+ (substring
+ (format "%s" (if (bound-and-true-p evil-state) evil-state ""))
+ 0 1)))
+ "]"
+ "%+%b("
+ '(:eval (format "%s" major-mode))
+ ")"
+ "%I"
+ vc-mode
+ mode-line-end-spaces)))
+ #+END_SRC
+* Custom Functions
+ These are custom functions I have defined
+** New line function
+ Vim bindings don't have a nice way of adding new lines before or after the current line while staying in normal mode.
+ You can use =o/O= to enter insert mode at a new line, but this isn't the same as being able to stay in normal mode, and only adds extra keypresses if your only purpose was to open up some lines.
+ As this is Emacs I can extend it as I wish, so I decided to define a new line function that won't remove me from normal state.
+
+ The logic is pretty simple:
+ - Use the predefined vim functions for opening new lines above and below with insert mode
+ - Given the argument =BACKWARD= to assess whether to open lines above or below
+ - Return to previous location
+ - Enter normal state
+
+ #+BEGIN_SRC emacs-lisp
+ (with-eval-after-load "evil"
+ (defun dx:newline (&optional BACKWARD)
+ (interactive)
+ (let ((old (point)))
+ (cond ((and BACKWARD (= BACKWARD 1)) (evil-open-below 1))
+ (t (evil-open-above 1)))
+ (goto-char (+ old 1))
+ (evil-normal-state))))
+ #+END_SRC
+** Generate tags
+ For some reason, I can't seem to rely on the =projectile-regenerate-tags= function, so define my own.
+
+ Steps are as follows:
+ - Consider the =root= to be either =default-directory= or the =projectile-project-root= depending on if it's loaded and set.
+ - Start a process (shell command) by changing to =root= and executing =ctags -Re=
+ #+BEGIN_SRC emacs-lisp
+ (defun dx:generate-tags ()
+ (interactive)
+ (let ((root (if (bound-and-true-p projectile-project-root)
+ projectile-project-root
+ default-directory)))
+ (start-process-shell-command "" nil (format "cd %s; ctags -Re ." root))))
+ #+END_SRC
+* Keybindings
+** Global map
+ Any functions that are already loaded, set them to the global map.
+ #+BEGIN_SRC emacs-lisp
+ (bind-keys
+ :map global-map
+ ("<menu>" . nil)
+ ("M-v" . (lambda () (interactive) (dx:newline 1)))
+ ("M-V" . (lambda () (interactive) (dx:newline)))
+ ("C-c !" . async-shell-command)
+ ("C-c c" . compile)
+ ("M-s i" . imenu)
+ ("M-n f" . narrow-to-defun)
+ ("M-n w" . widen)
+ ("M-n r" . narrow-to-region))
#+END_SRC
-** Set some useful variables
- Truncate lines, display number lines and stop making backup files (for now).
+** Menu map
+ Any keys I want to map to <menu>, the weird little menu interaction button on some keyboards.
#+BEGIN_SRC emacs-lisp
- (setq completion-ignore-case t
- truncate-lines t
- display-line-numbers-type t
- make-backup-files nil)
- #+END_SRC
-** ido mode
- Setup ido mode, easy to use completion framework.
+ (bind-keys
+ :prefix "<menu>"
+ :prefix-map dx:menu-map
+ ("<menu>" . execute-extended-command)
+ ("p" . (lambda () (interactive) (find-file (concat user-emacs-directory "config.org"))))
+ ("#" . (lambda () (interactive) (projectile-find-file)))
+ ("/" . counsel-rg)
+ ("." . imenu))
+ #+END_SRC
+* Evil
+** Evil default
+ Setup the evil package, with some basic keybinds.
#+BEGIN_SRC emacs-lisp
- (ido-mode +1)
+ (use-package evil
+ :init
+ (setq evil-want-keybinding nil)
+ :config
+ (evil-mode +1)
+ (bind-key "TAB" #'evil-jump-item evil-normal-state-map)
+ (evil-define-key 'visual 'emacs-lisp-mode-map "gr" #'eval-region))
#+END_SRC
-* Keybindings
-** Keychord
- Setup key chord, pretty basic config.
+** Evil surround
+ #+BEGIN_SRC emacs-lisp
+ (use-package evil-surround
+ :after evil
+ :config
+ (global-evil-surround-mode))
+ #+END_SRC
+** Evil commentary
#+BEGIN_SRC emacs-lisp
- (use-package key-chord
- :ensure t
+ (use-package evil-commentary
+ :after evil
:config
- (key-chord-mode +1))
+ (evil-commentary-mode))
#+END_SRC
-** General
- Setup for general, keybinding library.
- I use the function =general-evil-setup= to use the =*map= family of keymapping functions.
- In this case I setup two defines: =gmap= and =lmap=.
- =gmap= is for all global maps while lmap is for local, mode based keybindings
- I also have a good bit of bindings setup here, such that any default emacs functions that I use regularly is setup here.
+** Evil mc
+ Setup for multicursors in Evil mode.
+ Don't let evil-mc setup it's own keymap because it uses 'gr' as its prefix, which I don't like.
+ Instead, bind some useful functions to my personal =dx:evil-mc-map= which is bound to 'gz'.
+ Furthermore, define a function =dx:evil-mc-cursor-here= which pauses cursors upon placing a cursor at the current position.
#+BEGIN_SRC emacs-lisp
- (use-package general
- :ensure t
+ (use-package evil-mc
+ :after evil
+ :bind (("M-p" . evil-mc-skip-and-goto-prev-cursor)
+ :map dx:evil-mc-map
+ ("q" . evil-mc-undo-all-cursors)
+ ("d" . evil-mc-make-and-goto-next-match)
+ ("j" . evil-mc-make-cursor-move-next-line)
+ ("k" . evil-mc-make-cursor-move-prev-line)
+ ("j" . evil-mc-make-cursor-move-next-line)
+ ("m" . evil-mc-make-all-cursors)
+ ("z" . dx:evil-mc-cursor-here)
+ ("r" . evil-mc-resume-cursors)
+ ("s" . evil-mc-pause-cursors))
:init
- ;; Definers
- (general-def :states 'normal
- "SPC" nil)
- (general-create-definer gmap :prefix "SPC")
- (general-create-definer lmap :prefix "SPC m")
- (general-evil-setup t)
-)
- #+END_SRC
-* Which key
-#+BEGIN_SRC emacs-lisp
-(use-package which-key
- :ensure t
- :config
- (which-key-mode +1))
-#+END_SRC
-
-* Evil
- Basic evil configuration with some keychords.
+ (defvar evil-mc-key-map (make-sparse-keymap))
+ (define-prefix-command 'dx:evil-mc-map)
+ (bind-key "gz" dx:evil-mc-map evil-normal-state-map)
+ (bind-key "gz" dx:evil-mc-map evil-visual-state-map)
+ :config
+ (global-evil-mc-mode +1)
+ (defun dx:evil-mc-cursor-here ()
+ (interactive)
+ (evil-mc-make-cursor-here)
+ (evil-mc-pause-cursors)))
+ #+END_SRC
+** Evil collection
+ Setup evil collection, but don't turn on the mode.
+ Instead, I'll turn on setups for specific modes I think benefit from it.
+ #+BEGIN_SRC emacs-lisp
+ (use-package evil-collection
+ :after evil)
+ #+END_SRC
+* IBuffer
#+BEGIN_SRC emacs-lisp
-(use-package evil
- :ensure t
- :after key-chord general
- :config
- (evil-mode +1)
- (key-chord-define evil-insert-state-map "jk" #'evil-normal-state)
- ;; Keybindgs
- (gmap "SPC" #'execute-extended-command)
- ;; Files
- (gmap
- :infix "f"
- "f" #'find-file
- "p" #'(lambda () (interactive) (find-file "~/.config/emacs/init.el"))
- "-" #'dired
- "s" #'save-buffer)
- ;; Buffers
- (gmap
- :infix "b"
- "b" #'switch-to-buffer
- "d" #'kill-buffer
- "n" #'next-buffer
- "p" #'previous-buffer
- "i" #'ibuffer)
- ;; Other
- (gmap
- "c" #'compile)
- (vmap
- :keymaps 'emacs-lisp-mode-map
- "gr" #'eval-region)
-)
+ (use-package ibuffer
+ :bind ("<menu> ," . ibuffer)
+ :after evil-collection
+ :config
+ (evil-collection-ibuffer-setup))
+ #+END_SRC
+* Dired
+ Setup for dired.
+ Firstly, as it's an inbuilt package don't let straight try and download it.
+ Make dired-hide-details-mode the default mode when dired-mode, as it removes the clutter.
+ Create a keymap =dx:dired-map= which is bound to the prefix "C-c d", binding useful dired functions.
+ Setup evil collection for dired (even though dired doesn't really conflict with evil, there are some black corners I'd like to adjust)
+ #+BEGIN_SRC emacs-lisp
+ (use-package dired
+ :straight nil
+ :hook (dired-mode . dired-hide-details-mode)
+ :bind-keymap* ("C-c d" . dx:dired-map)
+ :after evil-collection
+ :init
+ (defvar dx:dired-map (make-sparse-keymap) "dx:dired-map")
+ :config
+ (bind-keys
+ :map dx:dired-map
+ ("f" . find-dired)
+ ("D" . dired-other-window)
+ ("d" . dired-jump))
+ (evil-collection-dired-setup))
#+END_SRC
-** Evil surround
-#+BEGIN_SRC emacs-lisp
-(use-package evil-surround
- :ensure t
- :after evil
- :config
- (global-evil-surround-mode +1))
-#+END_SRC
-
* Helpful
+ Basic setup, will be fully integrated in counsel.
#+BEGIN_SRC emacs-lisp
- (use-package helpful
- :after general
- :ensure t
- :config
- (gmap
- :infix "h"
- "f" #'helpful-callable
- "v" #'helpful-variable
- "k" #'helpful-key))
+ (use-package helpful
+ :commands (helpful-callable helpful-variable))
+ #+END_SRC
+* Which-key
+ Pretty simple, just activate after init.
+ #+BEGIN_SRC emacs-lisp
+ (use-package which-key
+ :hook (after-init . which-key-mode))
+ #+END_SRC
+* Avy
+ Avy is an incredibly useful package that I have just started to understand.
+ For now, I have two bindings for =avy-goto-line= and =avy-goto-char-2= as I use them often.
+ #+BEGIN_SRC emacs-lisp
+ (use-package avy
+ :bind (("M-g" . #'avy-goto-char-2)
+ ("M-l" . #'avy-goto-line)))
+ #+END_SRC
+* Hydra
+ I haven't found a use for it yet, so don't tangle this.
+ #+BEGIN_SRC emacs-lisp :tangle no
+ (use-package hydra)
#+END_SRC
-
* Yasnippet
-#+BEGIN_SRC emacs-lisp
-(use-package yasnippet
- :ensure t
- :after general
- :config
- (add-hook 'prog-mode-hook #'yas-minor-mode)
- (gmap
- "is" #'yas-insert-snippet))
+ Yasnippet is a great package for snippets, which I use heavily in programming and org-mode.
+ I setup here the global mode for yasnippet and a collection of snippets for ease of use.
+** Yasnippet default
+ Setup global mode after evil mode has been loaded
+ #+BEGIN_SRC emacs-lisp
+ (use-package yasnippet
+ :after evil
+ :hook (after-init . yas-global-mode)
+ :bind ("C-c i" . yas-insert-snippet))
+ #+END_SRC
+** Yasnippet snippets
+ Collection of snippets, activate after yasnippet has been loaded.
+ #+BEGIN_SRC emacs-lisp
+ (use-package yasnippet-snippets
+ :after yasnippet)
+ #+END_SRC
+* Keychord
+ Keychord is only really here for this one chord I wish to define: "jk" for exiting insert state.
+ Otherwise, I don't really need it.
+ #+BEGIN_SRC emacs-lisp
+ (use-package key-chord
+ :after evil
+ :config
+ (key-chord-define evil-insert-state-map "jk" #'evil-normal-state)
+ (key-chord-mode +1))
+ #+END_SRC
+* Ivy
+ Ivy is a completion framework for Emacs, and my preferred (sometimes second favourite) one.
+ It has a great set of features with little to no pain with setting up.
+** Ivy
+ Setup for ivy, in preparation for counsel.
+ Turn on ivy-mode just after init.
+ Setup vim-like bindings for the minibuffer ("C-(j|k)" for down|up the selection list)
+ Also setup evil-collection for ivy.
+ #+BEGIN_SRC emacs-lisp
+ (use-package ivy
+ :after evil-collection
+ :hook (after-init . ivy-mode)
+ :bind (:map ivy-minibuffer-map
+ ("C-j" . ivy-next-line-or-history)
+ ("C-k" . ivy-previous-line-or-history)
+ :map ivy-switch-buffer-map
+ ("C-j" . ivy-next-line-or-history)
+ ("C-k" . ivy-previous-line-or-history))
+ :config
+ (evil-collection-ivy-setup))
-(use-package yasnippet-snippets
- :ensure t
- :after yasnippet)
-#+END_SRC
-* Doom-themes
- Setup for doom themes.
- Allow bold themes but not italic (italic is harder to read).
- Allow doom themes to configure org mode to fix fonts on headers, etc.
- Define a function that does the same thing as =counsel-load-function-action= without the dependency on counsel.
- Load a theme using said function, in this case =doom-monokai-classic=.
+ #+END_SRC
+** Counsel
+ Setup for counsel.
+ Load after ivy and helpful.
+
+ Bind:
+ - Swiper to "C-s"
+ - Switch buffer to "C-x b"
+ - Counsel ripgrep to "M-s r" (search namespace)
+
+ Along with that, set the help function and variable functions to their helpful counterparts.
+ #+BEGIN_SRC emacs-lisp
+ (use-package counsel
+ :after (ivy helpful)
+ :bind (("C-s" . counsel-grep-or-swiper)
+ ("C-x b" . counsel-switch-buffer)
+ ("M-s r" . counsel-rg))
+ :config
+ (setq ivy-initial-inputs-alist nil
+ counsel-describe-function-function #'helpful-callable
+ counsel-describe-variable-function #'helpful-variable))
+ #+END_SRC
+** Counsel etags
+ Counsel etags allows me to search generated tag files for tags.
+ I already have a function defined [[*Generate tags][here]] to generate the tags, so it's just searching them which I find to be a bit of a hassle, and where this package comes in.
+ #+BEGIN_SRC emacs-lisp
+ (use-package counsel-etags
+ :after counsel
+ :bind ("M-s t" . counsel-etags-find-tag))
+ #+END_SRC
+* Projectile
+** Projectile default
+ Setup projectile, along with the tags command.
+ Also bind "C-c C-p" to the projectile command map for quick access.
+ #+BEGIN_SRC emacs-lisp
+ (use-package projectile
+ :after evil
+ :hook (prog-mode . projectile-mode)
+ :bind-keymap* ("C-c C-p" . projectile-command-map)
+ :init
+ (setq projectile-tags-command "ctags -Re -f \"%s\" %s \"%s\"")
+ :config
+ (projectile-global-mode))
+ #+END_SRC
+** Counsel projectile
+ Counsel projectile provides the ivy interface to projectile commands, which is really useful.
+ #+BEGIN_SRC emacs-lisp
+ (use-package counsel-projectile
+ :after (projectile counsel)
+ :config
+ (counsel-projectile-mode +1))
+ #+END_SRC
+* Magit
+ Magit is *the* git porcelain for Emacs, which perfectly encapsulates the git cli.
+ In this case, I just need to setup the bindings for it.
+ As magit will definitely load after evil (as it must be run by a binding, and evil will load after init), I can use evil-collection freely.
#+BEGIN_SRC emacs-lisp
- (use-package doom-themes
- :ensure t
- :config
- (setq doom-themes-enable-bold t
- doom-themes-enable-italic nil)
- (doom-themes-org-config)
- (defun dx:load-theme (theme)
- "Load a given theme into Emacs, while unloading the rest"
- (mapc #'disable-theme custom-enabled-themes)
- (load-theme theme t))
- (dx:load-theme 'doom-monokai-classic))
- #+END_SRC
+ (use-package magit
+ :bind (("C-x g g" . magit-status)
+ ("C-x g c" . magit-clone)
+ ("C-x g l" . magit-log)))
-* Org-mode
-** Vanilla org mode
+ (use-package evil-magit
+ :after magit)
+ #+END_SRC
+* Company
+ Company is the auto complete system I use.
+ I don't like having heavy setups for company, as it only makes it worse to use.
+ In this case, just setup some evil binds for company
#+BEGIN_SRC emacs-lisp
- (use-package org
- :ensure t
+ (use-package company
+ :hook (prog-mode . company-mode)
+ :bind (("C-SPC" . company-complete)
+ :map company-active-map
+ ("C-j" . company-select-next)
+ ("C-k" . company-select-previous)))
+ #+END_SRC
+* Elfeed
+ Elfeed is the perfect RSS feed reader, integrated into Emacs perfectly.
+ I've got a set of feeds that I use for a large variety of stuff, mostly media and entertainment.
+ I've also bound "C-c r" to elfeed for loading the system.
+ #+BEGIN_SRC emacs-lisp
+ (use-package elfeed
+ :bind ("C-c r" . elfeed)
+ :init
+ (setq +rss/feed-urls
+ '(("Arch Linux" "https://www.archlinux.org/feeds/news/" Linux)
+ ("LEMMiNO" "https://www.youtube.com/feeds/videos.xml?channel_id=UCRcgy6GzDeccI7dkbbBna3Q" YouTube Stories)
+ ("Dark Sominium" "https://www.youtube.com/feeds/videos.xml?channel_id=UC_e39rWdkQqo5-LbiLiU10g" YouTube Stories)
+ ("Dark Sominium Music" "https://www.youtube.com/feeds/videos.xml?channel_id=UCkLiZ_zLynyNd5fd62hg1Kw" YouTube Music)
+ ("Nexpo" "https://www.youtube.com/feeds/videos.xml?channel_id=UCpFFItkfZz1qz5PpHpqzYBw" YouTube)
+ ("Techquickie" "https://www.youtube.com/feeds/videos.xml?channel_id=UC0vBXGSyV14uvJ4hECDOl0Q" YouTube)
+ ("Captain Sinbad" "https://www.youtube.com/feeds/videos.xml?channel_id=UC8XKyvQ5Ne_bvYbgv8LaIeg" YouTube)
+ ("3B1B" "https://www.youtube.com/feeds/videos.xml?channel_id=UCYO_jab_esuFRV4b17AJtAw" YouTube)
+ ("Fredrik Knusden" "https://www.youtube.com/feeds/videos.xml?channel_id=UCbWcXB0PoqOsAvAdfzWMf0w" YouTube Stories)
+ ("Barely Sociable" "https://www.youtube.com/feeds/videos.xml?channel_id=UC9PIn6-XuRKZ5HmYeu46AIw" YouTube Stories)
+ ("Atrocity Guide" "https://www.youtube.com/feeds/videos.xml?channel_id=UCn8OYopT9e8tng-CGEWzfmw" YouTube Stories)
+ ("Phillip Defranco" "https://www.youtube.com/feeds/videos.xml?channel_id=UClFSU9_bUb4Rc6OYfTt5SPw" YouTube News)
+ ("Hacker News" "http://morss.aryadevchavali.com/news.ycombinator.com/rss" Social)
+ ("Hacker Factor" "https://www.hackerfactor.com/blog/index.php?/feeds/index.rss2" Social)
+ ("BBC Top News" "http://morss.aryadevchavali.com/feeds.bbci.co.uk/news/rss.xml" News)
+ ("BBC Tech News" "http://morss.aryadevchavali.com/feeds.bbci.co.uk/news/technology/rss.xml" News)))
+ (setq elfeed-db-directory (concat user-emacs-directory "elfeed"))
:config
- (load (concat user-emacs-directory "+org.el"))
- (nmap
- :keymaps 'org-mode-map
- "M-j" #'org-metadown
- "M-k" #'org-metaup
- "C-RET" #'dx:org-insert-item-below))
+ (evil-collection-elfeed-setup)
+ (evil-define-key 'normal elfeed-search-mode-map "gr" #'elfeed-update)
+ (evil-define-key 'normal elfeed-search-mode-map "s" #'elfeed-search-live-filter)
+ (evil-define-key 'normal elfeed-search-mode-map "<return>" #'elfeed-search-show-entry)
+ (setq elfeed-feeds (mapc #'(lambda (item) (append (list (nth 1 item)) (cdr (cdr item)))) +rss/feed-urls)))
#+END_SRC
-** Evil org mode
-Setup evil org mode, which allows for some nicer abstractions of the interace.
-#+BEGIN_SRC emacs-lisp
- (use-package evil-org
- :ensure t
- :after org
- :config
- (add-hook 'org-mode-hook 'evil-org-mode)
- (add-hook 'evil-org-mode-hook
- (lambda ()
- (evil-org-set-key-theme)))
- (require 'evil-org-agenda)
- (evil-org-agenda-set-keys))
-#+END_SRC
-* Magit
+* Org mode
+** Org default with evil
+ Setup for org mode, currently basically nothing.
+ Has evil-org for evil bindings.
#+BEGIN_SRC emacs-lisp
- (use-package magit
- :ensure t
- :after general
- :config
- (gmap
- "g" #'magit-status))
-
+ (use-package org
+ :hook (org-mode . yas-minor-mode)
+ :bind (:map org-mode-map
+ ([remap imenu] . counsel-org-goto)))
+ (use-package evil-org
+ :hook (org-mode . evil-org-mode))
#+END_SRC
-* Ace window
-#+BEGIN_SRC emacs-lisp
-(use-package ace-window
- :ensure t
- :after general
- :config
- (gmap "o" #'ace-window)
- (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
- aw-dispatch-always t))
+** Org superstar
+ #+BEGIN_SRC emacs-lisp
+ (use-package org-superstar
+ :hook (org-mode . org-superstar-mode))
+ #+END_SRC
+** Flyspell
+ #+BEGIN_SRC emacs-lisp
+ (use-package flyspell
+ :hook (org-mode . flyspell-mode))
+ (use-package flyspell-correct-ivy
+ :after flyspell
+ :bind (:map org-mode-map
+ ("C-c C-a" . flyspell-correct-at-point)))
+ #+END_SRC
+* Major modes and Programming
+ Setups for common major modes and languages
+ Here are some basic packages for programming first
+** Smartparens
+ Smartparens is a smarter electric-parens, it's much more aware of stuff and easier to use.
+ #+BEGIN_SRC emacs-lisp
+ (use-package smartparens
+ :after evil
+ :config
+ (setq sp-highlight-pair-overlay nil
+ sp-highlight-wrap-overlay t
+ sp-highlight-wrap-tag-overlay t)
+ (smartparens-global-mode))
+ #+END_SRC
+** Show-paren-mode
+ Show parenthesis for Emacs
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'prog-mode-hook #'show-paren-mode)
+ #+END_SRC
+** Eglot
+ Eglot is a library of packages to communicate with LSP servers for better programming capabilities.
+ Interactions with a server provide results to the client, done through JSON.
+ #+BEGIN_SRC emacs-lisp
+ (use-package eglot
+ :hook (c++-mode . eglot-ensure)
+ :hook (c-mode . eglot-ensure)
+ :bind (:map eglot-mode-map
+ ("<f2>" . eglot-rename)
+ ("C-c C-A" . eglot-code-actions)
+ ("C-c f" . eglot-format))
+ :config
+ (add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd")))
+ #+END_SRC
+** Flycheck
+ Flycheck is the checking system for Emacs.
+ I don't necessarily like having all my code checked all the time, so I haven't added a hook to prog-mode as it would be better for me to decide when I want checking and when I don't.
+ #+BEGIN_SRC emacs-lisp
+ (use-package flycheck
+ :commands flycheck-mode
+ :bind ("C-c x" . flycheck-list-errors))
+ #+END_SRC
+** Activate tabs
+ Set tabs to nil by default, with normal tab size set to 2.
+ #+BEGIN_SRC emacs-lisp
+ (setq-default indent-tabs-mode nil
+ tab-width 2)
+ #+END_SRC
+
+ Add a function to activate tabs mode.
+ #+BEGIN_SRC emacs-lisp
+ (defun dx:activate-tabs ()
+ (interactive)
+ (setq indent-tabs-mode t))
+ #+END_SRC
+** C/C++
+*** C Offset
+ #+BEGIN_SRC emacs-lisp
+ (setq-default c-basic-offset 2)
+ #+END_SRC
+*** Clang format
+ use-package clang-format for ease of use formatting, binding to "C-c '" for both C and C++ mode maps.
+ #+BEGIN_SRC emacs-lisp
+ (use-package clang-format
+ :after cc-mode
+ :config
+ (bind-key "C-c '" #'clang-format-region c-mode-map)
+ (bind-key "C-c '" #'clang-format-region c++-mode-map))
+ #+END_SRC
+*** Tabs mode for C and C++
+ Add tabs to both C and C++ modes via =activate-tabs= function.
+ #+BEGIN_SRC emacs-lisp
+ (add-hook 'c-mode-hook #'dx:activate-tabs)
+ (add-hook 'c++-mode-hook #'dx:activate-tabs)
+ #+END_SRC
+*** Custom user style
+ Add a custom style which follows something like a 'Microsoft Style' in that it opens braces everywhere (for ease of reading).
+ #+BEGIN_SRC emacs-lisp
+ (c-add-style
+ "user"
+ '((c-basic-offset . 2)
+ (c-comment-only-line-offset . 0)
+ (c-hanging-braces-alist (brace-list-open)
+ (brace-entry-open)
+ (substatement-open after)
+ (block-close . c-snug-do-while)
+ (arglist-cont-nonempty))
+ (c-cleanup-list brace-else-brace)
+ (c-offsets-alist
+ (statement-block-intro . +)
+ (knr-argdecl-intro . 0)
+ (substatement-open . 0)
+ (substatement-label . 0)
+ (access-label . 0)
+ (label . 0)
+ (statement-cont . +))))
-#+END_SRC
-* Counsel
-#+BEGIN_SRC emacs-lisp
-(use-package counsel
- :ensure t
- :after general
- :config
- (gmap
- :infix "s"
- "s" #'swiper
- "r" #'counsel-rg)
- (general-def
- :keymaps 'ivy-minibuffer-map
- "C-j" #'ivy-next-line-or-history
- "C-k" #'ivy-previous-line-or-history))
-#+END_SRC
+ #+END_SRC
+
+*** Set default styles
+ Set the default style for modes
+ #+BEGIN_SRC emacs-lisp
+ (setq c-default-style '((java-mode . "java")
+ (awk-mode . "awk")
+ (other . "user")))
+ #+END_SRC
+
diff --git a/Emacs/.config/emacs/init.el b/Emacs/.config/emacs/init.el
index d560765..5015f68 100644
--- a/Emacs/.config/emacs/init.el
+++ b/Emacs/.config/emacs/init.el
@@ -1,35 +1,25 @@
-;;; init.el -- My custom emacs config
-;;; Commentary:
-;;; Simple Emacs config that uses org-babel to execute org files which contain a literate config
-;;; Code:
-
-(require 'package)
-(add-to-list 'package-archives (cons "melpa" "https://melpa.org/packages/") t)
-(package-initialize)
-(unless (fboundp 'use-package)
- (package-install 'use-package))
-
-(setq package-quickstart t)
-(use-package org
- :ensure t
- :config
- (org-babel-load-file "~/.config/emacs/config.org" t))
+;; Load literate
+(require 'ob-tangle)
+(setq user-emacs-directory "~/.config/emacs/")
+(mapc #'(lambda (x) (org-babel-load-file (concat user-emacs-directory x))) (list "config.org"))
+;; Programming
(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.
+ '(ansi-color-names-vector
+ ["#000000" "#5f8787" "#dd9999" "#a06666" "#888888" "#999999" "#888888" "#c1c1c1"])
+ '(ansi-term-color-vector
+ [unspecified "#2e2e2e" "#bc8383" "#7f9f7f" "#d0bf8f" "#6ca0a3" "#dc8cc3" "#8cd0d3" "#b6b6b6"])
'(custom-safe-themes
- '("71e5acf6053215f553036482f3340a5445aee364fb2e292c70d9175fb0cc8af7" "d74c5485d42ca4b7f3092e50db687600d0e16006d8fa335c69cf4f379dbd0eee" default))
+ '("0266c89aae71e5b03453145509ee4dd09817377c6df69c384e2e313da86fabd8" "7a89dff27d761c077685970ff22f17d66edef90ac0b083332cfe326af8592dfd" "4de73368daa1be83e74165ae20a393cf205f2023c3dab3fffec6fbf8c742fee7" "b236a062b2e913c08e456cdc3743029951e3fc3e3cb7a579018271e2927b91f7" "6724d9651afb36fbb52d1d2e5a612da7d3f6e8739c30fbc818441798d5526113" "30c98a55535d742be02b7d44f00965ee6acbb892a945f428f1875a210c51d536" "311ac10c551b531e895c110583108d667de691aa46a26a5d324339d22911e94b" "28cd8971a2cfe634ef4a42d5bfb305b8865761017372d5d202bd08590da198d9" "6e1a7768b8023e6c2075e4af23aefba3b3e5db18b06dbb1b18ef1949d6af9d94" "7cc79b0c9da3ad3150256023b9023f363719274939656f57f3d1eae6120c4c13" "12670281275ea7c1b42d0a548a584e23b9c4e1d2dabb747fd5e2d692bcd0d39b" "6a0edb6b0f4c6d0566325cf91a1a34daa179e1979136ce0a528bf83aff9b7719" "b3bcf1b12ef2a7606c7697d71b934ca0bdd495d52f901e73ce008c4c9825a3aa" "c968804189e0fc963c641f5c9ad64bca431d41af2fb7e1d01a2a6666376f819c" "d873c4ec3fa23a2eee0a08ccbb6266ea9511edf2e738e63bd2b7f867dde43cb6" default))
'(package-selected-packages
- '(evil-org doom-themes general evil-surround evil evil-mode ace-window magit counsel which-key yasnippet use-package))
+ '(magit evil-magit evil-commentary evil-surround use-package))
'(safe-local-variable-values
'((org-babel-default-header-args:elisp
- (:results . "none"))))
- '(send-mail-function 'smtpmail-send-it)
- '(smtpmail-smtp-server "smtp.gmail.com")
- '(smtpmail-smtp-service 25))
+ (:results . "none")))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.