mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 19:40:24 +10:00
Updating Doom Emacs.
This commit is contained in:
@@ -4,21 +4,21 @@
|
||||
#+STARTUP: inlineimages
|
||||
|
||||
* Table of Contents :TOC_2:noexport:
|
||||
- [[Description][Description]]
|
||||
- [[Module Flags][Module Flags]]
|
||||
- [[Plugins][Plugins]]
|
||||
- [[Prerequisites][Prerequisites]]
|
||||
- [[Usage][Usage]]
|
||||
- [[Inserting OSS licenses][Inserting OSS licenses]]
|
||||
- [[Configuration][Configuration]]
|
||||
- [[Registering a new file template][Registering a new file template]]
|
||||
- [[Changing existing file templates][Changing existing file templates]]
|
||||
- [[Adding new OSS licenses][Adding new OSS licenses]]
|
||||
- [[Troubleshooting][Troubleshooting]]
|
||||
- [[Appendix][Appendix]]
|
||||
- [[API][API]]
|
||||
- [[Commands][Commands]]
|
||||
- [[Variables][Variables]]
|
||||
- [[#description][Description]]
|
||||
- [[#module-flags][Module Flags]]
|
||||
- [[#plugins][Plugins]]
|
||||
- [[#prerequisites][Prerequisites]]
|
||||
- [[#usage][Usage]]
|
||||
- [[#inserting-oss-licenses][Inserting OSS licenses]]
|
||||
- [[#configuration][Configuration]]
|
||||
- [[#registering-a-new-file-template][Registering a new file template]]
|
||||
- [[#changing-existing-file-templates][Changing existing file templates]]
|
||||
- [[#adding-new-oss-licenses][Adding new OSS licenses]]
|
||||
- [[#troubleshooting][Troubleshooting]]
|
||||
- [[#appendix][Appendix]]
|
||||
- [[#api][API]]
|
||||
- [[#commands][Commands]]
|
||||
- [[#variables][Variables]]
|
||||
|
||||
* Description
|
||||
This module adds file templates for blank files, powered by yasnippet.
|
||||
@@ -49,8 +49,12 @@ for comment headers in code.
|
||||
#+end_quote
|
||||
|
||||
* Configuration
|
||||
** TODO Registering a new file template
|
||||
** TODO Changing existing file templates
|
||||
** Registering a new file template
|
||||
Look into the documentation of ~set-file-template!~ and ~set-file-templates!~.
|
||||
** Changing existing file templates
|
||||
Simply register a new template (using ~set-file-template!~) that matches the same
|
||||
file. The new template would be pushed to the top of ~+file-template-alist~ and
|
||||
thus would take priority while searching for a template to insert.
|
||||
** Adding new OSS licenses
|
||||
The ~+file-templates/insert-license~ command searches for snippets under
|
||||
~text-mode~ that are named ~__license-ABC~, where ABC is the short name of the
|
||||
|
||||
@@ -41,7 +41,7 @@ these properties:
|
||||
|
||||
;;;###autodef
|
||||
(defun set-file-templates! (&rest templates)
|
||||
"Like `set-file-templates!', but can register multiple file templates at once.
|
||||
"Like `set-file-template!', but can register multiple file templates at once.
|
||||
|
||||
\(fn &rest (PRED &key WHEN TRIGGER MODE PROJECT IGNORE))"
|
||||
(defer-until! (boundp '+file-templates-alist)
|
||||
@@ -100,6 +100,8 @@ evil is loaded and enabled)."
|
||||
"Insert a license file template into the current file."
|
||||
(interactive)
|
||||
(require 'yasnippet)
|
||||
(unless (gethash 'text-mode yas--tables)
|
||||
(yas-reload-all t))
|
||||
(let ((templates
|
||||
(let (yas-choose-tables-first ; avoid prompts
|
||||
yas-choose-keys-first)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
don't have a :trigger property in `+file-templates-alist'.")
|
||||
|
||||
(defvar +file-templates-alist
|
||||
`(;; General
|
||||
'(;; General
|
||||
(gitignore-mode)
|
||||
(dockerfile-mode)
|
||||
("/docker-compose\\.yml$" :mode yaml-mode)
|
||||
@@ -29,7 +29,7 @@ don't have a :trigger property in `+file-templates-alist'.")
|
||||
:trigger "__doom-module"
|
||||
:mode emacs-lisp-mode)
|
||||
("-test\\.el$" :mode emacs-ert-mode)
|
||||
(emacs-lisp-mode :trigger "__initfile")
|
||||
(emacs-lisp-mode :trigger "__package")
|
||||
(snippet-mode)
|
||||
;; C/C++
|
||||
("/main\\.c\\(?:c\\|pp\\)$" :trigger "__main.cpp" :mode c++-mode)
|
||||
@@ -73,7 +73,8 @@ don't have a :trigger property in `+file-templates-alist'.")
|
||||
:when +file-templates-in-emacs-dirs-p
|
||||
:trigger "__doom-readme"
|
||||
:mode org-mode)
|
||||
("\\.org$" :trigger "__" :mode org-mode)
|
||||
(org-journal-mode :ignore t)
|
||||
(org-mode)
|
||||
;; PHP
|
||||
("\\.class\\.php$" :trigger "__.class.php" :mode php-mode)
|
||||
(php-mode)
|
||||
@@ -107,7 +108,7 @@ information.")
|
||||
|
||||
|
||||
;;
|
||||
;; Library
|
||||
;;; Library
|
||||
|
||||
(defun +file-templates-in-emacs-dirs-p (file)
|
||||
"Returns t if FILE is in Doom or your private directory."
|
||||
@@ -118,11 +119,14 @@ information.")
|
||||
"Return t if RULE applies to the current buffer."
|
||||
(let ((pred (car rule))
|
||||
(plist (cdr rule)))
|
||||
(and (cond ((symbolp pred) (eq major-mode pred))
|
||||
((and (stringp pred) buffer-file-name)
|
||||
(string-match-p pred buffer-file-name))
|
||||
((not (plist-member plist :when)) t)
|
||||
((funcall (plist-get plist :when) buffer-file-name)))
|
||||
(and (or (and (symbolp pred)
|
||||
(eq major-mode pred))
|
||||
(and (stringp pred)
|
||||
(stringp buffer-file-name)
|
||||
(string-match-p pred buffer-file-name)))
|
||||
(or (not (plist-member plist :when))
|
||||
(funcall (plist-get plist :when)
|
||||
buffer-file-name))
|
||||
rule)))
|
||||
|
||||
(defun +file-templates-check-h ()
|
||||
@@ -134,10 +138,7 @@ must be non-read-only, empty, and there must be a rule in
|
||||
(bobp) (eobp)
|
||||
(not (member (substring (buffer-name) 0 1) '("*" " ")))
|
||||
(not (file-exists-p buffer-file-name))
|
||||
;; Prevent file-templates from breaking org-capture when target file
|
||||
;; doesn't exist and has a file template.
|
||||
(or (not (fboundp 'org-capture-get))
|
||||
(not (org-capture-get :new-buffer)))
|
||||
(not (buffer-modified-p))
|
||||
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))
|
||||
(apply #'+file-templates--expand rule))))
|
||||
|
||||
@@ -156,4 +157,4 @@ must be non-read-only, empty, and there must be a rule in
|
||||
(yas-reload-all)))
|
||||
|
||||
;;
|
||||
(add-hook 'find-file-hook #'+file-templates-check-h)
|
||||
(add-hook 'doom-switch-buffer-hook #'+file-templates-check-h)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; editor/file-templates/packages.el
|
||||
|
||||
(package! yasnippet)
|
||||
|
||||
(package! yasnippet :pin "5b1217ab085fab4abeb1118dccb260691b446703")
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
;;; `(file-name-nondirectory buffer-file-name)`${1: --- ${2:description}} -*- lexical-binding: t; -*-
|
||||
|
||||
$0
|
||||
|
||||
(provide '`(file-name-base buffer-file-name)`)
|
||||
;;; `(file-name-nondirectory buffer-file-name)` ends here
|
||||
@@ -1,9 +0,0 @@
|
||||
(defun yas-java-project-package ()
|
||||
(or (and (eq major-mode 'java-mode)
|
||||
(+java-current-package))
|
||||
""))
|
||||
|
||||
(defun yas-java-class-name ()
|
||||
(or (and (eq major-mode 'java-mode)
|
||||
(+java-current-class))
|
||||
""))
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Java file template
|
||||
# --
|
||||
package `(yas-java-project-package)`;
|
||||
package `(+java-current-package)`;
|
||||
|
||||
public class `(yas-java-class-name)` $1
|
||||
public class `(+java-current-class)` $1
|
||||
{
|
||||
$0
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Java MAIN file template
|
||||
# --
|
||||
package `(yas-java-project-package)`;
|
||||
package `(+java-current-package)`;
|
||||
|
||||
public class `(yas-java-class-name)` $1
|
||||
public class `(+java-current-class)` $1
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
$0
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Org template
|
||||
# --
|
||||
#+TITLE: ${1:`(file-name-base buffer-file-name)`}
|
||||
#+TITLE: ${1:`
|
||||
(string-join
|
||||
(mapcar #'capitalize
|
||||
;; Replace -,_... with space
|
||||
(split-string
|
||||
(let (case-fold-search)
|
||||
;; Seperating lower from upper: hello|World
|
||||
(replace-regexp-in-string
|
||||
"\\([[:lower:]]\\)\\([[:upper:]]\\)" "\\1 \\2"
|
||||
;; Separating upper from (upper and lower): HTTP|Server
|
||||
(replace-regexp-in-string "\\([[:upper:]]\\)\\([[:upper:]][0-9[:lower:]]\\)"
|
||||
"\\1 \\2" (file-name-base buffer-file-name))))
|
||||
"[^[:word:]0-9]+"
|
||||
)) " " )
|
||||
`}
|
||||
|
||||
$0
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Doom module readme
|
||||
# name: Doom module readme
|
||||
# --
|
||||
#+TITLE: ${1:`(if (string-match "modules/\\([^/]+\\)/\\([^/]+\\)/.+" buffer-file-name)
|
||||
(format "%s/%s"
|
||||
@@ -7,36 +7,64 @@
|
||||
(match-string 2 buffer-file-name))
|
||||
"")`}
|
||||
#+DATE: `(format (format-time-string "%B %%s, %Y") (string-to-number (format-time-string "%d")))`
|
||||
#+SINCE: ${2:{replace with next tagged release version}}
|
||||
#+STARTUP: inlineimages
|
||||
#+SINCE: ${2:<replace with next tagged release version>}
|
||||
#+STARTUP: inlineimages nofold
|
||||
|
||||
* Table of Contents :TOC_3:noexport:
|
||||
|
||||
* Description
|
||||
${3:A summary of what this module does.}
|
||||
${3:# A summary of what this module does.}
|
||||
|
||||
+ If possible, include a brief list of feature highlights here
|
||||
+ Like code completion, syntax checking or available snippets
|
||||
+ Include links to packages & external things where possible
|
||||
|
||||
** Maintainers
|
||||
+ @username_linked_to_gihub (Author)
|
||||
+ @username_linked_to_gihub
|
||||
+ @username_linked_to_gihub
|
||||
|
||||
# If this module has no maintainers, then...
|
||||
This module has no dedicated maintainers.
|
||||
|
||||
** Module Flags
|
||||
+ =+flag1= A short description of what this flag does and what it might need
|
||||
when enabled.
|
||||
+ =+flag2= A short description of what this flag does and what it might need
|
||||
when enabled.
|
||||
+ =+flag3= A short description of what this flag does and what it might need
|
||||
when enabled.
|
||||
|
||||
# If this module has no flags, then...
|
||||
This module provides no flags.
|
||||
|
||||
** Plugins
|
||||
{A list of linked plugins}
|
||||
# A list of linked plugins
|
||||
+ [[https://orgmode.org/][org-plus-contrib]]
|
||||
+ [[https://github.com/sabof/org-bullets][org-bullets]]
|
||||
+ [[https://github.com/TobiasZawada/org-yt][org-yt]]
|
||||
+ [[https://github.com/sebastiencs/company-box][company-box]]* (=+childframe=)
|
||||
+ =:lang crystal=
|
||||
+ [[https://github.com/brantou/ob-crystal][ob-crystal]]
|
||||
+ =:lang go=
|
||||
+ [[https://github.com/pope/ob-go][ob-go]]
|
||||
+ =+present=
|
||||
+ [[https://github.com/anler/centered-window-mode][centered-window]]
|
||||
+ [[https://github.com/takaxp/org-tree-slide][org-tree-slide]]
|
||||
+ [[https://gitlab.com/oer/org-re-reveal][org-re-reveal]]
|
||||
|
||||
** Hacks
|
||||
{A list of internal modifications to included packages}
|
||||
# A list of internal modifications to included packages; omit if unneeded
|
||||
|
||||
* Prerequisites
|
||||
This module has no prereqisites.
|
||||
This module has no prerequisites.
|
||||
|
||||
* Features
|
||||
An in-depth list of features, how to use them, and their dependencies.
|
||||
# An in-depth list of features, how to use them, and their dependencies.
|
||||
|
||||
* Configuration
|
||||
How to configure this module, including common problems and how to address them.
|
||||
# How to configure this module, including common problems and how to address them.
|
||||
|
||||
* Troubleshooting
|
||||
Common issues and their solution, or places to look for help.
|
||||
# Common issues and their solution, or places to look for help.
|
||||
$0
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env `(if (equal (file-name-extension buffer-file-name) "zsh") "zsh" "bash")`
|
||||
set -euo pipefail
|
||||
|
||||
$0
|
||||
|
||||
Reference in New Issue
Block a user