edtris/editor/init.fnl

38 lines
958 B
Plaintext
Raw Normal View History

2021-02-07 21:56:19 +00:00
(local util (require :lib.util))
(local core (require :core))
(local command (require :core.command))
(local keymap (require :core.keymap))
(local common (require :core.common))
(fn selected-form []
2021-02-07 21:56:19 +00:00
(let [ldoc core.active_view.doc
(aline acol bline bcol) (ldoc:get_selection)]
2021-02-07 21:56:19 +00:00
(if (and (= aline bline) (= acol bcol))
(ldoc:get_text aline 1 aline 10000000)
(ldoc:get_text aline acol bline bcol))))
(fn inline-eval [eval]
(let [ldoc core.active_view.doc
(aline acol bline bcol) (ldoc:get_selection)]
(ldoc:insert bline bcol (eval (selected-form)))))
2021-02-07 21:56:19 +00:00
(require :editor.editmode)
2021-03-29 05:03:43 +00:00
(command.add :editor.replview {
"repl:submit" #(core.active_view:submit)
})
(local {: show : submit} (util.require :inspector.debug))
2021-03-29 05:03:43 +00:00
(command.add nil {
"repl:create" #(show)
})
(command.add :core.docview {
"repl:eval" #(submit nil (selected-form))
2021-03-29 05:03:43 +00:00
})
(keymap.add {
:return "repl:submit"
"alt+e" "repl:eval"
2021-03-29 05:03:43 +00:00
})
2021-02-07 21:56:19 +00:00
{: inline-eval}