All Projects → hlissner → Doom Snippets

hlissner / Doom Snippets

Licence: mit
The Doom Emacs snippets library

Projects that are alternatives of or similar to Doom Snippets

Ivy Yasnippet
Preview yasnippet snippets with ivy
Stars: ✭ 53 (-64.67%)
Mutual labels:  snippets, emacs
.emacs.d
🎉 Personal GNU Emacs configuration
Stars: ✭ 313 (+108.67%)
Mutual labels:  snippets, emacs
Org Mode Workshop
Workshop for Org-mode with focus on todo-, project- and workflow-management
Stars: ✭ 141 (-6%)
Mutual labels:  emacs
Omi Snippets
🔖Visual Studio Code Syntax Highlighting For Single File React And Omi Components - 编写React和Omi单文件组件的VSC语法高亮插件
Stars: ✭ 149 (-0.67%)
Mutual labels:  snippets
Monroe
Clojure nREPL client for Emacs
Stars: ✭ 146 (-2.67%)
Mutual labels:  emacs
Mu4e Alert
Desktop notifications and modeline display for mu4e
Stars: ✭ 143 (-4.67%)
Mutual labels:  emacs
Emacs Bootstrap
Your on-the-fly Emacs development environment.
Stars: ✭ 147 (-2%)
Mutual labels:  emacs
Processing Vscode
A Visual Studio Code extension for the programming language Processing
Stars: ✭ 141 (-6%)
Mutual labels:  snippets
Pine Utils
Code Snippets + Tricks & Tips to help Pine Script developers
Stars: ✭ 149 (-0.67%)
Mutual labels:  snippets
Spiral
Emacs Clojure IDE based on UNREPL
Stars: ✭ 146 (-2.67%)
Mutual labels:  emacs
Org Fragtog
Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
Stars: ✭ 149 (-0.67%)
Mutual labels:  emacs
Docker Emacs
Run Emacs in docker containers!
Stars: ✭ 145 (-3.33%)
Mutual labels:  emacs
Dots
💾 — Dumb & Opinionated Configurations
Stars: ✭ 144 (-4%)
Mutual labels:  emacs
Google Apps Script Snippets
Google Apps Script snippets
Stars: ✭ 147 (-2%)
Mutual labels:  snippets
Monky
Magit for Hg
Stars: ✭ 142 (-5.33%)
Mutual labels:  emacs
Swiper
Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
Stars: ✭ 1,948 (+1198.67%)
Mutual labels:  emacs
Comment Snippets
Sublime Text snippets to create fancy PHP, CSS and HTML comments.
Stars: ✭ 142 (-5.33%)
Mutual labels:  snippets
Borg
Assimilate Emacs packages as Git submodules
Stars: ✭ 145 (-3.33%)
Mutual labels:  emacs
Awesome Doctrine
A collection of useful Doctrine snippets.
Stars: ✭ 147 (-2%)
Mutual labels:  snippets
Mastodon.el
Emacs client for Mastodon
Stars: ✭ 150 (+0%)
Mutual labels:  emacs

Doom Emacs' Snippet Library

This repository contains the yasnippet snippets library for Doom Emacs.

It also exposes a small API to assist in writing your own snippets, including doom-snippets-expand for easily writing snippet aliases, and snippets for the project/framework-specific minor modes available to Doom Emacs users.

Install

  • Doom Emacs users need only enable the :editor snippets module.

  • This package isn't available on MELPA yet.

  • Otherwise, clone this repo somewhere local and use:

    (use-package doom-snippets
      :load-path "path/to/emacs-snippets"
      :after yasnippet)
    

Snippets API

This library exposes a small API to assist you in writing your own snippets. This is not an exhaustive list, but are the most useful.

doom-snippets-expand PROPERTY VALUE &optional MODE

This is primarily used for creating snippet aliases. A snippet alias is a snippet that will expand another snippet when used. e.g.

In js-mode/class:

# name: class
# --
class ${1:Name} {
    $0
}

In js-mode/cl:

# name: class
# key: cl
# type: command
# --
(doom-snippets-expand :name "class")

doom-snippets-format FORMAT &optional DEFAULT TRIM

Returns FORMAT, which is a format string with a custom spec:

spec description
%s The contents of your current selection (yas-selected-text)
%! A newline, if your current selection spans more than a single line
%> A newline, unless the point is at EOL
  • If yas-selected-text is empty, DEFAULT is used.
  • If TRIM is non-nil, whitespace on the ends of yas-selected-text is trimmed.

An example of its use:

# -*- mode: snippet -*-
# name: while ... { ... }
# key: while
# --
while ${1:true} { `(doom-snippets-format "%n%s%n")`$0 }

If the selection consists of a single line, this will expand to:

while true { console.log("Hello world")| }

If it consists of multiple lines, it will expand to:

while true { 
  console.log("Hello")
  console.log("world")| 
}

PROPERTY can be :uuid, :name, :key or :file, and MODE restricts the snippet search to a certain snippet table (by major mode). It isn't wise to use MODE to reference snippets for other major modes, because it will only see snippets that yasnippet have already loaded (and it lazy loads each table).

doom-snippets-without-trigger &rest BODY

Performs BODY after moving the point to the start of the trigger keyword.

Without this, tests like bolp would meaninglessly fail because the cursor is always in front of the word that triggered this snippet.

# -*- mode: snippet -*-
# name: .to_string()
# key: ts
# condition: (doom-snippets-without-trigger (eq (char-before) ?.))
# --
to_string()

doom-snippets-enable-short-helpers

If this variable is non-nil, this package will define the following shortcut function aliases for your convenience:

  • !%! = (doom-snippets-format "%n%s%n")
  • !% = (doom-snippets-format "%n%s")
  • %$ = (doom-snippets-format "%>")
  • (%expand ...) = (doom-snippets-expand ...)
  • (%format ...) = (doom-snippets-format ...)
  • (%without-trigger ...) = (doom-snippets-without-trigger ...)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].