├── Carton
├── README.md
├── datomic-snippets-pkg.el
├── datomic-snippets.el
└── snippets
└── clojure-mode
├── datomic-schema-attr-doc
├── datomic-schema-attr-fulltext
├── datomic-schema-attr-index
├── datomic-schema-attr-isComponent
├── datomic-schema-attr-noHistory
├── datomic-schema-attr-unique
├── datomic-schema-attribute
├── datomic-schema-cardinality-many
├── datomic-schema-function
├── datomic-schema-type-bigdec
├── datomic-schema-type-bigint
├── datomic-schema-type-boolean
├── datomic-schema-type-bytes
├── datomic-schema-type-double
├── datomic-schema-type-float
├── datomic-schema-type-instant
├── datomic-schema-type-keyword
├── datomic-schema-type-long
├── datomic-schema-type-ref
├── datomic-schema-type-string
├── datomic-schema-type-uri
├── datomic-schema-type-uuid
├── datomic-schema-unique-identity
└── datomic-schema-value-type-ref
/Carton:
--------------------------------------------------------------------------------
1 | (source "melpa" "http://melpa.milkbox.net/packages/")
2 |
3 | (package-file "datomic-snippets.el")
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # datomic-snippets.el
2 |
3 | Yasnippets for [Datomic](http://www.datomic.com/).
4 |
5 | ## Installation
6 |
7 | I highly recommend installing datomic-snippets through elpa.
8 |
9 | It's available on [melpa](http://melpa.milkbox.net/):
10 |
11 | M-x package-install datomic-snippets
12 |
13 | You can also install the dependencies on your own, and just dump
14 | datomic-snippets in your path somewhere:
15 |
16 | - s.el
17 | - dash.el
18 |
19 | ## Usage
20 |
21 | - `dsa` Insert a **d**atomic **s**chema **a**ttribute
22 | - `dsf` Insert a **d**atomic **s**chema **f**unction
23 | - `dst` List all **d**atomic **s**chema **t**ypes
24 | - `:db` List additional attribute attributes.
25 |
26 | ## Setup
27 |
28 | Well, you'll have to require it. You'll also need
29 | [yasnippets](https://github.com/capitaomorte/yasnippet) of course.
30 |
31 | (require 'datomic-snippets)
32 |
33 | ## License
34 |
35 | Copyright (C) 2013 Magnar Sveen
36 |
37 | This program is free software; you can redistribute it and/or modify
38 | it under the terms of the GNU General Public License as published by
39 | the Free Software Foundation, either version 3 of the License, or
40 | (at your option) any later version.
41 |
42 | This program is distributed in the hope that it will be useful,
43 | but WITHOUT ANY WARRANTY; without even the implied warranty of
44 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 | GNU General Public License for more details.
46 |
47 | You should have received a copy of the GNU General Public License
48 | along with this program. If not, see .
49 |
--------------------------------------------------------------------------------
/datomic-snippets-pkg.el:
--------------------------------------------------------------------------------
1 | (define-package "datomic-snippets" "0.1.0"
2 | "Yasnippets for Datomic"
3 | '((s "1.4.0") (dash "1.2.0") (yasnippet "0.6.1")))
4 |
--------------------------------------------------------------------------------
/datomic-snippets.el:
--------------------------------------------------------------------------------
1 | ;;; datomic-snippets.el --- Yasnippets for Datomic
2 |
3 | ;; Copyright (C) 2013 Magnar Sveen
4 |
5 | ;; Author: Magnar Sveen
6 | ;; Keywords: snippets
7 | ;; Version: 0.1.0
8 | ;; Package-Requires: ((s "1.4.0") (dash "1.2.0") (yasnippet "0.6.1"))
9 |
10 | ;; This program is free software; you can redistribute it and/or modify
11 | ;; it under the terms of the GNU General Public License as published by
12 | ;; the Free Software Foundation, either version 3 of the License, or
13 | ;; (at your option) any later version.
14 |
15 | ;; This program is distributed in the hope that it will be useful,
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | ;; GNU General Public License for more details.
19 |
20 | ;; You should have received a copy of the GNU General Public License
21 | ;; along with this program. If not, see .
22 |
23 | ;;; Commentary:
24 |
25 | ;; Yasnippets for [Datomic](http://www.datomic.com/).
26 | ;;
27 | ;; Please visit README.md for more commentary.
28 |
29 | ;;; Code:
30 |
31 | (require 'yasnippet)
32 | (require 'dash)
33 | (require 's)
34 |
35 | ;;;###autoload
36 | (defun datomic-snippets-show-docs-at-point ()
37 | (interactive)
38 | (datomic-snippets/show-docs (datomic-snippets/closest-datomic-identifer)))
39 |
40 | (defvar datomic-snippets/docstrings
41 | '((":db.type/string" . "Value type for strings.")
42 | (":db.type/boolean" . "Boolean value type.")
43 | (":db.type/long" . "Fixed integer value type. Same semantics as a Java long: 64 bits wide, two's complement binary representation.")
44 | (":db.type/bigint" . "Value type for arbitrary precision integers. Maps to java.math.BigInteger on Java platforms.")
45 | (":db.type/float" . "Floating point value type. Same semantics as a Java float: single-precision 32-bit IEEE 754 floating point.")
46 | (":db.type/double" . "Floating point value type. Same semantics as a Java double: double-precision 64-bit IEEE 754 floating point.")
47 | (":db.type/bigdec" . "Value type for arbitrary precision floating point numbers. Maps to java.math.BigDecimal on Java platforms.")
48 | (":db.type/ref" . "Value type for references. All references from one entity to another are through attributes with this value type.")
49 | (":db.type/instant" . "Value type for instants in time. Stored internally as a number of milliseconds since midnight, January 1, 1970 UTC. Maps to java.util.Date on Java platforms.")
50 | (":db.type/uuid" . "Value type for UUIDs. Maps to java.util.UUID on Java platforms.")
51 | (":db.type/uri" . "Value type for URIs. Maps to java.net.URI on Java platforms.")
52 | (":db.type/bytes" . "Value type for small binary data. Maps to byte array on Java platforms.")
53 | (":db/cardinality" . "Specifies whether an attribute associates a single value or a set of values with an entity.")
54 | (":db.cardinality/one" . "The attribute is single valued, it associates a single value with an entity.")
55 | (":db.cardinality/many" . "The attribute is multi valued, it associates a set of values with an entity.")
56 | (":db/doc" . "Specifies a documentation string.")
57 | (":db/unique" . "Specifies a uniqueness constraint for the values of an attribute. Setting an attribute :db/unique also implies :db/index.")
58 | (":db.unique/value" . "The attribute value is unique to each entity; attempts to insert a duplicate value for a different entity id will fail")
59 | (":db.unique/identity" . "The attribute value is unique to each entity and upsert is enabled; attempts to insert a duplicate value for a temporary entity id will cause all attributes associated with that temporary id to be merged with the entity already in the database.")
60 | (":db/index" . "Specifies a boolean value indicating that an index should be generated for this attribute. Defaults to false.")
61 | (":db/fulltext" . "Specifies a boolean value indicating that a fulltext search index should be generated for the attribute. Defaults to false.")
62 | (":db/isComponent" . "Specifies that an attribute whose type is :db.type/ref refers to a subcomponent of the entity to which the attribute is applied. When you retract an entity with :db.fn/retractEntity, all subcomponents are also retracted. When you touch an entity, all its subcomponent entities are touched recursively. Defaults to nil.")
63 | (":db/noHistory" . "Specifies a boolean value indicating whether past values of an attribute should not be retained. Defaults to false.")))
64 |
65 | (defvar datomic-snippets/docstrings-regexp
66 | (regexp-opt (-map 'car datomic-snippets/docstrings)))
67 |
68 | (defun -aget (alist key)
69 | (cdr (assoc key alist)))
70 |
71 | (defun datomic-snippets/show-docs (id)
72 | (message (-aget datomic-snippets/docstrings id))
73 | nil)
74 |
75 | (defun datomic-snippets/closest-datomic-identifer ()
76 | (save-excursion
77 | (search-forward " ")
78 | (search-backward-regexp datomic-snippets/docstrings-regexp)
79 | (match-string-no-properties 0)))
80 |
81 | (setq datomic-snippets-root (file-name-directory (or load-file-name
82 | (buffer-file-name))))
83 |
84 | ;;;###autoload
85 | (defun datomic-snippets-initialize ()
86 | (let ((snip-dir (expand-file-name "snippets" datomic-snippets-root)))
87 | (when (boundp 'yas-snippet-dirs)
88 | (add-to-list 'yas-snippet-dirs snip-dir t))
89 | (yas/load-directory snip-dir)))
90 |
91 | ;;;###autoload
92 | (eval-after-load "yasnippet"
93 | '(datomic-snippets-initialize))
94 |
95 | (provide 'datomic-snippets)
96 | ;;; datomic-snippets.el ends here
97 |
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-attr-doc:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-attr-doc
3 | # key: :db
4 | # --
5 | :db/doc true`
6 | (datomic-snippets/show-docs ":db/doc")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-attr-fulltext:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-attr-fulltext
3 | # key: :db
4 | # --
5 | :db/fulltext true`
6 | (datomic-snippets/show-docs ":db/fulltext")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-attr-index:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-attr-index
3 | # key: :db
4 | # --
5 | :db/index true`
6 | (datomic-snippets/show-docs ":db/index")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-attr-isComponent:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-attr-isComponent
3 | # key: :db
4 | # --
5 | :db/isComponent true`
6 | (datomic-snippets/show-docs ":db/isComponent")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-attr-noHistory:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-attr-noHistory
3 | # key: :db
4 | # --
5 | :db/noHistory true`
6 | (datomic-snippets/show-docs ":db/noHistory")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-attr-unique:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-attr-unique
3 | # key: :db
4 | # --
5 | :db/unique :db.unique/identity`
6 | (datomic-snippets/show-docs ":db/unique")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-attribute:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-attribute
3 | # key: dsa
4 | # --
5 | {:db/ident :${1:ident}
6 | :db/valueType dst$0
7 | :db/cardinality :db.cardinality/${2:one}}
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-cardinality-many:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-cardinality-many
3 | # key: :dbcm
4 | # --
5 | :db/cardinality :db.cardinality/many
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-function:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-function
3 | # key: dsf
4 | # --
5 | {:db/ident :${1:ident}
6 | :db/doc "$2"
7 | :db/fn #db/fn {:lang "clojure"
8 | :params [db $3]
9 | :code ($0)}}
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-bigdec:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-bigdec
3 | # key: dst
4 | # --
5 | :db.type/bigdec`
6 | (datomic-snippets/show-docs ":db.type/bigdec")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-bigint:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-bigint
3 | # key: dst
4 | # --
5 | :db.type/bigint`
6 | (datomic-snippets/show-docs ":db.type/bigint")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-boolean:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-boolean
3 | # key: dst
4 | # --
5 | :db.type/boolean`
6 | (datomic-snippets/show-docs ":db.type/boolean")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-bytes:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-bytes
3 | # key: dst
4 | # --
5 | :db.type/bytes`
6 | (datomic-snippets/show-docs ":db.type/bytes")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-double:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-double
3 | # key: dst
4 | # --
5 | :db.type/double`
6 | (datomic-snippets/show-docs ":db.type/double")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-float:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-float
3 | # key: dst
4 | # --
5 | :db.type/float`
6 | (datomic-snippets/show-docs ":db.type/float")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-instant:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-instant
3 | # key: dst
4 | # --
5 | :db.type/instant`
6 | (datomic-snippets/show-docs ":db.type/instant")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-keyword:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-keyword
3 | # key: dst
4 | # --
5 | :db.type/keyword`
6 | (datomic-snippets/show-docs ":db.type/keyword")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-long:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-long
3 | # key: dst
4 | # --
5 | :db.type/long`
6 | (datomic-snippets/show-docs ":db.type/long")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-ref:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-ref
3 | # key: dst
4 | # --
5 | :db.type/ref`
6 | (datomic-snippets/show-docs ":db.type/ref")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-string:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-string
3 | # key: dst
4 | # --
5 | :db.type/string`
6 | (datomic-snippets/show-docs ":db.type/string")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-uri:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-uri
3 | # key: dst
4 | # --
5 | :db.type/uri`
6 | (datomic-snippets/show-docs ":db.type/uri")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-type-uuid:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-type-uuid
3 | # key: dst
4 | # --
5 | :db.type/uuid`
6 | (datomic-snippets/show-docs ":db.type/uuid")`
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-unique-identity:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-unique-identity
3 | # key: :dbui
4 | # --
5 | :db/unique :db.unique/identity
--------------------------------------------------------------------------------
/snippets/clojure-mode/datomic-schema-value-type-ref:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: datomic-schema-value-type-ref
3 | # key: :dbvr
4 | # --
5 | :db/valueType :db.type/ref
--------------------------------------------------------------------------------