!REFACTOR: cleaning doom

This refactor removes a lot of the 'training wheels' that doom
provides (i.e. no modeline, bindings, etc). Instead, I defined my own
modules and systems to help with those tasks. I am now using the default
emacs modeline, customised to my liking, as well as the default scratch
buffer as my startup page.

This basically allows me to have a finer degree of control over what my
Emacs is doing, which is great as I can remove redundant pieces that I
don't use.
This commit is contained in:
dx
2020-07-15 15:26:11 +01:00
parent 8b067497da
commit 3e7642cae1
6 changed files with 214 additions and 171 deletions

5
.gitignore vendored
View File

@@ -3,6 +3,7 @@ mpd/*
ncmpcpp/*
Emacs/.config/emacs/transient/*
Emacs/.config/emacs/straight/*
/Doom/.doom.d/org/*.el
Doom/.doom.d/org/*.el
*.elc
/Emacs/.config/emacs/elpa/
Emacs/.config/emacs/elpa/
Doom/.doom.d/modules/private/bindings/*.el

View File

@@ -8,10 +8,12 @@
;; More information about these modules (and what flags they support) can be
;; found in modules/README.org.
(doom! :private
(oreoline)
;;(oreoline)
(bindings)
(startup)
(gentemplate)
(ocaml +lsp)
(rss +elfeed)
;; (ocaml +lsp)
;; (rss +elfeed)
(narrow)
;;(completion)
@@ -21,16 +23,16 @@
:completion
(company +childframe) ; the ultimate code completion backend
(ivy
+fuzzy
+icons) ; a search engine for love and life
;; (ivy
;; +fuzzy
;; +icons) ; a search engine for love and life
;;helm ; the *other* search engine for love and life
;;ido ; the other *other* search engine...
ido ; the other *other* search engine...
:ui
;;deft ; notational velocity for Emacs
doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs
;; doom-dashboard ; a nifty splash screen for Emacs
doom-quit ; DOOM quit-message prompts when you quit Emacs
;;fill-column ; a `fill-column' indicator
hl-todo ; highlight TODO/FIXME/NOTE tags
@@ -50,7 +52,7 @@
vc-gutter ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
window-select ; visually switch windows
workspaces ; tab emulation, persistence & separate workspaces
;;workspaces ; tab emulation, persistence & separate workspaces
zen
:editor
@@ -151,7 +153,7 @@
(python +lsp) ; beautiful is better than ugly
;;qt ; the 'cutest' gui framework ever
;;racket ; a DSL for DSLs
rest ; Emacs as a REST client
;;rest ; Emacs as a REST client
;;ruby ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good
@@ -173,7 +175,7 @@
:app
;;calendar
;;irc ; how neckbeards socialize
(rss) ; emacs as an RSS reader
;;rss ; emacs as an RSS reader
;;twitter ; twitter client https://twitter.com/vnought
:config
@@ -184,7 +186,7 @@
;; The default module sets reasonable defaults for Emacs. It also
;; provides a Spacemacs-inspired keybinding scheme and a smartparens
;; config. Use it as a reference for your own modules.
(default +bindings +smartparens))
(default +smartparens))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.

View File

@@ -0,0 +1,157 @@
#+TITLE: private/bindings Literate configuration
#+PROPERTY: header-args(elisp) :tangle config.el
* Introduction
This is the main document for this module (=private/bindings=).
To compile, simply execute the source code block below
#+BEGIN_SRC elisp :tangle no
(org-babel-tangle-file "README.org" "config.el")
#+END_SRC
* Initial
#+BEGIN_SRC elisp
;;; private/bindings/config.el -*- lexical-binding: t; -*-
#+END_SRC
* Leader
Bindings for the leader map
** Single binds
These are immediate bindings to the leader map that instantly launch functions when pressed.
This binding space is reserved for stuff I use quite often.
#+BEGIN_SRC elisp
(map!
:leader
"SPC" #'execute-extended-command
"!" #'async-shell-command
"T" #'eshell
"-" #'dired-jump
"_" #'dired-jump-other-window
";" #'eval-expression
"h" #'help-command
"w" #'ace-window)
#+END_SRC
** Files
#+BEGIN_SRC elisp
(map!
:leader
:prefix "f"
"r" #'counsel-recentf
"f" #'find-file
"p" #'(lambda () (interactive) (doom-project-find-file "~/Dotfiles"))
"s" #'save-buffer
"d" #'dired)
#+END_SRC
** Buffers
#+BEGIN_SRC elisp
(map!
:leader
:prefix "b"
"n" #'next-buffer
"p" #'previous-buffer
"d" #'kill-current-buffer
"b" #'switch-to-buffer
"i" #'ibuffer)
#+END_SRC
** Search
#+BEGIN_SRC elisp
(map!
:leader
:prefix "s"
"i" #'imenu
(:after counsel
"s" #'swiper
"r" #'counsel-rg)
(:after counsel-etags
"t" #'counsel-etags-find-tag)
"o" #'+lookup/online)
#+END_SRC
** Projectile
#+BEGIN_SRC elisp
(map!
:leader
:after projectile
:desc "Switch to p-buffer" ">" #'projectile-switch-to-buffer
:desc "Projects" "p" #'projectile-switch-project
(:prefix ("p" . "project")
:desc "Regen tags" "g" #'projectile-regenerate-tags
:desc "Open project files" "f" #'projectile-find-file))
#+END_SRC
** Code
#+BEGIN_SRC elisp
(map!
:leader
:prefix ("c" . "code") ; Code
:desc "Compile" "c" #'compile
:desc "Compile via make" "m" #'+make/run
:desc "Undo tree" "u" #'undo-tree-visualize
(:after lsp
:desc "Format code lsp" "f" #'+default/lsp-format-region-or-buffer
:desc "Execute action" "a" #'lsp-execute-code-action))
#+END_SRC
** Magit and VC
#+BEGIN_SRC elisp
(map!
:leader
:prefix "g"
"g" #'magit-status
"c" #'magit-clone
"f" #'magit-fetch
"p" #'magit-pull)
#+END_SRC
** Notes
#+BEGIN_SRC elisp
(map!
:leader
:prefix ("n" . "notes")
:desc "Open notes in dired" "-" #'(lambda () (interactive) (dired org-directory))
:desc "Open quicknotes" "q" #'(lambda () (interactive) (find-file (format "%s/qnotes.org" org-directory))))
#+END_SRC
** Frames
#+BEGIN_SRC elisp
(map!
:leader
:prefix "F"
"d" #'delete-frame)
#+END_SRC
* Company
#+BEGIN_SRC elisp
(map!
:map (company-search-map company-mode-map)
"C-j" #'company-select-next
"C-k" #'company-select-previous
"C-SPC" #'company-complete)
#+END_SRC
* Multi cursors
Setup bindings for multi cursors.
As it's a motion based system, use the "gz" namespace.
#+BEGIN_SRC elisp
(map!
:prefix "g"
(:prefix "z"
"m" #'evil-mc-resume-cursors
"p" #'evil-mc-pause-cursors
"d" #'evil-mc-make-all-cursors
"j" #'evil-mc-make-cursor-move-next-line
"k" #'evil-mc-make-cursor-move-prev-line
"z" #'evil-mc-make-cursor-at-pos))
#+END_SRC
* Quit
Quit Emacs or restart it
#+BEGIN_SRC elisp
(map!
:prefix "q"
"q" #'save-buffers-kill-terminal
"r" #'doom/restart)
#+END_SRC
* Remaps
#+BEGIN_SRC elisp
(define-key!
[remap org-goto] #'counsel-org-goto)
#+END_SRC
* Misc
Misc bindings that don't fit to any other category.
#+BEGIN_SRC elisp
(map!
"C-x C-z" #'text-scale-adjust
"TAB" #'evil-jump-item
"M-c" #'count-words-region
"M-s" #'occur)
#+END_SRC

View File

@@ -0,0 +1,10 @@
#+TITLE: private/startup
#+DATE: July 15, 2020
* Description
Basically setup the default Emacs mode-line and the scratch buffer for ease of use.
This replaces the =modeline= and =doom-dashboard= modules as it leverages the default Emacs utilities.
* Prerequisites
Emacs of some kind, preferably 27 just for the sake of preserving versioning.
* Requirements
None

View File

@@ -0,0 +1,12 @@
;;; private/startup/config.el -*- lexical-binding: t; -*-
(defun +startup/create-scratch-message ()
"Generate a string for the scratch buffer"
(format "Welcome to Emacs! (。◕‿◕。)
Load time was %s
Time of startup: %s"
(emacs-init-time)
(current-time-string (current-time))))
(setq-default mode-line-format (list "%l:%c %P \t %+%b(" '(:eval (format "%s" major-mode)) ") \t %I \t" vc-mode mode-line-end-spaces))
(setq initial-scratch-message (+startup/create-scratch-message))

View File

@@ -36,9 +36,18 @@ For some reason, currently, the org mode keybinds aren't working.
So reload the file again until the issue is fixed.
#+BEGIN_SRC elisp
(load "~/.emacs.d/modules/lang/org/config.el")
* Package Configuration
Configuration for or based heavily around specific packages that I find very important
** Ido
Just add vimish keybindings to ido completion
#+BEGIN_SRC elisp
(map!
:map (ido-common-completion-map ido-file-completion-map ido-buffer-completion-map)
"C-k" #'ido-prev-match
"C-j" #'ido-next-match)
(setq ido-ignore-buffers '("\\` " "^\\*ESS\\*" "^\\*[Hh]elp" "^\\*.*Completions\\*$" "^\\*tramp" "^\\*cvs-" "^*Ido"))
#+END_SRC
* Package Config
Config for or based heavily around specific packages that I find very important
** DAP
*** Function
First to setup is a routine for setting up all the dap-panes for debugging.
@@ -60,56 +69,6 @@ Easier to do than just running all those functions manually
:leader
:desc "Start debugging setup" "cD" #'dx:debug)
#+END_SRC
** Dashboard
My very own dashboard config using doom dashboard, with these features:
- Custom load message
- Custom splash image and dashboard buffer name
- Custom dashboard sections for myself
*** Benchmark display
Redo the display-benchmark function to display a different message
#+BEGIN_SRC elisp
(defun doom-display-benchmark-h (&optional return-p)
"Display a benchmark, showing number of packages and modules, and how quickly
they were loaded at startup.
If RETURN-P, return the message as a string instead of displaying it."
(funcall (if return-p #'format #'message)
"εmacs loaded %d packages, %d modules in %.03fs"
(- (length load-path) (length doom--initial-load-path))
(if doom-modules (hash-table-count doom-modules) 0)
(or doom-init-time
(setq doom-init-time
(float-time (time-subtract (current-time) before-init-time))))))
#+END_SRC
*** Image and buffer name
Set the splash-image and dashboard buffer name
Space image comes from [[https://flaticon.com][website]]
#+BEGIN_SRC elisp
(setq fancy-splash-image "~/Pictures/SplashScreens/space2.png") ; splash image
(setq +doom-dashboard-name "*dashboard*")
#+END_SRC
*** Dashboard items
Set the dashboard functions (segments in overall buffer), set the sections of the interactive menu as well.
#+BEGIN_SRC elisp
(setq +doom-dashboard-functions ; limit the dashboard items
'(doom-dashboard-widget-banner
doom-dashboard-widget-loaded
doom-dashboard-widget-shortmenu))
(setq +doom-dashboard-menu-sections ; Set a specific amount of items
'(("Open org-agenda"
:icon (all-the-icons-octicon "calendar" :face 'font-lock-keyword-face)
:when (fboundp 'org-agenda)
:action org-agenda)
("Jump to bookmark"
:icon (all-the-icons-octicon "bookmark" :face 'font-lock-keyword-face)
:action bookmark-jump)
("Open project"
:icon (all-the-icons-material "folder" :face 'font-lock-keyword-face)
:action projectile-switch-project)))
#+END_SRC
** Spelling checker
Keybinds to org-mode for flyspell package
#+BEGIN_SRC elisp
@@ -373,111 +332,6 @@ General keymap
:desc "Change theme" "t" #'dx:themes/set-new-theme ; From my own collection
:desc "Generate template" "g" #'+gentemplate/generate-template) ; From my own collection
#+END_SRC
** Counsel
- Counsel keybind config
- Mostly just convenience stuff that happens to use counsel
#+BEGIN_SRC elisp
(map!
:leader
(:prefix ("s" . "search")
:desc "RipGrep!" "r" #'counsel-rg ; Ripgrep is faster than Ag in most cases and makes me feel cool
:desc "Search Tags" "t" #'counsel-etags-find-tag)); is quicker to do than <SPC>/b, for something that is done so often
#+END_SRC
** Window
- Keybinds to do with windows
- SPC wc < SPC wd
- Some ace-window config in the window keybind prefix
#+BEGIN_SRC elisp
(map!
:leader
:prefix ("w" . "window") ; Windows
:desc "Close window" "d" #'+workspace/close-window-or-workspace ; is slightly closer together than <SPC>wc
:desc "Switch window" "w" #'ace-window ; is also used in spacemacs so I'd rather use this
:desc "Swap windows" "S" #'ace-swap-window) ; allows me to switch windows more efficiently than before, better than just motions
#+END_SRC
** Code
- Some keybinds for the code prefix which help me with coding or working with code, particularly LSP
#+BEGIN_SRC elisp
(map!
:leader
:prefix ("c" . "code") ; Code
:desc "Compile" "c" #'compile
:desc "Recompile" "C" #'recompile
:desc "Compile via make" "m" #'+make/run
:desc "Undo tree" "u" #'undo-tree-visualize
:desc "Narrow to function" "n" #'+narrow/toggle-narrow
(:after format-all
:desc "Format code" "=" #'format-all-buffer)
(:after lsp
:desc "Format code lsp" "f" #'+default/lsp-format-region-or-buffer
:desc "Execute action" "a" #'lsp-execute-code-action)
(:after dap-mode
:desc "Debug hydra" "h" #'dap-hydra))
#+END_SRC
** Projectile
- Projectile config, for leader and for project prefix
#+BEGIN_SRC elisp
(map!
:leader
:after projectile
:desc "Switch to p-buffer" ">" #'projectile-switch-to-buffer ; Opposing <SPC>< which counsel's all buffers
(:prefix ("p" . "project")
:desc "Regen tags" "g" #'projectile-regenerate-tags
:desc "Open project files" "f" #'projectile-find-file))
#+END_SRC
** Fonts
- Fonts keybinds (prefix "z") for messing with fonts temp on a buffer
- Really useful when I need to zoom into something for whatever reason
#+BEGIN_SRC elisp
(map!
:leader
:prefix ("z" . "font") ; Fonts
:desc "Increase font" "+" #'doom/increase-font-size
:desc "Decrease font" "-" #'doom/decrease-font-size
:desc "Adjust font" "z" #'text-scale-adjust)
#+END_SRC
** Frames
- Keybinds for frame manipulation:
- Generate new frames from current buffer
- Generate new frames from a specific buffer
- Delete frames
- Switch frames
#+BEGIN_SRC elisp
(map!
:leader
:prefix ("F" . "frame") ; Frames
:desc "Kill frame" "d" #'delete-frame
:desc "Current buffer frame" "m" #'make-frame
:desc "Choose Buffer frame" "n" #'display-buffer-other-frame
:desc "Switch frames" "o" #'other-frame)
#+END_SRC
** Misc Leader
Miscellaneous leader bindings that don't really fit into any particular item
#+BEGIN_SRC elisp
(map!
:leader
:desc "M-x" "SPC" #'execute-extended-command ; Redefine as M-x because of my muscle memory with spacemacs
:desc "Shell command" "!" #'async-shell-command ; Better than M-!
:desc "Open eshell" "T" #'eshell
(:prefix ("b" . "buffers")
:desc "Close buffer" "d" #'doom/kill-this-buffer-in-all-windows)
(:prefix ("f" . "files")
:desc "Recent files" "r" #'counsel-recentf
:desc "Find in dotfiles" "p" #'(lambda () (interactive) (doom-project-find-file "~/Dotfiles")))
(:prefix ("n" . "notes")
:desc "Open notes in dired" "-" #'(lambda () (interactive) (dired org-directory))
:desc "Open quicknotes" "q" #'(lambda () (interactive) (find-file (format "%s/qnotes.org" org-directory)))))
#+END_SRC
** Non-leader
Non-leader bindings for text-based commands.
#+BEGIN_SRC elisp
(map!
:n "TAB" #'evil-jump-item
:n "M-v" #'dx:newline
:n "M-V" #'(lambda () (interactive) (dx:newline 1))
:v "M-c" #'count-words-region
:n "M-s" #'occur)
#+END_SRC
** Remaps
Adding a new configuration option.
Remapping functions that other modules set to default functions.
@@ -485,3 +339,10 @@ Remapping functions that other modules set to default functions.
(define-key!
[remap compile] #'compile)
#+END_SRC
** Non-leader
Non-leader bindings for text-based commands.
#+BEGIN_SRC elisp
(map!
"M-v" #'dx:newline
"M-V" #'(lambda () (interactive) (dx:newline 1)))
#+END_SRC