Skip to content

Commit

Permalink
Make snd-s7 client optional. Add help doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
russtoku authored and Olical committed Jul 11, 2023
1 parent ad574db commit 9392c1a
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 45 deletions.
81 changes: 81 additions & 0 deletions doc/conjure-client-snd-s7-stdio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

*conjure-client-snd-s7-stdio*

==============================================================================
CONTENTS *conjure-client-snd-s7-stdio-contents*

1. Introduction ............ |conjure-client-snd-s7-stdio-introduction|
2. Mappings .................... |conjure-client-snd-s7-stdio-mappings|
3. Configuration .......... |conjure-client-snd-s7-stdio-configuration|

==============================================================================
INTRODUCTION *conjure-client-snd-s7-stdio-introduction*
>
Snd is a sound editor created by Bill Schottstaedt <[email protected]>
of the Center for Computer Research in Music and Acoustics (CCRMA). It can
be scripted or extended using the S7 Scheme interpreter built into it. In
this document, snd-s7 is used to refer to the program which is named snd.
Conjure starts a snd-s7 REPL within Neovim when you first open a snd-s7
(`.scm`) file. You can configure how the snd-s7 REPL is launched with the
`g:conjure#client#snd-s7#stdio#command` configuration option.

You should be able to evaluate files and forms as you would with other Conjure
supported languages right away.

Check out `:ConjureSchool` if you're unsure about what evaluation operations
you can perform.

* https://ccrma.stanford.edu/software/snd/snd/snd.html
* https://ccrma.stanford.edu/software/snd/snd/s7.html
* https://ccrma.stanford.edu/

==============================================================================
MAPPINGS *conjure-client-snd-s7-stdio-mappings*

These mappings are the defaults, you can change them as described in
|conjure-mappings| and |conjure-configuration|.

See |conjure-client-snd-s7-stdio-configuration| for specific configuration
options relevant to these mappings.

<localleader>cs Start the snd-s7 REPL if it's not running already.

<localleader>cS Stop any existing snd-s7 REPL.

<localleader>ei Interrupt running command. Same as pressing Ctrl-C
in a cmdline REPL. This may actually stop the REPL.

==============================================================================
CONFIGURATION *conjure-client-snd-s7-stdio-configuration*

All configuration can be set as described in |conjure-configuration|.

*g:conjure#client#snd-s7#stdio#mapping#start*
`g:conjure#client#snd-s7#stdio#mapping#start`
Start the snd-s7 REPL if it's not running already.
Default: `"cs"`

*g:conjure#client#snd-s7#stdio#mapping#stop*
`g:conjure#client#snd-s7#stdio#mapping#stop`
Stop any existing snd-s7 REPL.
Default: `"cS"`

*g:conjure#client#snd-s7#stdio#command*
`g:conjure#client#snd-s7#stdio#command`
Command used to start the snd-s7 REPL, you can modify this to add
arguments or change the command entirely.

When using a different REPL you'll probably have to change the
`prompt_pattern` too! Have a look at the default REPL output and
write a Lua pattern that will match that prompt string as best as
you can.

Default: `"snd"`

*g:conjure#client#snd-s7#stdio#prompt_pattern*
`g:conjure#client#snd-s7#stdio#prompt_pattern`
This is not used by this client module.
Default: `"> "`

vim:tw=78:sw=2:ts=2:ft=help:norl:et:listchars=
7 changes: 5 additions & 2 deletions doc/conjure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ configuring these values from Lua it's just `true` and `false`.
`g:conjure#filetype#scheme`
Client to use for `scheme` buffers. You can use Guile over a
socket file instead by setting this to
`"conjure.client.guile.socket"`.
Help: |conjure-client-scheme-stdio|, |conjure-client-guile-socket|
`"conjure.client.guile.socket"`. To edit scripts for the snd/s7
sound editor, set this to `"conjure.client.snd-s7.stdio"`.
Help: |conjure-client-scheme-stdio|,
|conjure-client-guile-socket|, or |conjure-client-snd-s7-stdio.
Default: `"conjure.client.scheme.stdio"`

*g:conjure#filetype#racket*
Expand Down Expand Up @@ -912,6 +914,7 @@ your dotfiles.
- |conjure-client-julia-stdio|
- |conjure-client-lua-stdio|
- |conjure-client-python-stdio|
- |conjure-client-snd-s7-stdio|
- |conjure-client-sql-stdio|
- |conjure-client-rust-evcxr|
- |conjure-client-common-lisp-swank|
Expand Down
44 changes: 4 additions & 40 deletions fnl/conjure/client/snd-s7/stdio.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
;; Based on: fnl/conjure/client/scheme/stdio.fnl
;; fnl/conjure/client/sql/stdio.fnl
;;
;; Uses fnl/conjure/remote/stdio-rt.fnl; not fnl/conjure/remote/stdio.fnl.
;;
;; The `snd` program should be runnable on the command line.
;;
;; NOTE: Conflicts with the Scheme client due to the same filetype suffix.
;; For testing the proof-of-concept, this client replaces the Scheme
;; To use this instead of the default Scheme client, set
;; `g:conjure#filetype#scheme` to `"conjure.client.snd-s7.stdio"`.
;; client in fnl/conjure/config.fnl.
;;
;;------------------------------------------------------------
Expand Down Expand Up @@ -76,47 +79,8 @@
(a.run! display-result msgs))
)
{:batch? false}))))

;;;;-------- End from client/sql/stdio.fnl ------------------

;;;;-------- from client/scheme/stdio.fnl -------------------
; (defn unbatch [msgs]
; {:out (->> msgs
; (a.map #(or (a.get $1 :out) (a.get $1 :err)))
; (str.join ""))})
;
; (defn format-msg [msg]
; (->> (-> msg
; (a.get :out)
; (string.gsub "^%s*" "")
; (string.gsub "%s+%d+%s*$" "")
; (str.split "\n"))
; (a.map
; (fn [line]
; (if
; (not (cfg [:value_prefix_pattern]))
; line
;
; (string.match line (cfg [:value_prefix_pattern]))
; (string.gsub line (cfg [:value_prefix_pattern]) "")
;
; (.. comment-prefix "(out) " line))))
; (a.filter #(not (str.blank? $1)))))
;
;
; (defn eval-str [opts]
; (with-repl-or-warn
; (fn [repl]
; (repl.send
; (.. opts.code "\n")
; (fn [msgs]
; (let [msgs (-> msgs unbatch format-msg)]
; (opts.on-result (a.last msgs))
; (log.append msgs)))
; {:batch? true}))))
;
;;;;-------- End from client/scheme/stdio.fnl ---------------

(defn eval-file [opts]
(eval-str (a.assoc opts :code (.. "(load \"" opts.file-path "\")"))))

Expand Down
3 changes: 1 addition & 2 deletions fnl/conjure/config.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
:hy :conjure.client.hy.stdio
:julia :conjure.client.julia.stdio
:racket :conjure.client.racket.stdio
;;:scheme :conjure.client.scheme.stdio
:scheme :conjure.client.snd-s7.stdio
:scheme :conjure.client.scheme.stdio
:lua :conjure.client.lua.neovim
:lisp :conjure.client.common-lisp.swank
:python :conjure.client.python.stdio
Expand Down
2 changes: 1 addition & 1 deletion lua/conjure/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ local function merge(tbl, opts, ks)
return nil
end
_2amodule_2a["merge"] = merge
merge({relative_file_root = nil, path_subs = nil, client_on_load = true, filetypes = {"clojure", "fennel", "janet", "hy", "julia", "racket", "scheme", "lua", "lisp", "python", "rust", "sql"}, filetype = {clojure = "conjure.client.clojure.nrepl", fennel = "conjure.client.fennel.aniseed", janet = "conjure.client.janet.netrepl", hy = "conjure.client.hy.stdio", julia = "conjure.client.julia.stdio", racket = "conjure.client.racket.stdio", scheme = "conjure.client.snd-s7.stdio", lua = "conjure.client.lua.neovim", lisp = "conjure.client.common-lisp.swank", python = "conjure.client.python.stdio", rust = "conjure.client.rust.evcxr", sql = "conjure.client.sql.stdio"}, filetype_suffixes = {racket = {"rkt"}, scheme = {"scm", "ss"}}, eval = {result_register = "c", inline_results = true, inline = {highlight = "comment", prefix = "=> "}, comment_prefix = nil, gsubs = {}}, mapping = {prefix = "<localleader>", log_split = "ls", log_vsplit = "lv", log_tab = "lt", log_buf = "le", log_toggle = "lg", log_close_visible = "lq", log_reset_soft = "lr", log_reset_hard = "lR", log_jump_to_latest = "ll", eval_current_form = "ee", eval_comment_current_form = "ece", eval_root_form = "er", eval_comment_root_form = "ecr", eval_word = "ew", eval_comment_word = "ecw", eval_replace_form = "e!", eval_marked_form = "em", eval_file = "ef", eval_buf = "eb", eval_visual = "E", eval_motion = "E", def_word = "gd", doc_word = {"K"}, enable_ft_mappings = true}, completion = {omnifunc = "ConjureOmnifunc", fallback = "syntaxcomplete#Complete"}, highlight = {group = "IncSearch", timeout = 500, enabled = false}, log = {hud = {width = 0.42, height = 0.3, enabled = true, passive_close_delay = 0, minimum_lifetime_ms = 20, overlap_padding = 0.1, border = "single", anchor = "NE", ignore_low_priority = false}, jump_to_latest = {cursor_scroll_position = "top", enabled = false}, break_length = 80, trim = {at = 10000, to = 6000}, strip_ansi_escape_sequences_line_limit = 1000, fold = {lines = 10, marker = {start = "~~~%{", ["end"] = "}%~~~"}, enabled = false}, wrap = false, botright = false}, extract = {context_header_lines = 24, form_pairs = {{"(", ")"}, {"{", "}"}, {"[", "]", true}}, tree_sitter = {enabled = true}}, preview = {sample_limit = 0.3}, debug = false})
merge({relative_file_root = nil, path_subs = nil, client_on_load = true, filetypes = {"clojure", "fennel", "janet", "hy", "julia", "racket", "scheme", "lua", "lisp", "python", "rust", "sql"}, filetype = {clojure = "conjure.client.clojure.nrepl", fennel = "conjure.client.fennel.aniseed", janet = "conjure.client.janet.netrepl", hy = "conjure.client.hy.stdio", julia = "conjure.client.julia.stdio", racket = "conjure.client.racket.stdio", scheme = "conjure.client.scheme.stdio", lua = "conjure.client.lua.neovim", lisp = "conjure.client.common-lisp.swank", python = "conjure.client.python.stdio", rust = "conjure.client.rust.evcxr", sql = "conjure.client.sql.stdio"}, filetype_suffixes = {racket = {"rkt"}, scheme = {"scm", "ss"}}, eval = {result_register = "c", inline_results = true, inline = {highlight = "comment", prefix = "=> "}, comment_prefix = nil, gsubs = {}}, mapping = {prefix = "<localleader>", log_split = "ls", log_vsplit = "lv", log_tab = "lt", log_buf = "le", log_toggle = "lg", log_close_visible = "lq", log_reset_soft = "lr", log_reset_hard = "lR", log_jump_to_latest = "ll", eval_current_form = "ee", eval_comment_current_form = "ece", eval_root_form = "er", eval_comment_root_form = "ecr", eval_word = "ew", eval_comment_word = "ecw", eval_replace_form = "e!", eval_marked_form = "em", eval_file = "ef", eval_buf = "eb", eval_visual = "E", eval_motion = "E", def_word = "gd", doc_word = {"K"}, enable_ft_mappings = true}, completion = {omnifunc = "ConjureOmnifunc", fallback = "syntaxcomplete#Complete"}, highlight = {group = "IncSearch", timeout = 500, enabled = false}, log = {hud = {width = 0.42, height = 0.3, enabled = true, passive_close_delay = 0, minimum_lifetime_ms = 20, overlap_padding = 0.1, border = "single", anchor = "NE", ignore_low_priority = false}, jump_to_latest = {cursor_scroll_position = "top", enabled = false}, break_length = 80, trim = {at = 10000, to = 6000}, strip_ansi_escape_sequences_line_limit = 1000, fold = {lines = 10, marker = {start = "~~~%{", ["end"] = "}%~~~"}, enabled = false}, botright = false, wrap = false}, extract = {context_header_lines = 24, form_pairs = {{"(", ")"}, {"{", "}"}, {"[", "]", true}}, tree_sitter = {enabled = true}}, preview = {sample_limit = 0.3}, debug = false})
return _2amodule_2a

0 comments on commit 9392c1a

Please sign in to comment.