Fork me on GitHub
#emacs
<
2021-08-02
>
solf15:08:04

Anyone making their own clojure snippets? I have a few for some specific clojurescript code I kept repeating, and I just added one for add-libs+find-deps (which act more as a how-to, I keep forgetting their fully-qualified name)

;; snippet definitions, only KEY and TEMPLATE are actually mandatory.
;; (KEY TEMPLATE NAME CONDITION GROUP EXPAND-ENV LOAD-FILE KEYBINDING UUID SAVE-FILE) 
(yas-define-snippets
 'clojure-mode
 '(
   (":d" "[:div $0]" "hiccup div")
   (":p" "[:p $0]" "hiccup p")
   ("f" "#($1 % $0)" "f-shorthand")
   ("ctw" "{:class (tw $0)}" "class-tw")
   
   ("add-libs"
    "
(require '[clojure.tools.deps.alpha.repl :refer [add-libs]]
         '[find-deps.core :refer [query*]])

(:deps (query* $0\"metosin/malli\" \"clojure data.json\"
               {:sources [:clojars :mvn]
                :rank :fuzzy
                :limit 1
                :format :deps}))

(add-libs '{})"
    "add-libs")
   ))

mpenet22:08:04

You could try to modify zencoding mode for hiccup