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)