more editor shit, use repls for things, show docs in autocomplete
This commit is contained in:
parent
5914e83437
commit
6df7ec8c33
|
@ -83,9 +83,12 @@
|
||||||
(fn replace-selected-symbol [text] (: (place-to-symbol (get-selection)) :replace-text text))
|
(fn replace-selected-symbol [text] (: (place-to-symbol (get-selection)) :replace-text text))
|
||||||
|
|
||||||
(fn autocomplete-results [text]
|
(fn autocomplete-results [text]
|
||||||
(var result [])
|
(var symbols [])
|
||||||
(: (replsession.session) :submit (.. ",complete " text) #(set result (or $1.vals [])) true)
|
(: (replsession.session) :submit (.. ",complete " text) #(set symbols (or $1.vals [])) true)
|
||||||
result)
|
(icollect [_ symbol (ipairs symbols)]
|
||||||
|
(let [item {:text symbol}]
|
||||||
|
(: (replsession.session) :submit (.. ",doc " symbol) #(when $1.vals (set item.info (. $1.vals 1))))
|
||||||
|
item)))
|
||||||
|
|
||||||
(fn autocomplete-symbol [callback ?starting-text]
|
(fn autocomplete-symbol [callback ?starting-text]
|
||||||
(fn fixup-result [text item] (callback (or (and item item.text) text)))
|
(fn fixup-result [text item] (callback (or (and item item.text) text)))
|
||||||
|
@ -96,7 +99,7 @@
|
||||||
(core.command_view:update_suggestions)))
|
(core.command_view:update_suggestions)))
|
||||||
|
|
||||||
(command.add :core.docview {
|
(command.add :core.docview {
|
||||||
"fennel:eval" #(submit nil (selected-form))
|
"fennel:eval" #(submit (selected-form))
|
||||||
"fennel:go-to-definition-under-cursor" #(go-to-definition (selected-symbol))
|
"fennel:go-to-definition-under-cursor" #(go-to-definition (selected-symbol))
|
||||||
"fennel:go-to-definition" #(autocomplete-symbol #(go-to-definition $1) (selected-symbol))
|
"fennel:go-to-definition" #(autocomplete-symbol #(go-to-definition $1) (selected-symbol))
|
||||||
"fennel:autocomplete" #(autocomplete-symbol #(replace-selected-symbol $1) (selected-symbol))
|
"fennel:autocomplete" #(autocomplete-symbol #(replace-selected-symbol $1) (selected-symbol))
|
||||||
|
|
|
@ -21,6 +21,13 @@
|
||||||
|
|
||||||
(fn replsession.new-session [] (replsession.restart-session {:submit replsession.submit}))
|
(fn replsession.new-session [] (replsession.restart-session {:submit replsession.submit}))
|
||||||
|
|
||||||
|
(fn replsession.current-session-id []
|
||||||
|
(var session-id nil)
|
||||||
|
(let [coro (coroutine.running)]
|
||||||
|
(each [id session (pairs replsession.sessions)]
|
||||||
|
(when (= session.coro coro) (set session-id id)))
|
||||||
|
session-id))
|
||||||
|
|
||||||
(fn replsession.submit [session chunk callback ?suppress-crash]
|
(fn replsession.submit [session chunk callback ?suppress-crash]
|
||||||
(assert (= session.callback nil))
|
(assert (= session.callback nil))
|
||||||
(set session.callback callback)
|
(set session.callback callback)
|
||||||
|
|
|
@ -21,15 +21,16 @@
|
||||||
(set view.inspector-name name)
|
(set view.inspector-name name)
|
||||||
(set view.title name)
|
(set view.title name)
|
||||||
(view:append {:draw (fn [_ _ x y] (renderer.draw_text style.font name x y style.text) (+ (style.font:get_height) style.padding.y))})
|
(view:append {:draw (fn [_ _ x y] (renderer.draw_text style.font name x y style.text) (+ (style.font:get_height) style.padding.y))})
|
||||||
(view:append (repl.mk-result [?value]))
|
(when ?value
|
||||||
(node:add_view view)
|
(view:append (repl.mk-result [?value])))
|
||||||
|
(node:split :right view)
|
||||||
view))
|
view))
|
||||||
|
|
||||||
(lambda module.show [?name ?value]
|
(lambda module.show [?value ?name]
|
||||||
(let [name (replsession.session-id ?name)]
|
(let [name (replsession.session-id ?name)]
|
||||||
(or (find-existing-inspector-window name) (create-inspector-window name ?value))))
|
(or (find-existing-inspector-window name) (create-inspector-window name ?value))))
|
||||||
|
|
||||||
(lambda module.submit [?name chunk]
|
(lambda module.submit [chunk ?name]
|
||||||
(: (module.show ?name) :submit chunk))
|
(: (module.show ?name) :submit chunk))
|
||||||
|
|
||||||
module.hot
|
module.hot
|
||||||
|
|
Loading…
Reference in a new issue