aboutsummaryrefslogtreecommitdiffstats
path: root/oni-css
diff options
context:
space:
mode:
authorGravatar Tom Willemse2019-08-23 23:48:41 -0700
committerGravatar Tom Willemse2019-08-23 23:48:41 -0700
commit36c65fbe45a8891e3b02027b0e20bd34ed147bd4 (patch)
treedf7ba7b9ee519812cfe999c7f7e791e97549fd27 /oni-css
parent6902ce5a334545f0d48b86e61b1e828a2a2f5edb (diff)
downloademacs-config-36c65fbe45a8891e3b02027b0e20bd34ed147bd4.tar.gz
emacs-config-36c65fbe45a8891e3b02027b0e20bd34ed147bd4.zip
Actually load the snippets for ‘oni-css’
Diffstat (limited to 'oni-css')
-rw-r--r--oni-css/oni-css.el24
1 files changed, 23 insertions, 1 deletions
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 <tom@ryuslash.org>
;; 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)