Import earnemacs with patches to make it less configurable

old-yadm
earnest ma 2021-07-03 11:13:54 -04:00
parent 6aa9c2ed45
commit 80c70bfca8
No known key found for this signature in database
GPG Key ID: 6B361FA81C5FB695
34 changed files with 1498 additions and 0 deletions

7
.config/emacs/config.el Normal file
View File

@ -0,0 +1,7 @@
(setq
user-full-name "earnest ma"
user-mail-address "me@earne.link"
calendar-latitude 43.70011
calendar-longitude -79.4163
)

View File

@ -0,0 +1,168 @@
;;; earnecore-display.el --- Display -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
;; Misc
(setq frame-title-format (list "%b %* " earnemacs-daemon-name "@" system-name)
truncate-string-ellipsis ""
use-file-dialog nil
use-dialog-box nil)
;; Show column number in modeline
(setq-default column-number-mode t)
;; Font: More set below, this is just in case for the daemon
(add-to-list 'default-frame-alist '(font . "Fira Code 11"))
;; Modeline
(use-package doom-modeline
:demand
:init (doom-modeline-mode 1)
:config
(display-time-mode 1)
(if (equal "Battery status not available"
(battery))
()
(display-battery-mode 1)))
;; Dashboard
(use-package dashboard
:demand
;; Prevent issues when opening through Daemon - will see scratch buffer instead
:if (< (length command-line-args) 2)
:config
(dashboard-setup-startup-hook)
;; Customizations
(setq dashboard-banner-logo-title "Welcome to earnemacs!")
(setq dashboard-startup-banner 'logo)
(setq dashboard-set-footer nil)
(setq dashboard-items
'((recents . 5)
(bookmarks . 5)
(agenda . 5)
(projects . 5))))
;; Tabs
(use-package tab-bar
:straight nil
:bind
(:map tab-prefix-map
("n" . tab-next)
("p" . tab-previous)
("t" . tab-new)
("x" . tab-close)
("X" . tab-close-other)
("C-x" . tab-bar-undo-close-tab))
:general
(earnemacs-spc-def "T" '(:keymap tab-prefix-map :wk "Tab"))
:init
(tab-bar-mode))
;; Scrolling
(setq mouse-wheel-scroll-amount '(2 ((shift) . 1)))
(setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-follow-mouse 't)
(setq scroll-step 1)
;; Frame opacity
(defun earnemacs-adjust-opacity (frame incr)
"Adjust the background opacity of FRAME by increment INCR.
From purcell/emacs.d"
(unless (display-graphic-p frame)
(error "Cannot adjust opacity of this frame"))
(let* ((oldalpha (or (frame-parameter frame 'alpha) 100))
;; The 'alpha frame param became a pair at some point in
;; emacs 24.x, e.g. (100 100)
(oldalpha (if (listp oldalpha) (car oldalpha) oldalpha))
(newalpha (+ incr oldalpha)))
(when (and (<= frame-alpha-lower-limit newalpha) (>= 100 newalpha))
(modify-frame-parameters frame (list (cons 'alpha newalpha))))))
(earnemacs-spc-def
;; Frame opacity keybindings
"t0" '(:def (lambda () (interactive) (modify-frame-parameters nil
`((alpha . 100))))
:wk "Reset transparency")
"t-" '(:def (lambda () (interactive) (earnemacs-adjust-opacity nil -10))
:wk "Decrease transparency")
"t=" '(:def (lambda () (interactive) (earnemacs-adjust-opacity nil 10))
:wk "Increase transparency"))
;; Increase/ decrease font size
(defun font-name-replace-size (font-name new-size)
(let ((parts (split-string font-name "-")))
(setcar (nthcdr 7 parts) (format "%d" new-size))
(mapconcat 'identity parts "-")))
(defun increment-default-font-height (delta)
"Adjust the default font height by DELTA on every frame.
The pixel size of the frame is kept (approximately) the same.
DELTA should be a multiple of 10, in the units used by the
:height face attribute. From purcell/emacs.d"
(let* ((new-height (+ (face-attribute 'default :height) delta))
(new-point-height (/ new-height 10)))
(dolist (f (frame-list))
(with-selected-frame f
;; Latest 'set-frame-font supports a "frames" arg, but
;; we cater to Emacs 23 by looping instead.
(set-frame-font (font-name-replace-size (face-font 'default)
new-point-height)
t)))
(set-face-attribute 'default nil :height new-height)
(message "default font size is now %d" new-point-height)))
;; Functions, keybindings for size
(defun increase-default-font-height ()
(interactive)
(increment-default-font-height 10))
(defun decrease-default-font-height ()
(interactive)
(increment-default-font-height -10))
(earnemacs-spc-def
;; -/+ zooms in/out using `text-scale-...'
"z0" 'text-scale-adjust
"z-" 'text-scale-decrease
"z=" 'text-scale-increase
;; Shift -/+ increases the default font height
"z+" 'increase-default-font-height
"z_" 'decrease-default-font-height)
;; -
;; Setup font/ transparency/ display of frame
(defun earnemacs--frame-hook ()
"Font and transparency settings. This is in a hook because Emacs doesn't
really like setting fonts/ transparency when run through a daemon."
(if (not (null earnemacs-transparent-frame))
(modify-all-frames-parameters `((alpha . 95))))
(set-face-attribute 'default nil
:font "Fira Code"
:height earnemacs-default-face-height)
(set-face-attribute 'fixed-pitch nil
:font "Fira Code"
:height earnemacs-fixed-face-height)
(set-face-attribute 'variable-pitch nil
:font "FiraGO"
:height earnemacs-variable-face-height))
;; Run earnemacs--frame-hook, if daemon nothing will happen, but the hook will
;; set everything when it needs to.
(earnemacs--frame-hook)
(add-hook 'server-after-make-frame-hook 'earnemacs--frame-hook)
;; Give focus when a new client frame is created
(add-hook 'server-after-make-frame-hook
(lambda () (select-frame-set-input-focus (selected-frame))))
(provide 'earnecore-display)
;;; earnecore-display.el ends here

View File

@ -0,0 +1,71 @@
;;; earnecore-editing.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;;
;;; Code:
(use-package editorconfig
:demand
:config
(editorconfig-mode 1))
;; Improve performance for large files
(global-so-long-mode 1)
;; Automatically revert buffers when changed on disk
(global-auto-revert-mode 1)
;; Save and restore place in file
(save-place-mode +1)
;; Auto-saving/ backup/ lockfiles
(use-package super-save
:demand
:config
(super-save-mode +1)
(setq super-save-auto-save-when-idle t)
(setq super-save-remote-files nil)
(setq super-save-exclude '(".gpg")))
(setq backup-by-copying t
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
;; crux (A Collection of Ridiculously Useful eXtensions for Emacs)
(use-package crux
:general
(earnemacs-spc-def
"fr" 'crux-sudo-edit))
;; "Paste menu" - taken and adapted with <3 from Doom Emacs
(defun earnemacs/paste ()
"Interactively select what text to insert from the kill ring."
(interactive)
(call-interactively
(cond ((fboundp 'counsel-yank-pop) #'counsel-yank-pop)
((error "No kill-ring search backend available.")))))
(earnemacs-spc-def "ip" 'earnemacs/paste)
;; yes or no -> y or n
(fset 'yes-or-no-p 'y-or-n-p)
;; Windows: open current directory in explorer.exe
(when *sys-windows*
(defun earnemacs/open-current-dir-in-explorer ()
"Open the currently visited directory in Windows Explorer."
(interactive)
(shell-command "explorer.exe .")))
(setq delete-by-moving-to-trash t)
(setq-default fill-column 80)
(provide 'earnecore-editing)
;;; earnecore-editing.el ends here

View File

@ -0,0 +1,121 @@
;;; earnecore-keybinds.el --- Evil mode and keys -*- lexical-binding: t; -*-
;; Copyright (C) 2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Evil
(use-package evil
:demand
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-fine-undo t)
:config
(evil-mode 1)
(setq evil-split-window-below t
evil-vsplit-window-right t)
(evil-ex-define-cmd "W" 'evil-write-all)
(evil-ex-define-cmd "Q" 'save-buffers-kill-emacs))
;; which-key
(use-package which-key
:demand
:config
(which-key-mode))
;; General
(use-package general
:demand
:config
(general-create-definer earnemacs-spc-def
:states '(normal emacs insert visual)
:prefix "SPC"
:non-normal-prefix "C-SPC")
;; Base SPC keybindings
(earnemacs-spc-def
"." 'find-file
";" 'eval-expression
":" 'shell-command
"b" '(:wk "Buffer")
"be" 'eval-buffer
"bk" 'kill-buffer
"bK" 'kill-current-buffer
"br" 'revert-buffer
"bs" 'save-buffer
"bS" 'save-some-buffers
"bx" '(:def (lambda () (interactive) (switch-to-buffer "*scratch*"))
:wk "scratch buffer")
"bz" 'bury-buffer
"bZ" 'unbury-buffer
"b <left>" 'switch-to-next-buffer
"b <right>" 'switch-to-prev-buffer
"c" '(:wk "Code")
"f" '(:wk "File")
"ff" 'find-file
"fP" '(:def (lambda () (interactive)
(find-file (concat earnemacs-root-dir "config.el")))
:wk "open config file")
"fs" 'save-buffer
"fS" '(:def (lambda () (interactive) (save-buffer ""))
:wk "save buffer as")
"fy" '(:def (lambda () (interactive) (kill-new buffer-file-name))
:wk "kill path to buffer")
"fY" '(:def (lambda () (interactive) (kill-new default-directory))
:wk "kill current dir path")
"g" '(:wk "Git")
"h" '(:keymap help-map :wk "Help")
"i" '(:wk "Insert")
"o" '(:wk "Open")
"oe" 'eshell
"of" 'make-frame-command
"oS" 'shell
"q" '(:wk "Quit/Reload")
"qf" 'delete-frame
"qK" 'save-buffers-kill-emacs
"qq" 'save-buffers-kill-terminal
"qQ" 'evil-quit-all-with-error-code
"t" '(:wk "Toggle")
"tf" 'toggle-frame-fullscreen
"tF" 'flycheck-mode
"tr" 'read-only-mode
"to" 'olivetti-mode
"tv" 'variable-pitch-mode
"tw" 'visual-line-mode
"w" '(:wk "Window")
"w=" 'balance-windows
"w-" 'evil-window-decrease-height
"w+" 'evil-window-increase-height
"w<" 'evil-window-decrease-width
"w>" 'evil-window-increase-width
"wh" 'evil-window-left
"wj" 'evil-window-down
"wk" 'evil-window-top
"wl" 'evil-window-right
"wd" 'evil-window-delete
"wn" 'evil-window-new
"wq" 'evil-quit
"ww" 'evil-window-next
"wv" 'evil-window-vsplit
"wt" 'tear-off-window
))
(provide 'earnecore-keybinds)
;;; earnecore-keybinds.el ends here

View File

@ -0,0 +1,50 @@
;;; earnecore-pkg.el --- Misc -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
;; Keep the emacs config directory clean
(use-package no-littering
:demand
:config
;; Exclude directories from recentf
(with-eval-after-load 'recentf
(add-to-list 'recentf-exclude no-littering-etc-directory)
(add-to-list 'recentf-exclude no-littering-var-directory))
(setq ; save some files to different files for daemon(s)
recentf-save-file (concat no-littering-var-directory
"recentf-save-" earnemacs-daemon-name ".el")
bookmark-default-file (concat no-littering-var-directory
"bookmark-" earnemacs-daemon-name ".el")
projectile-cache-file (concat no-littering-var-directory
"projectile/cache-" earnemacs-daemon-name ".el")
projectile-known-projects-file (concat no-littering-var-directory
"projectile/known-projects-"
earnemacs-daemon-name ".el")))
;; Do not keep or load a custom file
(setq custom-file (expand-file-name
(format
"custom-%d-%d.el" (emacs-pid) (random))
temporary-file-directory))
;; Native comp adjustments
(defun earnemacs--native-comp-adjustments ()
"Adjustments when using Emacs built with native compilation."
(setq comp-async-report-warnings-errors nil))
(if (and (fboundp 'native-comp-available-p)
(native-comp-available-p))
(earnemacs--native-comp-adjustments))
;; Inherit environment variables from shell
(use-package exec-path-from-shell
:if (or *sys-bsd* *sys-linux* *sys-mac*)
:init
(exec-path-from-shell-initialize))
(provide 'earnecore-pkg)
;;; earnecore-pkg.el ends here

View File

@ -0,0 +1,28 @@
;;; earnecore-projects.el --- Project management -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;;
;;; Code:
(use-package projectile
:general
(general-def
:keymaps 'projectile-command-map "A"
'projectile-add-known-project)
(earnemacs-spc-def
"SPC" 'projectile-find-file
"," 'projectile-switch-to-buffer
"p" '(:keymap projectile-command-map :package projectile :wk "Projectile"))
:config
(projectile-mode +1)
(when (file-directory-p "~/ghq")
(setq projectile-project-search-path '("~/ghq"))))
(provide 'earnecore-projects)
;;; earnecore-projects.el ends here

View File

@ -0,0 +1,25 @@
;;; earnecore-theme.el --- Theme -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;;
;;; Code:
(defvar earnemacs-theme 'doom-dracula
"Theme to load. Change in load.el")
(use-package doom-themes
:demand
:config
(doom-themes-visual-bell-config))
(use-package modus-themes)
(load-theme earnemacs-theme t)
(provide 'earnecore-theme)
;;; earnemod-base-theme.el ends here

View File

@ -0,0 +1,84 @@
;;; earnemacs-main.el --- earnemacs -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;; The main earnemacs file.
;;; Code:
;; Windows - $HOME folder if not set
(when (and *sys-windows* (null (getenv-internal "HOME")))
(setenv "HOME" (getenv "USERPROFILE"))
(setq abbreviated-home-dir nil))
;; UTF-8, LF by default
(setq-default buffer-file-coding-system 'utf-8-unix)
(setq-default default-buffer-file-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
;; Less noise on startup
(unless (daemonp)
(advice-add #'display-startup-echo-area-message :override #'ignore)) ; message
(setq inhibit-startup-screen t) ; startup buffer
(setq ad-redefinition-action 'accept) ; silence redefined warnings
(setq server-use-tcp t) ; daemon: use tcp sockets file
;; Add default modules to load path (modules/ recursively)
;; Taken with <3 from siren emacs: https://github.com/jimeh/.emacs.d
(defun siren-recursive-add-to-load-path (dir)
"Add DIR and all its sub-directories to `load-path'."
(add-to-list 'load-path dir)
(dolist (f (directory-files dir))
(let ((name (expand-file-name f dir)))
(when (and (file-directory-p name)
(not (string-prefix-p "." f)))
(siren-recursive-add-to-load-path name)))))
(siren-recursive-add-to-load-path earnemacs-modules-dir)
;;; -
(defun earnemacs+load ()
"Function to finish loading earnemacs.
earnemacs has already loaded earnemacs-var, -main, and -packages.
This function will load:
- core modules (prefixed with `earnecore-')
- `pre-load.el' if it exists
- `load.el'
- `config.el'"
(let* ((prel (concat earnemacs-root-dir "pre-load.el")))
(if (file-exists-p prel)
(load-file prel)))
;; Load core modules
(require 'earnecore-theme)
(require 'earnecore-keybinds)
(require 'earnecore-display)
(require 'earnecore-pkg)
(require 'earnecore-projects)
(require 'earnecore-editing)
(let* ((modules (concat earnemacs-root-dir "load.el")))
(load modules nil t)
(dolist (module earnemacs-modules)
(require module)))
(let* ((config (concat earnemacs-root-dir "config.el")))
(load config nil t))
(setq earnemacs-initialized-p t))
;; Load everything!
(earnemacs+load)
(provide 'earnemacs-main)
;;; earnemacs-main.el ends here

View File

@ -0,0 +1,80 @@
;;; earnemacs-packages.el --- Package management -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;; Bootstrap/ load and configure straight.el for package management.
;;; Code:
;; Profiles
(setq straight-profiles
'((nil . "default.el")
(pinned . "pinned.el")))
;; Use the develop branch of straight.el (for now), must set before bootstrap.
(setq straight-repository-branch "develop")
;; Boostrap/ load straight.el
(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))
;; Configure straight
; (setq straight-vc-git-default-clone-depth 1) ; save space
(setq straight-use-package-by-default t) ; use-package integration
(straight-use-package 'use-package)
(setq use-package-always-defer t) ; always defer unless :demanded
(require 'straight-x) ; load additional experimental commands
;;; Modules system:
(defvar earnemacs-modules nil
"A quoted list of optional modules to load. The default list is provided and
used form `load.template.el'. It should be checked after every major update to
earnemacs.")
(defun earnemacs-update-packages ()
"Update all packages (core/ module packages mostly will refer to pinned
lockfile unless no commit hash is provided) and write packages the user has
installed to the `default.el' lockfile."
(interactive)
(message "[earnemacs] Updating packages and lockfiles...")
(straight-x-pull-all)
(straight-x-freeze-versions)
(message "[earnemacs] Update complete, consider reloading earnemacs."))
;;; Pin packages to a certain commit (for core/ module packages only):
;; Any core/module package not given a commit hash here will update
;; as normal, and no hash is written to `pinned.el'.
(defmacro earnemacs-package-pin (package commit)
"Add the PACKAGE and COMMIT hash to the pinned lockfile. Aliased to `epin'.
Ex: (epin \"packagename\" \"70b64b6d91d62ecef8fa202c65c19b8aba7122e2\")
Only for core/ optional modules. (for now?)"
`(let ((straight-current-profile 'pinned))
(add-to-list 'straight-x-pinned-packages
'(,package . ,commit))))
(defalias 'epin 'earnemacs-package-pin)
(provide 'earnemacs-packages)
;;; earnemacs-packages.el ends here

View File

@ -0,0 +1,52 @@
;;; earnemacs-vars.el --- Variables for earnemacs -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;; This file defines variables for earnemacs.
;;; Code:
(defconst earnemacs-root-dir user-emacs-directory
"Typically the ~/.config/emacs or ~/.emacs.d directory earnemacs is being
loaded from, although this can differ if you are using chemacs2.")
(defconst earnemacs-core-dir (concat earnemacs-root-dir "core/")
"Path to the earnemacs core directory.")
(defconst earnemacs-modules-dir (concat earnemacs-root-dir "modules/")
"Path to the earnemacs modules directory.")
(defvar earnemacs-initialized-p nil
"Non-nil if earnemacs has been initialized.")
;; What OS are we using?
(defconst *sys-linux* (eq system-type 'gnu/linux))
(defconst *sys-windows* (memq system-type '(windows-nt cygwin ms-dos)))
(defconst *sys-mac* (eq system-type 'darwin))
(defconst *sys-bsd* (or *sys-mac* (eq system-type 'berkeley-unix)))
;; Daemon identification
(cond ((eq (daemonp) nil)
(defconst earnemacs-daemon-name "indiv")) ; emacs
((eq (daemonp) t)
(defconst earnemacs-daemon-name "daemon")) ; emacs --daemon
((defconst earnemacs-daemon-name (daemonp)))) ; emacs --daemon="..."
;; Config options that must be set very early
(defvar earnemacs-default-face-height 110
"If you want to adjust it, it must be done in `pre-load.el'.")
(defvar earnemacs-fixed-face-height 110
"If you want to adjust it, it must be done in `pre-load.el'.")
(defvar earnemacs-variable-face-height 115
"If you want to adjust it, it must be done in `pre-load.el'.")
(defvar earnemacs-transparent-frame t
"Enables a semi-transparent frame by default. Set to nil to disable in
`pre-load.el'.")
(provide 'earnemacs-vars)
;;; earnemacs-vars.el ends here

View File

@ -0,0 +1,43 @@
;;; early-init.el --- Early initialization -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;; This file is loaded before the main `init.el' initialization file and
;; graphical window.
;;; Code:
;; Garbage collection
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6)
(add-hook 'emacs-startup-hook
(lambda ()
(setq gc-cons-threshold 16777216
gc-cons-percentage 0.1)))
;; Remove some graphical things
;; (if (not (eq system-type 'darwin)) (menu-bar-mode -1))
(tool-bar-mode -1)
(scroll-bar-mode -1) ; no scroll bars at all
;; Startup slightly faster even if frame is being resized on startup
(setq frame-inhibit-implied-resize t)
;; Do NOT use package.el
(setq package-enable-at-startup nil)
;; Silence "Package cl is deprecated"
;; AFAIK, cl was deprecated in Emacs 27.1 and replaced by cl-lib,
;; which some packages have not switched over to yet.
(setq byte-compile-warnings '(cl-functions))
;; Don't show the default modeline until doom-modeline loads
(setq-default mode-line-format nil)
(provide 'early-init)
;;; early-init.el ends here

34
.config/emacs/init.el Normal file
View File

@ -0,0 +1,34 @@
;;; init.el --- Emacs main initialization file -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;; Other than `early-init.el', this file is first looked at when Emacs is first
;; started. It only checks if the Emacs version is too low and the loads the
;; core/main.el file.
;;; Code:
(defvar earnemacs-minimum-emacs-version "27.1"
"Minimum Emacs version for earnemacs functionality.")
;; Error if Emacs version is not supported
(if (version< emacs-version earnemacs-minimum-emacs-version)
(error (concat "[earnemacs] supports %s or higher, "
"but you are running %s."
earnemacs-minimum-emacs-version emacs-version)))
;; Load!
(add-to-list 'load-path (expand-file-name "core/" user-emacs-directory))
(require 'earnemacs-vars)
(require 'earnemacs-packages)
(use-package earnemacs-main
:straight nil
:demand)
(provide 'init)
;;; init.el ends here

38
.config/emacs/load.el Normal file
View File

@ -0,0 +1,38 @@
(setq
earnemacs-modules '(
;; completion
earnemod-company
earnemod-ivy
;; display
earnemod-focus
earnemod-scrolling
earnemod-window
;; editor
earnemod-everywhere
earnemod-check
earnemod-docker
earnemod-git
earnemod-lsp
earnemod-parens
;; projects
earnemod-treemacs
;; lang
earnemod-config
earnemod-markdown
earnemod-golang
earnemod-python
earnemod-rust
earnemod-web
;; apps
earnemod-elfeed
earnemod-gemini
earnemod-org
;; games
)
)

View File

@ -0,0 +1,84 @@
;;; earnemod-elfeed.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package elfeed
:bind (:map elfeed-search-mode-map
("q" . bjm/elfeed-save-db-and-bury)
("w" . (lambda () (interactive) (elfeed-db-save)))
("m" . elfeed-toggle-star)
("b" . mz/elfeed-browse-url)
("B" . elfeed-search-browse-url))
:general
(earnemacs-spc-def "or" 'bjm/elfeed-load-db-and-open)
:hook
(elfeed-show-mode . visual-line-mode)
(elfeed-show-mode . olivetti-mode)
:config
;; Set the default state to Emacs
(evil-set-initial-state 'elfeed-search-mode 'emacs)
(evil-set-initial-state 'elfeed-show-mode 'emacs)
(defun elfeed-mark-all-as-read ()
"Mark the whole buffer as read."
(interactive)
(mark-whole-buffer)
(elfeed-search-untag-all-unread))
(defun bjm/elfeed-load-db-and-open ()
"Wrapper to load the elfeed db from disk before opening"
(interactive)
(elfeed-protocol-enable)
(elfeed-db-load)
(elfeed)
(elfeed-goodies/setup)
(elfeed-search-update--force))
(defun bjm/elfeed-save-db-and-bury ()
"Wrapper to save the elfeed db to disk before burying buffer"
(interactive)
(elfeed-db-save)
(quit-window))
;; Browse the URL at point without marking as read
;; https://github.com/zamansky/dot-emacs/blob/master/README.org
(defun mz/elfeed-browse-url (&optional use-generic-p)
"Visit the current entry in your browser using `browse-url'.
If there is a prefix argument, visit the current entry in the
browser defined by `browse-url-generic-program'."
(interactive "P")
(let ((entries (elfeed-search-selected)))
(cl-loop for entry in entries
do (if use-generic-p
(browse-url-generic (elfeed-entry-link entry))
(browse-url (elfeed-entry-link entry))))
(mapc #'elfeed-search-update-entry entries)
(unless (or elfeed-search-remain-on-entry (use-region-p)))))
;; Take advantage of curl if it is available
(if (executable-find "curl")
(setq
elfeed-use-curl t
elfeed-curl-max-connections 10))
;; Set the default search filter (space for convenience)
(setq-default elfeed-search-filter "@3-months-ago +unread "))
(use-package elfeed-protocol
:demand
:after elfeed)
(use-package elfeed-goodies
:demand
:after elfeed
:config
;; Make the feed source column width longer
(setq elfeed-goodies/feed-source-column-width 26))
(provide 'earnemod-elfeed)
;;; earnemod-elfeed.el ends here

View File

@ -0,0 +1,17 @@
;;; earnemod-gemini.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package elpher
:general
(earnemacs-spc-def "oG" 'elpher))
(use-package gemini-mode)
(use-package ox-gemini)
(provide 'earnemod-gemini)
;;; earnemod-gemini.el ends here

View File

@ -0,0 +1,124 @@
;;; earnemod-org.el --- org-mode -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package org
;; Use built-in org
:straight nil
:general
(earnemacs-spc-def
"oA" 'org-agenda
"oC" 'org-capture)
:config
;; Default directory containing org-mode files
(setq org-directory "~/org/")
;; Enable modules
(add-to-list 'org-modules 'org-habit)
;; Hooks:
;; Indent correctly
(add-hook 'org-mode-hook 'org-indent-mode)
;; Visual wrapping
(add-hook 'org-mode-hook 'visual-line-mode)
;; Table of contents generation
(add-hook 'org-mode-hook 'toc-org-mode)
;; Use sans-serif font
(add-hook 'org-mode-hook 'variable-pitch-mode)
;; Set indenting as default
(setq-default org-indent-mode t)
;; use org-mode + doom-themes improvements
(doom-themes-org-config)
;; Variable pitch and heading
(custom-theme-set-faces
;; <3 https://zzamboni.org/post/beautifying-org-mode-in-emacs/
'user
'(org-block ((t (:inherit fixed-pitch))))
'(org-code ((t (:inherit fixed-pitch))))
'(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
'(org-indent ((t (:inherit (org-hide fixed-pitch)))))
'(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-property-value ((t (:inherit fixed-pitch))) t)
'(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))
t))
'(org-table ((t (:inherit fixed-pitch))))
'(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
'(org-verbatim ((t (:inherit (shadow fixed-pitch))))))
:custom
;; Set number of lines between headings to display empty lines to 1
(org-cycle-separator-lines 1)
;; Set default table formatting
(org-columns-set-default-format
"80ITM(Task) %10Effort(Effort){:} %10CLOCKSUM(Timed)")
;; Enforce todo dependencies
(org-enforce-todo-dependencies t)
(org-global-properties (quote (
;; Set default Effort properties
("Effort_ALL" . "0:05 0:10 0:15 0:20
0:30 0:45 1:00 1:30 2:00 4:00 6:00 8:00"))))
;; Drawer names
(org-log-into-drawer "LOGBOOK")
(org-clock-into-drawer "CLOCKING")
;; Do not set state triggers when using Shift to change states
(org-treat-S-cursor-todo-selection-as-state-change nil)
;; Log time when task marked as DONE
(org-log-done 'time)
;; Log note and time when rescheduling or redeadlining
(org-log-reschedule 'note)
(org-log-redeadline 'note)
;; Only show today's habits
(org-habit-show-habits-only-for-today t))
(use-package org-agenda
:after org
:straight nil
:bind (("C-c a" . org-agenda))
:custom
(org-agenda-window-setup 'other-window)
(org-agenda-restore-windows-after-quit 't)
(org-agenda-dim-blocked-tasks t)
(org-agenda-span 4)
(org-agenda-start-on-weekday nil)
(org-agenda-start-day "-1d")
(org-agenda-skip-deadline-prewarning-if-scheduled 'pre-scheduled)
(org-agenda-skip-deadline-if-done nil)
(org-agenda-skip-scheduled-if-done nil))
(use-package org-capture
:after org
:straight nil
:bind (("C-c c" . org-capture))
:custom
;; Base capture templates
(org-capture-templates
`(("t" "Task" entry (file, "~/org/refile.org")
"* TODO %^{Task}\n:PROPERTIES:\n- Added: %U\n:END:"
:empty-lines 1 :immediate-finish t :clock-resume :kill-buffer))))
(use-package ox-ssh)
(use-package toc-org)
(use-package zpresent
:config
;; Set default state to Emacs
(evil-set-initial-state 'zpresent-mode 'emacs))
(provide 'earnemod-org)
;;; earnemod-org.el ends here

View File

@ -0,0 +1,59 @@
;;; earnecore-company.el --- Company completion -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package company
:init (global-company-mode)
:bind (:map company-active-map
;; TAB should always complete the current selection
("<tab>" . company-complete-selection)
;; Spaces should not try to complete
("SPC" . nil))
:bind ((;; Trigger completion manually
"M-RET" . company-manual-begin))
:config
;; Max number of results
(setq company-tooltip-limit 10)
;; Press M-# to complete that selection
(setq company-show-numbers t)
;; Show results immediately/ faster
(setq company-idle-delay 0)
(setq company-echo-delay 0)
(setq company-minimum-prefix-length 2)
;; Prevent non-matching input from blocking, but only if we explicitly
;; interact with company
(setq company-require-match #'company-explicit-action-p)
;; Do not downcase completion suggestions
(setq company-dabbrev-downcase nil))
(use-package company-statistics
:demand
:after company
:config
;; Load the company-statistics file silently.
(defun earnemacs--company-statistics--load ()
"Restore statistics without a minibuffer message"
(load company-statistics-file 'noerror 'nomessage 'nosuffix))
(advice-add 'company-statistics--load
:override #'earnemacs--company-statistics--load)
;; Load
(company-statistics-mode))
(use-package company-quickhelp
:demand
:after company
:config (company-quickhelp-mode))
(provide 'earnemod-company)
;;; earnemod-company.el ends here

View File

@ -0,0 +1,22 @@
;;; earnecore-ivy.el --- Ivy -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package ivy
:demand
:general
(earnemacs-spc-def
"/" 'ivy-switch-buffer
"bb" 'ivy-switch-buffer)
:config
(ivy-mode 1))
(use-package counsel
:demand
:after ivy)
(provide 'earnemod-ivy)
;;; earnemod-ivy.el ends here

View File

@ -0,0 +1,14 @@
;;; earnemod-focus.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package olivetti
:general
(earnemacs-spc-def
"to" 'olivetti-mode))
(provide 'earnemod-focus)
;;; earnemod-focus.el ends here

View File

@ -0,0 +1,14 @@
;;; earnemod-scrolling.el --- Improves scrolling -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package good-scroll
:demand
:init
(good-scroll-mode +1))
(provide 'earnemod-scrolling)
;;; earnemod-scrolling.el ends here

View File

@ -0,0 +1,29 @@
;;; earnemod-window.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package ace-window
:bind (("M-o" . 'ace-window)
("M-O" . 'ace-delete-window))
:general
(earnemacs-spc-def
"wo" 'ace-window
"wO" 'ace-delete-window
"wX" 'ace-delete-other-windows))
;; Easily undo/ redo window configuration
(use-package winner
:straight nil
:demand
:general
(earnemacs-spc-def
"wu" 'winner-undo
"wU" 'winner-redo)
:config
(winner-mode 1))
(provide 'earnemod-window)
;;; earnemod-window.el ends here

View File

@ -0,0 +1,14 @@
;;; earnemod-check.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package flycheck
:demand
:config
(global-flycheck-mode +1))
(provide 'earnemod-check)
;;; earnemod-check.el ends here

View File

@ -0,0 +1,18 @@
;;; earnemod-docker.el --- Docker -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package docker
:general
(earnemacs-spc-def "od" 'docker))
(use-package dockerfile-mode)
(use-package docker-compose-mode)
(provide 'earnemod-docker)
;;; earnemod-docker.el ends here

View File

@ -0,0 +1,13 @@
;;; earnemod-everywhere.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package emacs-everywhere
:if (or *sys-bsd* *sys-linux* *sys-mac*)
:demand)
(provide 'earnemod-everywhere)
;;; earnemod-everywhere.el ends here

View File

@ -0,0 +1,50 @@
;;; earnemod-git.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package ghq
:if (executable-find "ghq")
:general
(earnemacs-spc-def
"gc" 'ghq))
(use-package magit
:demand
:general
(earnemacs-spc-def
"g." 'magit-dispatch
"gb" 'magit-branch
"gf" 'magit-fetch
"gF" 'magit-pull
"gg" 'magit-status
"gs" 'magit-stage-file
"gS" 'magit-unstage-file
"gm" 'magit-merge
"gM" 'magit-remote
"gP" 'magit-push
"gr" 'magit-rebase
"gz" 'magit-stash)
:config
;; Set default state to Emacs
(evil-set-initial-state 'magit-status-mode 'emacs))
(use-package git-gutter
:demand
:config
;; Update every 2 seconds
(setq git-gutter:update-interval 2)
;; Load
(global-git-gutter-mode))
;; Follow symlinks
(setq vc-follow-symlinks t)
;; Major mode for editing git files (ignore, attributes...)
(use-package git-modes)
(provide 'earnemod-git)
;;; earnemod-git.el ends here

View File

@ -0,0 +1,29 @@
;;; earnemod-lsp.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package lsp-mode
:init
(setq lsp-keymap-prefix "C-c l")
:hook
((lsp-mode . lsp-enable-which-key-integration)))
(use-package lsp-ui
:demand
:after lsp-mode)
(use-package lsp-ivy
:if (fboundp 'ivy-mode)
:demand
:after (lsp-mode ivy-mode))
(use-package lsp-treemacs
:if (fboundp 'treemacs)
:demand
:after (lsp-mode treemacs))
(provide 'earnemod-lsp)
;;; earnemod-lsp.el ends here

View File

@ -0,0 +1,19 @@
;;; earnemod-parens.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package smartparens
:demand
:config
;; Enable globally
(smartparens-global-mode 1)
(show-smartparens-global-mode 1))
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
(provide 'earnemod-parens)
;;; earnemod-parens.el ends here

View File

@ -0,0 +1,39 @@
;;; earnemod-config.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
;; TOML
(use-package toml-mode)
;; JSON
(use-package json-mode)
;; YAML
(use-package yaml-mode
:mode (("\\.yml\\'" . yaml-mode)
("\\.yaml\\'" . yaml-mode))
:config
(add-hook 'yaml-mode-hook
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent))))
;; SSH config files
(use-package ssh-config-mode)
;; Nginx
(use-package nginx-mode
:config
(setq nginx-indent-tabs-mode t))
(use-package company-nginx
:config
(add-hook 'nginx-mode-hook
(lambda ()
(add-to-list 'company-backends #'company-nginx))))
(provide 'earnemod-config)
;;; earnemod-config.el ends here

View File

@ -0,0 +1,15 @@
;;; earnemod-golang.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package go-mode
:mode "\\.go\\'"
:config
;; Start LSP
(add-hook 'go-mode-hook #'lsp-deferred))
(provide 'earnemod-golang)
;;; earnemod-golang.el ends here

View File

@ -0,0 +1,34 @@
;;; earnemod-markdown.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package markdown-mode
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode))
:config
;; Hooks:
;; Visual line wrapping
(add-hook 'markdown-mode-hook 'visual-line-mode)
;; Font
(add-hook 'markdown-mode-hook 'variable-pitch-mode)
;; Center text
(add-hook 'markdown-mode-hook 'olivetti-mode)
;; Line breaks
(add-hook 'markdown-mode-hook 'auto-fill-mode)
;; Font settings
(custom-theme-set-faces
'user
'(markdown-code-face ((t (:inherit fixed-pitch))))
'(markdown-header-face-1 ((t (:inherit variable-pitch :height 1.9))))
'(markdown-header-face-2 ((t (:inherit variable-pitch :height 1.7))))
'(markdown-header-face-3 ((t (:inherit variable-pitch :height 1.55))))
'(markdown-header-face-4 ((t (:inherit variable-pitch :height 1.4))))
'(markdown-header-face-5 ((t (:inherit variable-pitch :height 1.3))))
'(markdown-header-face-6 ((t (:inherit variable-pitch :height 1.25))))))
(provide 'earnemod-markdown)
;;; earnecore-markdown.el ends here

View File

@ -0,0 +1,18 @@
;;; earnemod-python.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package elpy
:hook (python-mode . elpy-enable))
(use-package blacken
:hook (python-mode . blacken-mode)
:config
;; Set line length
(setq blacken-line-length '79))
(provide 'earnemod-python)
;;; earnemod-python.el ends here

View File

@ -0,0 +1,14 @@
;;; earnemod-rust.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Code:
(use-package rustic
:config
;; Start LSP
(add-hook 'rustic-mode-hook #'lsp-deferred))
(provide 'earnemod-rust)
;;; earnecore-rust.el ends here

View File

@ -0,0 +1,16 @@
;;; earnemod-web.el --- -*- lexical-binding: t; -*-
;; Copyright (C) 2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;; code:
(use-package web-mode
:mode
"\\.html\\'"
"\\.css\\'")
(use-package scss-mode)
(provide 'earnemod-web)
;;; earnemod-web.el ends here

View File

@ -0,0 +1,55 @@
;;; earnemod-treemacs.el --- Treemacs+Projectile -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;;
;;; Code:
(use-package treemacs
:init
;; Set persist file per session name
(setq treemacs-persist-file (concat no-littering-var-directory
"treemacs/persist-"
earnemacs-daemon-name ".el"))
:general
(earnemacs-spc-def
"op" 'treemacs)
:config
;; doom-themes + treemacs <3 (M-x all-the-icons-install-fonts)
(doom-themes-treemacs-config)
;; ?
(treemacs-fringe-indicator-mode 'only-when-focused)
;; Defer using git to check for modified files
(treemacs-git-mode 'deferred)
;; Auto-refresh when files change
(treemacs-filewatch-mode)
;; Follow the current file
(setq treemacs-follow-after-init t)
;; Set width of buffer
(setq treemacs-width 26)
;; Refresh without showing a message
(setq treemacs-silent-refresh t)
;; Do not show cursor in buffer
(setq treemacs-show-cursor nil))
(use-package treemacs-evil
:demand
:after treemacs)
(use-package treemacs-projectile
:demand
:after treemacs)
(provide 'earnemod-treemacs)
;;; earnemod-treemacs.el ends here