aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml11
-rw-r--r--GNUmakefile16
-rw-r--r--oni-twig/Cask11
-rw-r--r--oni-twig/oni-twig.el54
-rw-r--r--oni-twig/snippets/twig-mode/_self5
-rw-r--r--oni-twig/snippets/twig-mode/blk7
-rw-r--r--oni-twig/snippets/twig-mode/def7
-rw-r--r--oni-twig/snippets/twig-mode/ext5
-rw-r--r--oni-twig/snippets/twig-mode/for7
-rw-r--r--oni-twig/snippets/twig-mode/if7
-rw-r--r--oni-twig/snippets/twig-mode/ife9
-rw-r--r--oni-twig/snippets/twig-mode/iif5
-rw-r--r--oni-twig/snippets/twig-mode/imp7
-rw-r--r--oni-twig/snippets/twig-mode/mac7
-rw-r--r--oni-twig/snippets/twig-mode/set5
15 files changed, 162 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cc85730..e27709d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -96,6 +96,16 @@ package-oni-ruby:
paths:
- oni-ruby/dist/
+package-oni-twig:
+ stage: pre-package-multifile
+ before_script:
+ - rm -rf oni-elisp/dist
+ script:
+ - cask --path oni-twig package
+ artifacts:
+ paths:
+ - oni-twig/dist/
+
test-oni-alert:
stage: test
script: make test-oni-alert
@@ -152,6 +162,7 @@ package:
- package-oni-php
- package-oni-python
- package-oni-ruby
+ - package-oni-twig
before_script:
- rm -rf bin/
- mkdir bin/
diff --git a/GNUmakefile b/GNUmakefile
index 2b478ff..b409d96 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -4,7 +4,7 @@ PACKAGE_TARGETS := $(addprefix package-,$(FILES))
package: $(PACKAGE_TARGETS) package-oni-conf package-oni-css package-oni-elisp \
package-oni-haml package-oni-html package-oni-nxml package-oni-org \
- package-oni-php package-oni-python package-oni-ruby
+ package-oni-php package-oni-python package-oni-ruby package-oni-twig
package-%: %
emacs --batch \
@@ -72,6 +72,12 @@ package-oni-ruby:
--funcall package-initialize \
--eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-ruby/dist/*.tar\") #'string>)))"
+package-oni-twig:
+ emacs --batch \
+ --load oni-package.el \
+ --funcall package-initialize \
+ --eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-twig/dist/*.tar\") #'string>)))"
+
install-%:
emacs --batch \
--load oni-package.el \
@@ -160,6 +166,14 @@ install-oni-ruby:
$(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \
--eval "(package-install-file (car (sort (file-expand-wildcards \"oni-ruby/dist/*.tar\") #'string>)))"
+install-oni-twig:
+ emacs --batch \
+ --load oni-package.el \
+ --fluncall package-initialize \
+ --eval '(package-refresh-contents)' \
+ $(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \
+ --eval "(package-install-file (car (sort (file-expand-wildcards \"oni-twig/dist/*.tar\") #'string>)))"
+
test-%: install-%
emacs --batch \
--load oni-package.el \
diff --git a/oni-twig/Cask b/oni-twig/Cask
new file mode 100644
index 0000000..cf1a2a3
--- /dev/null
+++ b/oni-twig/Cask
@@ -0,0 +1,11 @@
+(source gnu)
+(source melpa)
+
+(package-file "./oni-twig.el")
+
+(depends-on "twig-mode")
+(depends-on "oni-yasnippet" :git "../" :files ("oni-yasnippet.el"))
+
+(files
+ "*.el"
+ ("snippets" "./snippets/*"))
diff --git a/oni-twig/oni-twig.el b/oni-twig/oni-twig.el
new file mode 100644
index 0000000..c71b51a
--- /dev/null
+++ b/oni-twig/oni-twig.el
@@ -0,0 +1,54 @@
+;;; oni-twig.el --- Twig configuration -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2019 Tom Willemse
+
+;; Author: Tom Willemse <tom@ryuslash.org>
+;; Keywords: local
+;; Version: 20190828000459
+;; Package-Requires: (twig-mode oni-yasnippet)
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Configuration for ‘twig-mode’.
+
+;;; Code:
+
+(require 'yasnippet)
+
+(defconst oni-twig-root
+ (file-name-directory
+ (or load-file-name
+ (buffer-file-name)))
+ "The directory where ‘oni-twig’ was loaded from.")
+
+(defconst oni-twig-snippets-dir
+ (expand-file-name "snippets" oni-twig-root)
+ "The directory where ‘oni-twig’ stores its snippets.")
+
+;;;###autoload
+(defun oni-twig-snippets-initialize ()
+ "Initialize the snippets for ‘oni-twig’."
+ (when (boundp 'yas-snippet-dirs)
+ (add-to-list 'yas-snippet-dirs oni-twig-snippets-dir))
+ (yas-load-directory oni-twig-snippets-dir))
+
+;;;###autoload
+(with-eval-after-load 'twig-mode
+ (with-eval-after-load 'yasnippet
+ (oni-twig-snippets-initialize)))
+
+(provide 'oni-twig)
+;;; oni-twig.el ends here
diff --git a/oni-twig/snippets/twig-mode/_self b/oni-twig/snippets/twig-mode/_self
new file mode 100644
index 0000000..c441690
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/_self
@@ -0,0 +1,5 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: _self
+# key: _self
+# --
+{% import _self as ${1:`(file-name-nondirectory (file-name-sans-extension buffer-file-name))`} %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/blk b/oni-twig/snippets/twig-mode/blk
new file mode 100644
index 0000000..bb100a3
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/blk
@@ -0,0 +1,7 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: block
+# key: blk
+# --
+{% block $1 %}
+ $0
+{% endblock %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/def b/oni-twig/snippets/twig-mode/def
new file mode 100644
index 0000000..78dead4
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/def
@@ -0,0 +1,7 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: default value
+# key: def
+# --
+{% if $1 is not defined %}
+ {% set $1 = $2 %}
+{% endif %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/ext b/oni-twig/snippets/twig-mode/ext
new file mode 100644
index 0000000..501cae8
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/ext
@@ -0,0 +1,5 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: extends
+# key: ext
+# --
+{% extends "$1" %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/for b/oni-twig/snippets/twig-mode/for
new file mode 100644
index 0000000..01c0cc5
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/for
@@ -0,0 +1,7 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: for
+# key: for
+# --
+{% for $1 in $2 %}
+ `yas-selected-text`$0
+{% endfor %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/if b/oni-twig/snippets/twig-mode/if
new file mode 100644
index 0000000..a9385d9
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/if
@@ -0,0 +1,7 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: if
+# key: if
+# --
+{% if $1 %}
+ $0
+{% endif %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/ife b/oni-twig/snippets/twig-mode/ife
new file mode 100644
index 0000000..a4d18f3
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/ife
@@ -0,0 +1,9 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: if...else
+# key: ife
+# --
+{% if $1 %}
+ $0
+{% else %}
+
+{% endif %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/iif b/oni-twig/snippets/twig-mode/iif
new file mode 100644
index 0000000..df26b61
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/iif
@@ -0,0 +1,5 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: Inline if
+# key: iif
+# --
+{% if $1 %}$0{% endif %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/imp b/oni-twig/snippets/twig-mode/imp
new file mode 100644
index 0000000..01ceb69
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/imp
@@ -0,0 +1,7 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: import
+# key: imp
+# --
+{% import "${1:module}" as ${1:$(if (string-match "/\\\\([^/]*\\\\)$" yas-text)
+ (match-string 1 yas-text)
+ yas-text)} %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/mac b/oni-twig/snippets/twig-mode/mac
new file mode 100644
index 0000000..d4e480a
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/mac
@@ -0,0 +1,7 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: macro
+# key: mac
+# --
+{% macro ${1:name}(${2:args}) %}
+ $0
+{% endmacro %} \ No newline at end of file
diff --git a/oni-twig/snippets/twig-mode/set b/oni-twig/snippets/twig-mode/set
new file mode 100644
index 0000000..715c828
--- /dev/null
+++ b/oni-twig/snippets/twig-mode/set
@@ -0,0 +1,5 @@
+# -*- mode: snippet; require-final-newline: nil -*-
+# name: set
+# key: set
+# --
+{% set $1 = $2 %} \ No newline at end of file