From 36c65fbe45a8891e3b02027b0e20bd34ed147bd4 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 23 Aug 2019 23:48:41 -0700 Subject: [PATCH] =?UTF-8?q?Actually=20load=20the=20snippets=20for=20?= =?UTF-8?q?=E2=80=98oni-css=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oni-css/oni-css.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/oni-css/oni-css.el b/oni-css/oni-css.el index 6669f3c..fe126ac 100644 --- a/oni-css/oni-css.el +++ b/oni-css/oni-css.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 20190822234329 +;; Version: 20190823234829 ;; Package-Requires: (oni-company oni-fci hydra rainbow-mode) ;; This program is free software; you can redistribute it and/or modify @@ -29,11 +29,22 @@ (require 'align) (require 'css-mode) (require 'hydra) +(require 'yasnippet) (eval-when-compile (require 'compile) (require 'grep)) +(defconst oni-css-root + (file-name-directory + (or load-file-name + (buffer-file-name))) + "The directory where ‘oni-css’ was loaded from.") + +(defconst oni-css-snippets-dir + (expand-file-name "snippets" oni-css-root) + "The directory where ‘oni-conf’ stores its snippets.") + (defun oni-css-property-important-p () "Return whether or not the current property is important." (save-excursion @@ -49,6 +60,12 @@ (when (re-search-backward ";" (line-beginning-position) :noerror) (insert " !important"))))) +(defun oni-css-snippets-initialize () + "Initialize the snippets for ‘oni-css’." + (when (boundp 'yas-snippet-dirs) + (add-to-list 'yas-snippet-dirs oni-css-snippets-dir t)) + (yas-load-directory oni-css-snippets-dir)) + (defun oni-css-remove-important () "Remove the important flag from the property on the current line." (interactive) @@ -141,6 +158,11 @@ (with-eval-after-load 'grep (add-to-list 'grep-files-aliases '("css" . "*.css *.less *.sass *.scss"))) +;;;###autoload +(with-eval-after-load 'css-mode + (with-eval-after-load 'yasnippet + (oni-css-snippets-initialize))) + ;;;###autoload(with-eval-after-load 'css-mode (require 'oni-css)) (provide 'oni-css)