Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #497 Scheme client #498

Merged
merged 4 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/conjure-client-scheme-stdio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ options relevant to these mappings.

<localleader>cS Stop any existing Scheme REPL.

<localleader>ei Interrupt running command. Same as pressing Ctrl-C
in a cmdline REPL.

==============================================================================
CONFIGURATION *conjure-client-scheme-stdio-configuration*

Expand Down
17 changes: 15 additions & 2 deletions fnl/conjure/client/scheme/stdio.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
{:scheme
{:stdio
{:mapping {:start "cs"
:stop "cS"}
:stop "cS"
:interrupt "ei"}
:command "mit-scheme"
;; Match "]=> " or "error> "
:prompt_pattern "[%]e][=r]r?o?r?> "
Expand Down Expand Up @@ -119,6 +120,12 @@
(fn [msg]
(log.append (format-msg msg)))}))))

(defn interrupt []
(with-repl-or-warn
(fn [repl]
(log.append [(.. comment-prefix " Sending interrupt signal.")] {:break? true})
(repl.send-signal vim.loop.constants.SIGINT))))

(defn on-load []
(start))

Expand All @@ -131,7 +138,13 @@
(mapping.buf
:SchemeStop (cfg [:mapping :stop])
stop
{:desc "Stop the REPL"}))
{:desc "Stop the REPL"})

(mapping.buf
:SchemeInterrupt (cfg [:mapping :interrupt])
interrupt
{:desc "Interrupt the REPL"}))

(defn on-exit []
(stop))

13 changes: 11 additions & 2 deletions lua/conjure/client/scheme/stdio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _2amodule_locals_2a["stdio"] = stdio
_2amodule_locals_2a["str"] = str
_2amodule_locals_2a["ts"] = ts
_2amodule_locals_2a["_"] = _
config.merge({client = {scheme = {stdio = {mapping = {start = "cs", stop = "cS"}, command = "mit-scheme", prompt_pattern = "[%]e][=r]r?o?r?> ", value_prefix_pattern = "^;Value: "}}}})
config.merge({client = {scheme = {stdio = {mapping = {start = "cs", stop = "cS", interrupt = "ei"}, command = "mit-scheme", prompt_pattern = "[%]e][=r]r?o?r?> ", value_prefix_pattern = "^;Value: "}}}})
local cfg = config["get-in-fn"]({"client", "scheme", "stdio"})
do end (_2amodule_locals_2a)["cfg"] = cfg
local state
Expand Down Expand Up @@ -128,13 +128,22 @@ local function start()
end
end
_2amodule_2a["start"] = start
local function interrupt()
local function _17_(repl)
log.append({(comment_prefix .. " Sending interrupt signal.")}, {["break?"] = true})
return repl["send-signal"](vim.loop.constants.SIGINT)
end
return with_repl_or_warn(_17_)
end
_2amodule_2a["interrupt"] = interrupt
local function on_load()
return start()
end
_2amodule_2a["on-load"] = on_load
local function on_filetype()
mapping.buf("SchemeStart", cfg({"mapping", "start"}), start, {desc = "Start the REPL"})
return mapping.buf("SchemeStop", cfg({"mapping", "stop"}), stop, {desc = "Stop the REPL"})
mapping.buf("SchemeStop", cfg({"mapping", "stop"}), stop, {desc = "Stop the REPL"})
return mapping.buf("SchemeInterrupt", cfg({"mapping", "interrupt"}), interrupt, {desc = "Interrupt the REPL"})
end
_2amodule_2a["on-filetype"] = on_filetype
local function on_exit()
Expand Down