aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emacs/.config/emacs/+org.el78
-rw-r--r--Emacs/.config/emacs/config.org248
-rw-r--r--Emacs/.config/emacs/init.el167
3 files changed, 351 insertions, 142 deletions
diff --git a/Emacs/.config/emacs/+org.el b/Emacs/.config/emacs/+org.el
new file mode 100644
index 0000000..aa5e755
--- /dev/null
+++ b/Emacs/.config/emacs/+org.el
@@ -0,0 +1,78 @@
+(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/config.org b/Emacs/.config/emacs/config.org
new file mode 100644
index 0000000..c99bbe7
--- /dev/null
+++ b/Emacs/.config/emacs/config.org
@@ -0,0 +1,248 @@
+#+TITLE: Config for Emacs
+#+AUTHOR: Oreodave
+#+DESCRIPTION: My bespoke config for Emacs
+#+PROPERTY: header-args :tangle yes
+
+* 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
+ #+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.
+ #+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")
+
+ (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)
+
+ (add-hook 'prog-mode-hook #'hs-minor-mode)
+ (add-hook 'prog-mode-hook #'display-line-numbers-mode)
+ #+END_SRC
+** Set some useful variables
+ Truncate lines, display number lines and stop making backup files (for now).
+ #+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.
+ #+BEGIN_SRC emacs-lisp
+ (ido-mode +1)
+ #+END_SRC
+* Keybindings
+** Keychord
+ Setup key chord, pretty basic config.
+ #+BEGIN_SRC emacs-lisp
+ (use-package key-chord
+ :ensure t
+ :config
+ (key-chord-mode +1))
+ #+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.
+ #+BEGIN_SRC emacs-lisp
+ (use-package general
+ :ensure t
+ :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.
+ #+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)
+)
+ #+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
+ #+BEGIN_SRC emacs-lisp
+ (use-package helpful
+ :after general
+ :ensure t
+ :config
+ (gmap
+ :infix "h"
+ "f" #'helpful-callable
+ "v" #'helpful-variable
+ "k" #'helpful-key))
+ #+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))
+
+(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=.
+ #+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
+
+* Org-mode
+** Vanilla org mode
+ #+BEGIN_SRC emacs-lisp
+ (use-package org
+ :ensure t
+ :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))
+ #+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
+ #+BEGIN_SRC emacs-lisp
+ (use-package magit
+ :ensure t
+ :after general
+ :config
+ (gmap
+ "g" #'magit-status))
+
+
+ #+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))
+
+
+#+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
+
+
diff --git a/Emacs/.config/emacs/init.el b/Emacs/.config/emacs/init.el
index 1814d34..d560765 100644
--- a/Emacs/.config/emacs/init.el
+++ b/Emacs/.config/emacs/init.el
@@ -9,147 +9,30 @@
(unless (fboundp 'use-package)
(package-install 'use-package))
-(setq user-emacs-directory (expand-file-name "~/.config/emacs/")
- ring-bell-function 'ignore
- inhibit-startup-screen t)
-
-(tool-bar-mode -1)
-(scroll-bar-mode -1)
-(tab-bar-mode -1)
-(load-theme 'tango-dark)
-(add-hook 'prog-mode-hook #'hs-minor-mode)
-
-(use-package evil
- :ensure t
- :config
- (evil-mode +1))
-
-(use-package evil-surround
- :ensure t
- :after (evil)
- :config
- (evil-surround-mode +1))
-
-(use-package which-key
+(setq package-quickstart t)
+(use-package org
:ensure t
:config
- (which-key-mode +1))
-
-(use-package general
- :ensure t
- :config
- (general-create-definer leader
- :prefix "SPC"
- :states 'normal
- :keymaps 'override)
-
- (general-create-definer localleader
- :prefix ","
- :states 'normal
- :keymaps 'override)
-
- (general-def
- "M-s" nil
- "M-s" #'occur)
-
- (leader
- "!" #'async-shell-command
- "f" '(:ignore t :wk "File")
- "s" '(:ignore t :wk "Search")
- "b" '(:ignore t :wk "Buffer"))
-
- (general-def
- :states 'visual
- "gr" #'eval-region)
-
- (leader
- :infix "b"
- "n" #'next-buffer
- "p" #'previous-buffer
- "b" #'counsel-switch-buffer
- "i" #'ibuffer)
-
- (leader
- :infix "o"
- "-" #'dired)
-
- (leader
- :infix "f"
- "s" #'save-buffer
- "f" #'find-file
- "p" #'((lambda () (interactive) (find-file "~/.config/emacs/init.el"))
- :wk "Open init.el")))
-
-(use-package counsel
- :ensure t
- :general
- (leader
- "SPC" #'counsel-M-x)
- (leader
- :infix "s"
- "s" #'(swiper :wk "Search buffer")
- "r" #'(counsel-rg :wk "Ripgrep"))
- (general-def
- :keymaps 'ivy-minibuffer-map
- "C-j" #'ivy-next-line-or-history
- "C-k" #'ivy-previous-line-or-history)
- :init
- (counsel-mode +1))
-
-(use-package org :ensure t)
-
-(use-package magit :ensure t)
-
-(use-package evil-magit :ensure t)
-
-(use-package telephone-line
- :ensure t
- :hook (after-init . telephone-line-mode)
- :init
- ; Faces
- (defface my-accent-dark '((t (:foreground "Black" :background "Cadet Blue"))) "")
- (defface my-evil-dark '((t (:foreground "White" :background "Black"))) "")
- (defface my-accent-light '((t (:foreground "black" :background "Light Slate Grey"))) "")
- (defface my-evil-light '((t (:foreground "black" :background "Sky Blue"))) "")
-
- ;; Set telephone line faces
- (setq telephone-line-faces
- '((evil . (my-evil-dark . my-evil-dark))
- (modal . telephone-line-modal-face)
- (ryo . telephone-line-ryo-modal-face)
- (accent . (my-accent-dark . telephone-line-accent-inactive))
- (nil mode-line . mode-line-inactive)))
-
- ; Seperators
- (setq telephone-line-primary-left-separator 'telephone-line-abs-left
- telephone-line-secondary-left-separator 'telephone-line-identity-hollow-left
- telephone-line-primary-right-separator 'telephone-line-abs-right
- telephone-line-secondary-right-separator 'telephone-line-identity-hollow-right)
-
- ; LSP segment
- (telephone-line-defsegment +oreoline-lsp-segment ()
- (if (bound-and-true-p lsp-mode)
- (propertize "")
- (propertize "")))
-
- ; LHS
- (setq telephone-line-lhs
- '((evil . (telephone-line-evil-tag-segment
- telephone-line-buffer-modified-segment))
- (accent . (telephone-line-vc-segment
- telephone-line-filesize-segment
- telephone-line-buffer-name-segment
- telephone-line-erc-modified-channels-segment
- telephone-line-process-segment))
- (nil . ())))
-
- ; RHS
- (setq telephone-line-rhs
- '((nil . (telephone-line-misc-info-segment))
- (accent . (telephone-line-major-mode-segment
- +oreoline-lsp-segment
- telephone-line-flycheck-segment))
- (evil . (telephone-line-airline-position-segment))))
- (telephone-line-mode +1)
- :config
- (size-indication-mode +1))
+ (org-babel-load-file "~/.config/emacs/config.org" t))
+
+(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.
+ '(custom-safe-themes
+ '("71e5acf6053215f553036482f3340a5445aee364fb2e292c70d9175fb0cc8af7" "d74c5485d42ca4b7f3092e50db687600d0e16006d8fa335c69cf4f379dbd0eee" default))
+ '(package-selected-packages
+ '(evil-org doom-themes general evil-surround evil evil-mode ace-window magit counsel which-key yasnippet 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))
+(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.
+ )