Add ‘oni-twig’
For now this only contains snippets.
This commit is contained in:
parent
567d78a12c
commit
ca973c76e9
15 changed files with 162 additions and 1 deletions
|
@ -96,6 +96,16 @@ package-oni-ruby:
|
||||||
paths:
|
paths:
|
||||||
- oni-ruby/dist/
|
- 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:
|
test-oni-alert:
|
||||||
stage: test
|
stage: test
|
||||||
script: make test-oni-alert
|
script: make test-oni-alert
|
||||||
|
@ -152,6 +162,7 @@ package:
|
||||||
- package-oni-php
|
- package-oni-php
|
||||||
- package-oni-python
|
- package-oni-python
|
||||||
- package-oni-ruby
|
- package-oni-ruby
|
||||||
|
- package-oni-twig
|
||||||
before_script:
|
before_script:
|
||||||
- rm -rf bin/
|
- rm -rf bin/
|
||||||
- mkdir bin/
|
- mkdir bin/
|
||||||
|
|
16
GNUmakefile
16
GNUmakefile
|
@ -4,7 +4,7 @@ PACKAGE_TARGETS := $(addprefix package-,$(FILES))
|
||||||
|
|
||||||
package: $(PACKAGE_TARGETS) package-oni-conf package-oni-css package-oni-elisp \
|
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-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-%: %
|
package-%: %
|
||||||
emacs --batch \
|
emacs --batch \
|
||||||
|
@ -72,6 +72,12 @@ package-oni-ruby:
|
||||||
--funcall package-initialize \
|
--funcall package-initialize \
|
||||||
--eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-ruby/dist/*.tar\") #'string>)))"
|
--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-%:
|
install-%:
|
||||||
emacs --batch \
|
emacs --batch \
|
||||||
--load oni-package.el \
|
--load oni-package.el \
|
||||||
|
@ -160,6 +166,14 @@ install-oni-ruby:
|
||||||
$(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \
|
$(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \
|
||||||
--eval "(package-install-file (car (sort (file-expand-wildcards \"oni-ruby/dist/*.tar\") #'string>)))"
|
--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-%
|
test-%: install-%
|
||||||
emacs --batch \
|
emacs --batch \
|
||||||
--load oni-package.el \
|
--load oni-package.el \
|
||||||
|
|
11
oni-twig/Cask
Normal file
11
oni-twig/Cask
Normal file
|
@ -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/*"))
|
54
oni-twig/oni-twig.el
Normal file
54
oni-twig/oni-twig.el
Normal file
|
@ -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
|
5
oni-twig/snippets/twig-mode/_self
Normal file
5
oni-twig/snippets/twig-mode/_self
Normal file
|
@ -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))`} %}
|
7
oni-twig/snippets/twig-mode/blk
Normal file
7
oni-twig/snippets/twig-mode/blk
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: block
|
||||||
|
# key: blk
|
||||||
|
# --
|
||||||
|
{% block $1 %}
|
||||||
|
$0
|
||||||
|
{% endblock %}
|
7
oni-twig/snippets/twig-mode/def
Normal file
7
oni-twig/snippets/twig-mode/def
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: default value
|
||||||
|
# key: def
|
||||||
|
# --
|
||||||
|
{% if $1 is not defined %}
|
||||||
|
{% set $1 = $2 %}
|
||||||
|
{% endif %}
|
5
oni-twig/snippets/twig-mode/ext
Normal file
5
oni-twig/snippets/twig-mode/ext
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: extends
|
||||||
|
# key: ext
|
||||||
|
# --
|
||||||
|
{% extends "$1" %}
|
7
oni-twig/snippets/twig-mode/for
Normal file
7
oni-twig/snippets/twig-mode/for
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: for
|
||||||
|
# key: for
|
||||||
|
# --
|
||||||
|
{% for $1 in $2 %}
|
||||||
|
`yas-selected-text`$0
|
||||||
|
{% endfor %}
|
7
oni-twig/snippets/twig-mode/if
Normal file
7
oni-twig/snippets/twig-mode/if
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: if
|
||||||
|
# key: if
|
||||||
|
# --
|
||||||
|
{% if $1 %}
|
||||||
|
$0
|
||||||
|
{% endif %}
|
9
oni-twig/snippets/twig-mode/ife
Normal file
9
oni-twig/snippets/twig-mode/ife
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: if...else
|
||||||
|
# key: ife
|
||||||
|
# --
|
||||||
|
{% if $1 %}
|
||||||
|
$0
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% endif %}
|
5
oni-twig/snippets/twig-mode/iif
Normal file
5
oni-twig/snippets/twig-mode/iif
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: Inline if
|
||||||
|
# key: iif
|
||||||
|
# --
|
||||||
|
{% if $1 %}$0{% endif %}
|
7
oni-twig/snippets/twig-mode/imp
Normal file
7
oni-twig/snippets/twig-mode/imp
Normal file
|
@ -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)} %}
|
7
oni-twig/snippets/twig-mode/mac
Normal file
7
oni-twig/snippets/twig-mode/mac
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: macro
|
||||||
|
# key: mac
|
||||||
|
# --
|
||||||
|
{% macro ${1:name}(${2:args}) %}
|
||||||
|
$0
|
||||||
|
{% endmacro %}
|
5
oni-twig/snippets/twig-mode/set
Normal file
5
oni-twig/snippets/twig-mode/set
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- mode: snippet; require-final-newline: nil -*-
|
||||||
|
# name: set
|
||||||
|
# key: set
|
||||||
|
# --
|
||||||
|
{% set $1 = $2 %}
|
Loading…
Reference in a new issue