All Projects → doomemacs → snippets

doomemacs / snippets

Licence: MIT license
The Doom Emacs snippets library

Programming Languages

YASnippet
69 projects
emacs lisp
2029 projects

Projects that are alternatives of or similar to snippets

Vscode Restructuredtext
reStructuredText Language Support in Visual Studio Code
Stars: ✭ 243 (-2.02%)
Mutual labels:  snippets
vscode-extension
Link your code and commits to a video recording and explain your code with video.
Stars: ✭ 67 (-72.98%)
Mutual labels:  snippets
30-seconds-blog
Code articles for all your development needs
Stars: ✭ 566 (+128.23%)
Mutual labels:  snippets
Gowebexamples
Go Web Examples Generator
Stars: ✭ 252 (+1.61%)
Mutual labels:  snippets
django-addendum
📜 Easily edit arbitrary text snippets on a site without a full-fledged CMS or issuing another site release. Like a mini-CMS for every site.
Stars: ✭ 71 (-71.37%)
Mutual labels:  snippets
middleman-snippets
⚡ Library of commonly used snippets for Middleman websites
Stars: ✭ 27 (-89.11%)
Mutual labels:  snippets
Vim Vsnip
Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
Stars: ✭ 224 (-9.68%)
Mutual labels:  snippets
Sublime-GameMaker-Studio-Language-Bundle
A sublime bundle for GameMaker Language (GML)
Stars: ✭ 32 (-87.1%)
Mutual labels:  snippets
vim-snipp-snapp-snut-and-the-legend-continues
💇 (Experimental) Vim snippet plugin
Stars: ✭ 24 (-90.32%)
Mutual labels:  snippets
codecolorer
WordPress plugin which allows you to insert code snippets into the post with nice syntax highlighting.
Stars: ✭ 56 (-77.42%)
Mutual labels:  snippets
Java Design Patterns
Design patterns implemented in Java
Stars: ✭ 71,923 (+28901.21%)
Mutual labels:  snippets
snippets
Short (but useful) scripts and programs.
Stars: ✭ 31 (-87.5%)
Mutual labels:  snippets
twig.vim
Twig syntax highlighting, indentation, neocomplete and UltiSnips snippets in Vim
Stars: ✭ 30 (-87.9%)
Mutual labels:  snippets
Cookbook
Code snippets for various programming languages and libraries
Stars: ✭ 245 (-1.21%)
Mutual labels:  snippets
dotfiles
My dotfiles - Emacs centric OSX Big Sur
Stars: ✭ 29 (-88.31%)
Mutual labels:  doom-emacs
Web
A free, open-source, and completely encrypted notes app. https://standardnotes.com
Stars: ✭ 3,061 (+1134.27%)
Mutual labels:  snippets
pipet
Personal snippet manager, store bits of text.
Stars: ✭ 21 (-91.53%)
Mutual labels:  snippets
vscode-control-snippets
Disable or enable VS Code's built-in snippets and manually installed snippets from extensions.
Stars: ✭ 43 (-82.66%)
Mutual labels:  snippets
linden-scripting-language
Linden Scripting Language (LSL / Second Life) files for your editor.
Stars: ✭ 53 (-78.63%)
Mutual labels:  snippets
htmlrecipes
A collection of quick copy HTML snippets for a variety of common scenarios.
Stars: ✭ 113 (-54.44%)
Mutual labels:  snippets

Release tag Discord Server Discourse server

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)
  • straight.el users can use:

(use-package doom-snippets
  :after yasnippet
  :straight (doom-snippets :type git :host github :repo "doomemacs/snippets" :files ("*.el" "*")))

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].