aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.emacs.d/init.el49
-rw-r--r--.emacs.d/modules/et-appearance.el46
-rw-r--r--.emacs.d/modules/et-format.el12
-rw-r--r--.emacs.d/modules/et-utils.el12
-rw-r--r--.emacs.d/modules/et-vc.el101
5 files changed, 152 insertions, 68 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 1b2d2f6..3a82daa 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -1,24 +1,35 @@
-;; -*- lexical-binding: t; -*-
+;;; init.el --- Emacs Configuration entrypoint -*- lexical-binding: t; -*-
+;;
+;;; Commentary:
+;; init.el serves as the entrypoint for this Emacs configuration.
+;;
+;; The majority of the configuration lives within the modules/
+;; directory. Each module is intended to be a self-contained unit for
+;; some aspect of my usage of Emacs. Each module name is prefixed
+;; with et- to namespace them. Furthermore, all public definitions
+;; *within* a module are prefixed by the module name
+;; e.g. et-vc-generate-remote-git-url.
+;;
+;; Because the configuration is generally in these module files, the
+;; primary role of init.el is to bootstrap the loading of these
+;; modules.
+;;
+;; Therefore, this entrypoint file:
+;; * Sets up the Emacs load path to include the modules directory.
+;; * Defines core variables and functions throughout the modules.
+;; * Loads each module in the necessary order.
+;;
+;;; Code:
+(add-to-list 'load-path '"~/.emacs.d/modules")
-;; Add configuration modules to load path
-(add-to-list 'load-path '"~/.dotfiles/.emacs.d/modules")
-
-;; --------- Core Utilities ---------------------
-(defun et-is-desktop-p ()
- (string-match-p "desktop" (system-name)))
-
-;; --------- Core Variables ---------------------
-(defvar et-monospace-font "Hack Nerd Font Mono"
- "The font used by default and for any monospaced font usage.")
-(defvar et-monospace-font-size (if (et-is-desktop-p) 192 160))
-
-;; --------- Modules ----------------------------
(require 'et-package)
(require 'et-appearance)
(require 'et-vc)
(require 'et-completion)
+(require 'et-format)
(require 'et-lsp)
+;; Misc. grab bag items that aren't formally organized yet.
(use-package which-key
:config
(which-key-mode 1))
@@ -26,8 +37,18 @@
(use-package surround
:bind-keymap ("M-'" . surround-keymap))
+(use-package treesit-auto
+ :custom
+ (treesit-auto-install 'prompt)
+ :config
+ (treesit-auto-add-to-auto-mode-alist 'all)
+ (global-treesit-auto-mode))
+
(setq custom-file (expand-file-name "custom-vars.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
(setq messages-log-max t)
+
+(provide 'init)
+;;; init.el ends here
diff --git a/.emacs.d/modules/et-appearance.el b/.emacs.d/modules/et-appearance.el
index 3e9c035..b11ceea 100644
--- a/.emacs.d/modules/et-appearance.el
+++ b/.emacs.d/modules/et-appearance.el
@@ -1,3 +1,24 @@
+;;; et-appearance --- Configuration for the "Look" of Emacs -*- lexical-binding: t; -*-
+;;
+;;; Commentary:
+;;
+;;; Code:
+(require 'et-utils)
+
+(defvar et-monospace-font "Hack Nerd Font Mono"
+ "The font used by default and for any monospaced font usage.")
+(defvar et-monospace-font-size (if (et-utils-is-desktop-p) 192 160))
+(set-face-attribute 'default nil
+ :font (symbol-value 'et-monospace-font)
+ :height (symbol-value 'et-monospace-font-size))
+
+;; Start emacs in full screen
+;;
+;; The t parameter appends to the hook, instead of prepending.
+;; This means it'll be run after other hooks that might fiddle
+;; with the frame size.
+(add-hook 'window-setup-hook 'toggle-frame-maximized t)
+
; Remove the menu bar (File Edit Options...)
(menu-bar-mode -1)
@@ -11,21 +32,17 @@
;; flash instead.
(setq visible-bell t)
-;; Start emacs in full screen
-;;
-;; The t parameter appends to the hook, instead of prepending.
-;; This means it'll be run after other hooks that might fiddle
-;; with the frame size.
-(add-hook 'window-setup-hook 'toggle-frame-maximized t)
-
-;; Setup our monospace font
-(set-face-attribute 'default nil
- :font (symbol-value 'et-monospace-font)
- :height (symbol-value 'et-monospace-font-size))
-
-;; Use line numbers globally
-;; (setq display-line-numbers-type 'relative)
+;; Default to using line numbers in all modes
+;; and turn them off one by one in the particular
+;; modes where they don't make as much sense.
(global-display-line-numbers-mode 1)
+(dolist (mode '(text-mode-hook
+ org-mode-hook
+ term-mode-hook
+ eshell-mode-hook
+ shell-mode-hook
+ special-mode-hook))
+ (add-hook mode (lambda () (display-line-numbers-mode 0))))
(use-package nord-theme
:config
@@ -36,3 +53,4 @@
:init (doom-modeline-mode 1))
(provide 'et-appearance)
+;;; et-appearance.el ends here
diff --git a/.emacs.d/modules/et-format.el b/.emacs.d/modules/et-format.el
new file mode 100644
index 0000000..be4b9ac
--- /dev/null
+++ b/.emacs.d/modules/et-format.el
@@ -0,0 +1,12 @@
+;;; et-format.el --- Code formatting configuration ;; -*- lexical-binding: t; -*-
+;;; Commentary:
+;;
+;;; Code:
+
+(use-package flycheck
+ :init (global-flycheck-mode))
+
+(setq-default flycheck-emacs-lisp-load-path 'inherit)
+
+(provide 'et-format)
+;;; et-format.el ends here
diff --git a/.emacs.d/modules/et-utils.el b/.emacs.d/modules/et-utils.el
new file mode 100644
index 0000000..c75091f
--- /dev/null
+++ b/.emacs.d/modules/et-utils.el
@@ -0,0 +1,12 @@
+;;; et-utils.el --- Utilities for my Emacs configuration -*- lexical-binding: t; -*-
+;;
+;;; Commentary:
+;;
+;;; Code:
+
+(defun et-utils-is-desktop-p ()
+ "Check if the current system is my desktop system."
+ (string-match-p "desktop" (system-name)))
+
+(provide 'et-utils)
+;;; et-utils.el ends here
diff --git a/.emacs.d/modules/et-vc.el b/.emacs.d/modules/et-vc.el
index ea8e797..559e14e 100644
--- a/.emacs.d/modules/et-vc.el
+++ b/.emacs.d/modules/et-vc.el
@@ -1,17 +1,26 @@
-;;; -*- Lexical-binding:t -*-
+;;; et-vc --- Version control configuration -*- lexical-binding:t -*-
+;;
+;;; Commentary:
+;;
+;;; Code:
(require 'vc-git)
(use-package magit)
(global-set-key (kbd "C-c gu")
- 'et-generate-remote-git-url)
+ 'et-vc-generate-remote-git-url)
-(defun et-generate-remote-git-url ()
+(defun et-vc-generate-remote-git-url ()
"Generate a remote URL for the current buffer file and line number.
- * The remote URL can be HTTPS or SSH.
- * The git hosting provider is determined via the git remote origin url.
- * Only Github and SourceHut are supported as a hosting provider."
+* The remote URL can be HTTPS or SSH.
+* The git hosting provider is determined via the git remote `origin` url.
+* Only Github and SourceHut are supported as a hosting provider.
+
+For example, if the point is on line 12 of example.el on head SHA
+abc123, and the git remote origin url is set to a github URL, then a
+URL such https://github.com/myuser/myrepo/blob/abc123/example.el#L12
+would be added to the kill ring."
(interactive)
(if (not buffer-file-name)
@@ -22,61 +31,73 @@
(vc-git-root buffer-file-name)))
(line-num (line-number-at-pos)))
- (if (et--is-supported-provider-p remote-url)
+ (if (et-vc--is-supported-provider-p remote-url)
(progn
- (kill-new (et--generate-remote-git-url remote-url head-sha relative-file-path line-num))
+ (kill-new (et-vc--generate-remote-git-url remote-url head-sha relative-file-path line-num))
(message "Copied remote git URL"))
(message (format "%s is not a supported git hosting provider." remote-url))))))
-(defun et--is-supported-provider-p (url)
- "Check whether url is a supported git hosting provider for URL generation."
- (not (null (et--get-git-hosting-provider url))))
-
-(defun et--get-git-hosting-provider (url)
- "Get the git hosting provider for the given url.
+(defun et-vc--is-supported-provider-p (url)
+ "Check whether URL is a supported git hosting provider for URL generation."
+ (not (null (et-vc--get-git-hosting-provider url))))
- Supported providers:
- - github
- - sourcehut
+(defun et-vc--get-git-hosting-provider (url)
+ "Get the git hosting provider for the given URL.
- Otherwise, if the url corresponds to an unsupported provider,
- nil is returned."
+The supported providers are github and sourcehut. If the URL
+corresponds to an unsupported provider, null is returned."
(cond
- ((string-match-p "github\\.com" url) "github")
- ((string-match-p "git\\.sr\\.ht" url) "sourcehut")))
+ ((string-match-p "github\\.com" url) 'github)
+ ((string-match-p "git\\.sr\\.ht" url) 'sourcehut)))
-(defun et--generate-remote-git-url (remote-url head-sha relative-file-path line-num)
- (let ((provider (et--get-git-hosting-provider remote-url)))
+(defun et-vc--generate-remote-git-url (remote-url head-sha relative-file-path line-num)
+ (let ((provider (et-vc--get-git-hosting-provider remote-url)))
(cond
- ((string-match-p "github" provider)
- (et--gh-generate-remote-git-url remote-url head-sha relative-file-path line-num))
- ((string-match-p "sourcehut" provider)
- (et--sh-generate-remote-git-url remote-url head-sha relative-file-path line-num)))))
+ ((eq 'github provider)
+ (et-vc--gh-generate-remote-git-url remote-url head-sha relative-file-path line-num))
+ ((eq 'sourcehut provider)
+ (et-vc--sh-generate-remote-git-url remote-url head-sha relative-file-path line-num)))))
-
-(defun et--gh-generate-remote-git-url (remote-url head-sha relative-file-path line-num)
+(defun et-vc--gh-generate-remote-git-url (remote-url head-sha relative-file-path line-num)
(format "https://github.com/%s/blob/%s/%s#L%d"
- (et--extract-repo-path "https://github.com" remote-url)
+ (et-vc--extract-repo-path "https://github.com" remote-url)
+ head-sha
+ relative-file-path
+ line-num))
+
+(defun et-vc--sh-generate-remote-git-url (remote-url head-sha relative-file-path line-num)
+ (format "https://git.sr.ht/%s/tree/%s/item/%s#L%d"
+ (et-vc--extract-repo-path "https://git.sr.ht" remote-url)
head-sha
relative-file-path
line-num))
-(defun et--extract-repo-path (base-url remote-url)
- (if (et--git-ssh-url-p remote-url)
+(defun et-vc--extract-repo-path (base-url remote-url)
+ "Extract the repository path from the REMOTE-URL.
+
+BASE-URL is used to determine where the repository part of the
+REMOTE-URL starts if the REMOTE-URL is a http URL.
+
+Example:
+ (et-vc--extract-repo-path
+ \"https://github.com\"
+ \"https://github.com/user/repo\")
+ => \"user/repo\"
+
+ (et-vc--extract-repo-path
+ \"https://git.sr.ht\"
+ \"git@git.sr.ht:~eugenetriguba/repo\")
+ => \"~eugenetriguba/repo\""
+ (if (et-vc--git-ssh-url-p remote-url)
(substring remote-url (+ 1 (string-match ":" remote-url)))
(replace-regexp-in-string
(format "%s/\\(.*?\\)\\(.git\\)?$" base-url)
"\\1"
remote-url)))
-(defun et--git-ssh-url-p (url)
+(defun et-vc--git-ssh-url-p (url)
+ "Check whether URL is a SSH-based Git origin URL."
(string-prefix-p "git@" url))
-(defun et--sh-generate-remote-git-url (remote-url head-sha relative-file-path line-num)
- (format "https://git.sr.ht/%s/tree/%s/item/%s#L%d"
- (et--extract-repo-path "https://git.sr.ht" remote-url)
- head-sha
- relative-file-path
- line-num))
-
(provide 'et-vc)
+;;; et-vc.el ends here