summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
Diffstat (limited to '.config')
-rw-r--r--.config/emacs/early-init.el9
-rw-r--r--.config/emacs/init.el9
-rw-r--r--.config/emacs/modules/mm-editing.el6
-rw-r--r--.config/emacs/modules/mm-projects.el45
-rw-r--r--.config/emacs/modules/mm-theme.el4
-rw-r--r--.config/emacs/modules/mm-treesit.el17
-rw-r--r--.config/emacs/site-lisp/gh.el39
7 files changed, 107 insertions, 22 deletions
diff --git a/.config/emacs/early-init.el b/.config/emacs/early-init.el
index b48d643..0dfbfa6 100644
--- a/.config/emacs/early-init.el
+++ b/.config/emacs/early-init.el
@@ -76,17 +76,14 @@
;; set threshold to 8 MiB which seems to be a good middleground for now.
;; A higher threshold means less garbage collections but I’ve had issues
;; with those garbage collections causing long freezes when they occur.
-(let ((saved-file-name-handler-alist file-name-handler-alist)
- (saved-vc-handled-backends vc-handled-backends))
- (setopt file-name-handler-alist nil
- vc-handled-backends nil)
+(let ((saved-file-name-handler-alist file-name-handler-alist))
+ (setopt file-name-handler-alist nil)
(add-hook
'emacs-startup-hook
(defun mm-restore-emacs-settings ()
(setopt gc-cons-threshold (* 1024 1024 8)
gc-cons-percentage 0.1
- file-name-handler-alist saved-file-name-handler-alist
- vc-handled-backends saved-vc-handled-backends))))
+ file-name-handler-alist saved-file-name-handler-alist))))
;;; Avoid Flashbang
diff --git a/.config/emacs/init.el b/.config/emacs/init.el
index a8620d6..56e8476 100644
--- a/.config/emacs/init.el
+++ b/.config/emacs/init.el
@@ -294,15 +294,6 @@ the buffer without saving it."
(advice-add command :around #'mm-auto-create-directories))
-;;; Emacs Lisp Libraries
-
-;; The following are included here because they’re required by some of
-;; the modules.
-
-(use-package async
- :ensure t)
-
-
;;; Load Modules
(require 'mm-abbrev) ; Text Expansion
diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el
index 14f5211..540bae4 100644
--- a/.config/emacs/modules/mm-editing.el
+++ b/.config/emacs/modules/mm-editing.el
@@ -67,7 +67,10 @@
(sgml-mode . (:extras sgml-basic-offset))
(sh-mode . (:extras sh-basic-offset))
(tex-mode . (:width 2))
- (vimscript-ts-mode . (:extras vimscript-ts-mode-indent-level)))
+ (typescript-ts-mode . (:extras typescript-ts-mode-indent-offset))
+ (vimscript-ts-mode . (:extras vimscript-ts-mode-indent-level))
+ (vue-ts-mode . (:extras (typescript-ts-mode-indent-offset
+ vue-ts-mode-indent-offset))))
"Alist of indentation settings.
Each pair in this alist is of the form (MODE . SETTINGS) where MODE
specifies the mode for which the given SETTINGS should apply.
@@ -327,6 +330,7 @@ is as described by `emmet-expand-line'."
(use-package awk-ts-mode :ensure t)
(use-package git-modes :ensure t)
+(use-package po-mode :ensure t)
(use-package sed-mode :ensure t)
(use-package csv-mode
diff --git a/.config/emacs/modules/mm-projects.el b/.config/emacs/modules/mm-projects.el
index 00342f5..71006d5 100644
--- a/.config/emacs/modules/mm-projects.el
+++ b/.config/emacs/modules/mm-projects.el
@@ -96,4 +96,49 @@ This is intended to be called interactively via
(require 'ansi-color)
(add-hook 'compilation-filter-hook #'ansi-color-compilation-filter))
+
+;;; GitHub Pull Requests
+
+(require 'gh)
+(keymap-global-set "C-c p" #'gh-create-pr)
+
+;; (defun mm-gh--get-labels ()
+;; (with-temp-buffer
+;; (call-process "gh" nil t nil "label" "list" "--json" "name")
+;; (goto-char (point-min))
+;; (let* ((data (json-parse-buffer))
+;; (labels (seq-map (lambda (x) (gethash "name" x)) data)))
+;; (sort labels
+;; :in-place t
+;; :lessp (lambda (x y)
+;; (let ((prefix-x-p (string-prefix-p "Sprint " x))
+;; (prefix-y-p (string-prefix-p "Sprint " y)))
+;; (cond
+;; ((and prefix-x-p prefix-y-p) (string> x y))
+;; (prefix-x-p t)
+;; (prefix-y-p nil)
+;; (:else (string< x y)))))))))
+
+;; (defun mm-gh-create-pr (title draftp labels)
+;; "Create a GitHub pull request using the gh CLI.
+;; If DRAFT is non-nil, the PR will be created as a draft.
+;; LABELS should be a comma-separated string of GitHub labels."
+;; (interactive
+;; (list
+;; (read-string (format-prompt "PR Title" nil))
+;; (y-or-n-p "Create as draft PR? ")
+;; (completing-read-multiple (format-prompt "PR Labels" nil)
+;; (mm-gh--get-labels))))
+;; (let* ((branch (car (vc-git-branches)))
+;; (title (format "%s %s" branch title))
+;; (flags `("--fill-verbose" "--title" ,title "--assignee" "@me"))
+;; (label-string (mapconcat #'identity labels ",")))
+;; (when draftp
+;; (setq flags (append flags '("--draft"))))
+;; (when labels
+;; (setq flags (append flags `("--label" ,label-string))))
+;; (with-temp-buffer
+;; (apply #'call-process "gh" nil t nil "pr" "create" flags)
+;; (message (buffer-string)))))
+
(provide 'mm-projects) \ No newline at end of file
diff --git a/.config/emacs/modules/mm-theme.el b/.config/emacs/modules/mm-theme.el
index 95c96c9..90b89ba 100644
--- a/.config/emacs/modules/mm-theme.el
+++ b/.config/emacs/modules/mm-theme.el
@@ -16,7 +16,9 @@
"The default monospace font.
This is a plist containing a font name, -weight, and -height.")
-(defvar mm-theme-proportional-font '("OpenSans" :weight regular :height 162)
+(defvar mm-theme-proportional-font
+ `(,(if mm-darwin-p "Microsoft Sans Serif" "OpenSans")
+ :weight regular :height 162)
"The default proportional font.
This is a plist containing a font name, -weight, and -height.")
diff --git a/.config/emacs/modules/mm-treesit.el b/.config/emacs/modules/mm-treesit.el
index 4e052de..1d4defa 100644
--- a/.config/emacs/modules/mm-treesit.el
+++ b/.config/emacs/modules/mm-treesit.el
@@ -43,6 +43,9 @@
"split_parser" "tree-sitter-markdown-inline/src")
(python
"https://github.com/tree-sitter/tree-sitter-python")
+ (tsx
+ "https://github.com/tree-sitter/tree-sitter-typescript"
+ "master" "tsx/src")
(typescript
"https://github.com/tree-sitter/tree-sitter-typescript"
"master" "typescript/src")
@@ -112,11 +115,12 @@ The parsers are taken from `treesit-language-source-alist'."
;; anyway. Same goes for ‘typescript-ts-mode’.
(defvar mm-treesit-language-file-name-alist
'((go . "\\.go\\'")
- (go-mod . "/go\\.mod\\'")
+ (gomod . "/go\\.mod\\'")
+ (tsx . "\\.tsx\\'")
(typescript . "\\.ts\\'"))
"Alist mapping languages to their associated file-names.
This alist is a set of pairs of the form (LANG . REGEXP) where LANG is
-the symbol corresponding to a major mode with the ‘-ts-mode’ suffix
+the symbol corresponding to a major mode with the `-ts-mode' suffix
removed. REGEXP is a regular expression matching filenames for which
the associated language’s major-mode should be enabled.
@@ -132,9 +136,9 @@ languages should be listed here.")
(dolist (spec treesit-language-source-alist)
(let* ((lang (car spec))
- (lang (alist-get lang mm-treesit-language-remap-alist lang))
- (name-mode (intern (format "%s-mode" lang)))
- (name-ts-mode (intern (format "%s-ts-mode" lang))))
+ (lang-remap (alist-get lang mm-treesit-language-remap-alist lang))
+ (name-mode (intern (format "%s-mode" lang-remap)))
+ (name-ts-mode (intern (format "%s-ts-mode" lang-remap))))
;; If ‘name-ts-mode’ is already in ‘auto-mode-alist’ then we don’t
;; need to do anything, however if that’s not the case then if
;; ‘name-ts-mode’ and ‘name-mode’ are both bound we do a simple
@@ -155,6 +159,9 @@ languages should be listed here.")
(add-to-list 'auto-mode-alist (cons file-regexp name-ts-mode))
(warn "Unable to determine the extension for `%s'." name-ts-mode))))))
+;; JavaScript being difficult as usual
+(add-to-list 'major-mode-remap-alist '(javascript-mode . js-ts-mode))
+
;;; Hack For C23
diff --git a/.config/emacs/site-lisp/gh.el b/.config/emacs/site-lisp/gh.el
new file mode 100644
index 0000000..0461b18
--- /dev/null
+++ b/.config/emacs/site-lisp/gh.el
@@ -0,0 +1,39 @@
+;;; gh.el --- GitHub integration for Emacs -*- lexical-binding: t; -*-
+
+(defun gh-get-labels ()
+ "Return a list of labels in the current GitHub repository."
+ (with-temp-buffer
+ (call-process "gh" nil t nil "label" "list" "--sort" "name" "--json" "name")
+ (goto-char (point-min))
+ (seq-map (lambda (x) (gethash "name" x))
+ (json-parse-buffer))))
+
+;; TODO: Set title and body in a buffer like Magit
+(defun gh-create-pr (title &optional labels draftp)
+ "Create a GitHub pull request.
+If DRAFTP is non-nil, the PR will be created as a draft.
+
+LABELS is a list of labels. A list of available labels can be fetched
+via `gh-get-labels'."
+ (interactive
+ (list
+ (read-string (format-prompt "PR Title" nil))
+ (completing-read-multiple (format-prompt "PR Labels" nil)
+ (gh-get-labels))
+ (y-or-n-p "Create PR as a draft? ")))
+ (let* ((project (project-name (project-current)))
+ (flags `("--fill-verbose" "--assignee" "@me"))
+ (label-string (mapconcat #'identity labels ",")))
+ ;; TODO: Remove this
+ (when (string= project "blixem")
+ (setq title (format "%s %s" (car (vc-git-branches)) title)))
+ (setq flags (append flags `("--title" ,title)))
+ (when draftp
+ (setq flags (append flags '("--draft"))))
+ (when labels
+ (setq flags (append flags `("--label" ,label-string))))
+ (with-temp-buffer
+ (apply #'call-process "gh" nil t nil "pr" "create" flags)
+ (message (buffer-string)))))
+
+(provide 'gh) \ No newline at end of file