File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
clj/src/vim_clojure_static Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change 9
9
(:import (java.io File)
10
10
(java.util List)))
11
11
12
+ (defmacro with-tempfile
13
+ {:requires [File]}
14
+ [tmp-sym & body]
15
+ `(let [~tmp-sym (File/createTempFile " vim-clojure-static" " .tmp" )]
16
+ (try
17
+ ~@body
18
+ (finally
19
+ (.delete ~tmp-sym)))))
20
+
12
21
(defn vim-exec
13
22
" Spit buf into file, then execute vim-expr after Vim loads the file. The
14
23
value of vim-expr is evaluated as EDN and returned."
15
24
[file buf vim-expr]
16
- (let [tmp (File/createTempFile " vim-clojure-static.test." " .out" )]
17
- (try
18
- (io/make-parents file)
19
- (spit file buf)
20
- (spit tmp (str " let @x = " vim-expr))
21
- (shell/sh " vim" " -N" " -u" " vim/test-runtime.vim"
22
- " -c" (str " source " tmp " | call writefile([@x], " (pr-str (str tmp)) " ) | quitall!" )
23
- file)
24
- (edn/read-string (slurp tmp))
25
- (finally
26
- (.delete tmp)))))
25
+ (with-tempfile tmp
26
+ (io/make-parents file)
27
+ (spit file buf)
28
+ (spit tmp (str " let @x = " vim-expr))
29
+ (shell/sh " vim" " -N" " -u" " vim/test-runtime.vim"
30
+ " -c" (str " source " tmp " | call writefile([@x], " (pr-str (str tmp)) " ) | quitall!" )
31
+ file)
32
+ (edn/read-string (slurp tmp))))
27
33
28
34
(defn syn-id-names
29
35
" Map lines of clojure text to vim synID names at each column as keywords:
62
68
At runtime the syn-id-names of the strings (which are placed in the format
63
69
spec) are passed to their associated predicates. The format spec should
64
70
contain a single `%s`."
65
- {:require [#'test/deftest]}
71
+ {:requires [#'test/deftest syn-id-names subfmt ]}
66
72
[name & body]
67
73
(assert (every? (fn [[fmt tests]] (and (string? fmt)
68
74
(coll? tests)
76
82
[[] []] body)
77
83
syntable (gensym " syntable" )]
78
84
`(test/deftest ~name
79
- ; ; Shellout to vim should happen at runtime
80
85
(let [~syntable (syn-id-names (str " tmp/" ~(str name) " .clj" ) ~@strings)]
81
86
~@(map (fn [{:keys [fmt ss λs]}]
82
87
`(test/testing ~fmt
You can’t perform that action at this time.
0 commit comments