File tree 6 files changed +31
-36
lines changed
6 files changed +31
-36
lines changed Original file line number Diff line number Diff line change
1
+ /rplugin
Original file line number Diff line number Diff line change 24
24
last))
25
25
26
26
(defn to-root [loc]
27
- (exec-to loc z/up #(not (top? %))))
27
+ (if (top? loc)
28
+ loc
29
+ (exec-to loc z/up #(not (top? %)))))
28
30
29
31
(defn parent-let? [zloc]
30
32
(= 'let (-> zloc z/up z/leftmost z/sexpr)))
129
131
(defn read-position
130
132
[old-pos zloc]
131
133
(-> zloc
132
- (zdbg " read-position" )
133
134
(remove-all-after )
134
135
(z/root-string )
135
136
(z/of-string )
145
146
146
147
(defn find-mark
147
148
[zloc marker]
148
- (if-let [mloc (z/find (to-root zloc) z/next #( = marker (get (z/node % ) ::marker )))]
149
+ (if-let [mloc (z/find (to-root zloc) z/next ( fn [loc] ( = marker (get (z/node loc ) ::marker ) )))]
149
150
mloc
150
151
zloc))
Original file line number Diff line number Diff line change 51
51
(z/of-string )
52
52
(z/find-last-by-pos pos #(not= (z/tag %) :whitespace ))
53
53
(edit/mark-position :new-cursor )
54
+ ; ; TODO should check if anything has changed
55
+ ; ; - should return nil if transformer returned nil
54
56
(transformer args)
55
57
(edit/find-mark :new-cursor )
56
58
(swap-position! new-cursor)
57
- (edit/zdbg (pr-str @new-cursor))
58
- ; ; TODO should check if anything has changed
59
- ; ; - should return nil if transformer returned nil
60
59
(z/root-string )
61
60
(parinfer/parenMode )
62
61
(aget " text" ))]
109
108
; ; REPL only commands
110
109
(.command js/plugin " CAddMissingLibSpec" #js {:eval " expand('<cword>')" :nargs 0 }
111
110
(partial repl/add-missing-libspec run-transform))
112
- (.command js/plugin " CCleanNS" #js {:eval " expand('%:p')" :nargs 0 }
111
+ (.command js/plugin " CCleanNS" #js {:eval " [getpos('.'), expand('%:p')] " :nargs 0 }
113
112
(partial repl/clean-ns run-transform))
114
113
(.command js/plugin " CRenameFile" #js {:eval " expand('%:p')" :nargs 1 :complete " file" }
115
114
repl/rename-file)
Original file line number Diff line number Diff line change 64
64
(defn clean-ns
65
65
" Asks repl for the missing libspec.
66
66
When the repl comes back with response, run transform to add to ns"
67
- [run-transform nvim _ path]
67
+ [run-transform nvim _ [cursor path] ]
68
68
(fireplace-message
69
69
nvim
70
70
{:op " clean-ns" :path path :prefix-rewriting " false" }
73
73
(let [ns-str (aget (first results) " ns" )]
74
74
(when (string? ns-str)
75
75
(run-transform
76
- transform/replace-ns nvim [(parser/parse-string ns-str)] fake- cursor))))))
76
+ transform/replace-ns nvim [(parser/parse-string ns-str)] cursor))))))
77
77
78
78
(defn rename-file
79
79
[nvim [new-file] current-file]
Original file line number Diff line number Diff line change 16
16
[rewrite-clj.zip.utils :as zu]
17
17
[rewrite-clj.zip.whitespace :as ws]))
18
18
19
- (defn zdbg
20
- [zloc]
21
- (println (z/sexpr zloc))
22
- zloc )
23
-
24
19
(defn introduce-let
25
20
" Adds a let around the current form."
26
21
[zloc [binding-name]]
You can’t perform that action at this time.
0 commit comments