From e530fbfc5f47e5fb19107f442f3d752ed049817c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 27 Aug 2019 23:53:06 -0700 Subject: [PATCH] =?UTF-8?q?Add=20snippets=20for=20=E2=80=98oni-php?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 14 +++++++++++++ GNUmakefile | 17 +++++++++++++++- oni-php/Cask | 19 ++++++++++++++++++ oni-php.el => oni-php/oni-php.el | 27 ++++++++++++++++++++++++-- oni-php/snippets/php-mode/function | 8 ++++++++ oni-php/snippets/php-mode/wpheader.php | 13 +++++++++++++ 6 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 oni-php/Cask rename oni-php.el => oni-php/oni-php.el (80%) create mode 100644 oni-php/snippets/php-mode/function create mode 100644 oni-php/snippets/php-mode/wpheader.php diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 359339f..c6fddd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,6 +66,16 @@ package-oni-nxml: paths: - oni-nxml/dist/ +package-oni-php: + stage: pre-package-multifile + before_script: + - rm -rf oni-elisp/dist + script: + - cask --path oni-php package + artifacts: + paths: + - oni-php/dist/ + test-oni-alert: stage: test script: make test-oni-alert @@ -105,6 +115,9 @@ test-oni-highlight-indent-guides: test-oni-php: stage: test + dependencies: + - package-oni-php + needs: [package-oni-php] script: make test-oni-php package: @@ -116,6 +129,7 @@ package: - package-oni-haml - package-oni-html - package-oni-nxml + - package-oni-php before_script: - rm -rf bin/ - mkdir bin/ diff --git a/GNUmakefile b/GNUmakefile index 246208b..36b22e8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,8 @@ FILES := $(wildcard *.el) 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-haml package-oni-html package-oni-nxml package-oni-org \ + package-oni-php package-%: % emacs --batch \ @@ -53,6 +54,12 @@ package-oni-org: --funcall package-initialize \ --eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-org/dist/*.tar\") #'string>)))" +package-oni-php: + emacs --batch \ + --load oni-package.el \ + --funcall package-initialize \ + --eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-php/dist/*.tar\") #'string>)))" + install-%: emacs --batch \ --load oni-package.el \ @@ -117,6 +124,14 @@ install-oni-org: $(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \ --eval "(package-install-file (car (sort (file-expand-wildcards \"oni-org/dist/*.tar\") #'string>)))" +install-oni-php: + 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-php/dist/*.tar\") #'string>)))" + test-%: install-% emacs --batch \ --load oni-package.el \ diff --git a/oni-php/Cask b/oni-php/Cask new file mode 100644 index 0000000..6011891 --- /dev/null +++ b/oni-php/Cask @@ -0,0 +1,19 @@ +(source gnu) +(source melpa) + +(package-file "./oni-php.el") + +(depends-on "php-mode") +(depends-on "oni-yasnippet" :git "../" :files ("oni-yasnippet.el")) +(depends-on "oni-flycheck" :git "../" :files ("oni-flycheck.el")) +(depends-on "oni-company" :git "../" :files ("oni-company.el")) +(depends-on "oni-fci" :git "../" :files ("oni-fci.el")) +(depends-on "ggtags") +(depends-on "fic-mode") +(depends-on "hydra") +(depends-on "company-php") +(depends-on "phpcbf") + +(files + "*.el" + ("snippets" "./snippets/*")) diff --git a/oni-php.el b/oni-php/oni-php.el similarity index 80% rename from oni-php.el rename to oni-php/oni-php.el index 4b21c9c..ed7fbb9 100644 --- a/oni-php.el +++ b/oni-php/oni-php.el @@ -4,8 +4,8 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 20190505200117 -;; Package-Requires: (php-mode oni-flycheck oni-company oni-fci ggtags fic-mode hydra company-php phpcbf) +;; Version: 20190827234741 +;; Package-Requires: (php-mode oni-yasnippet oni-flycheck oni-company oni-fci ggtags fic-mode hydra company-php phpcbf) ;; 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 @@ -31,6 +31,24 @@ (require 'company) (require 'php-mode) (require 'whitespace) +(require 'yasnippet) + +(defconst oni-php-root + (file-name-directory + (or load-file-name + (buffer-file-name))) + "The directory where ‘oni-php’ was loaded from.") + +(defconst oni-php-snippets-dir + (expand-file-name "snippets" oni-php-root) + "The directory where ‘oni-php’ stores its snippets.") + +;;;###autoload +(defun oni-php-snippets-initialize () + "Initialize the snippets for ‘oni-php’." + (when (boundp 'yas-snippet-dirs) + (add-to-list 'yas-snippet-dirs oni-php-snippets-dir)) + (yas-load-directory oni-php-snippets-dir)) (defun oni-php--set-require-final-newline () "Set `require-final-newline' to t. @@ -94,6 +112,11 @@ nil for some reason." (modes . '(php-mode web-mode)) (repeat . t))) +;;;###autoload +(with-eval-after-load 'php-mode + (with-eval-after-load 'yasnippet + (oni-php-snippets-initialize))) + ;;;###autoload(with-eval-after-load 'php-mode (require 'oni-php)) ;;;###autoload(add-to-list 'auto-mode-alist '("\\.inc\\'" . php-mode)) ;;;###autoload(add-to-list 'auto-mode-alist '("\\.module\\'" . php-mode)) diff --git a/oni-php/snippets/php-mode/function b/oni-php/snippets/php-mode/function new file mode 100644 index 0000000..ab4cf2c --- /dev/null +++ b/oni-php/snippets/php-mode/function @@ -0,0 +1,8 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: function +# key: function +# -- +function $1($2) +{ + $0 +} \ No newline at end of file diff --git a/oni-php/snippets/php-mode/wpheader.php b/oni-php/snippets/php-mode/wpheader.php new file mode 100644 index 0000000..2c70f93 --- /dev/null +++ b/oni-php/snippets/php-mode/wpheader.php @@ -0,0 +1,13 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: WP Plugin Header +# key: header +# -- +/* + * Plugin Name: $1 + * Plugin URI: $2 + * Description: $3 + * Version: ${4:1.0} + * Author: ${5:Tom Willemse} + * Author URI: ${6:https://ryuslash.org} + * License: ${7:GPLv2} + */ \ No newline at end of file