Skip to content

Commit

Permalink
Add right_margin pretty print options #406
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Aug 25, 2023
1 parent e5586b7 commit 5119706
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions doc/conjure-client-clojure-nrepl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ All configuration can be set as described in |conjure-configuration|.
to `false` to disable this limit.
Default: `500`

*g:conjure#client#clojure#nrepl#eval#print_options#right_margin*
`g:conjure#client#clojure#nrepl#eval#print_options#right_margin`
Pretty printing will try to avoid anything going beyond this column.
Default: `72`

*g:conjure#client#clojure#nrepl#interrupt#sample_limit*
`g:conjure#client#clojure#nrepl#interrupt#sample_limit`
How many characters to show of the code you just interrupted as a
Expand Down
4 changes: 3 additions & 1 deletion fnl/conjure/client/clojure/nrepl/init.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
:auto_require true
:print_quota nil
:print_function :conjure.internal/pprint
:print_options {:length 500 :level 50}}
:print_options {:length 500
:level 50
:right_margin 72}}

:interrupt
{:sample_limit 0.3}
Expand Down
18 changes: 14 additions & 4 deletions fnl/conjure/client/clojure/nrepl/server.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,20 @@
;; So it's as if we set the options to [] which is _not_ good.
:associative 1

:level (or (config.get-in [:client :clojure :nrepl :eval :print_options :level])
nil)
:length (or (config.get-in [:client :clojure :nrepl :eval :print_options :length])
nil)}
:level
(or
(config.get-in [:client :clojure :nrepl :eval :print_options :level])
nil)

:length
(or
(config.get-in [:client :clojure :nrepl :eval :print_options :length])
nil)

:right-margin
(or
(config.get-in [:client :clojure :nrepl :eval :print_options :right_margin])
nil)}

:nrepl.middleware.print/quota
(config.get-in [:client :clojure :nrepl :eval :print_quota])
Expand Down
2 changes: 1 addition & 1 deletion lua/conjure/client/clojure/nrepl/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end
_2amodule_2a["symbol-node?"] = symbol_node_3f
local comment_node_3f = ts["lisp-comment-node?"]
_2amodule_2a["comment-node?"] = comment_node_3f
config.merge({client = {clojure = {nrepl = {connection = {default_host = "localhost", port_files = {".nrepl-port", ".shadow-cljs/nrepl.port"}, auto_repl = {enabled = true, cmd = "bb nrepl-server localhost:$port", port_file = ".nrepl-port", hidden = false}}, eval = {pretty_print = true, auto_require = true, print_quota = nil, print_function = "conjure.internal/pprint", print_options = {length = 500, level = 50}, raw_out = false}, interrupt = {sample_limit = 0.3}, refresh = {after = nil, before = nil, dirs = nil}, test = {current_form_names = {"deftest"}, runner = "clojure", call_suffix = nil, raw_out = false}, mapping = {disconnect = "cd", connect_port_file = "cf", interrupt = "ei", last_exception = "ve", result_1 = "v1", result_2 = "v2", result_3 = "v3", view_source = "vs", session_clone = "sc", session_fresh = "sf", session_close = "sq", session_close_all = "sQ", session_list = "sl", session_next = "sn", session_prev = "sp", session_select = "ss", run_all_tests = "ta", run_current_ns_tests = "tn", run_alternate_ns_tests = "tN", run_current_test = "tc", refresh_changed = "rr", refresh_all = "ra", refresh_clear = "rc"}, completion = {cljs = {use_suitable = true}, with_context = false}}}}})
config.merge({client = {clojure = {nrepl = {connection = {default_host = "localhost", port_files = {".nrepl-port", ".shadow-cljs/nrepl.port"}, auto_repl = {enabled = true, cmd = "bb nrepl-server localhost:$port", port_file = ".nrepl-port", hidden = false}}, eval = {pretty_print = true, auto_require = true, print_quota = nil, print_function = "clojure.pprint/pprint", print_options = {length = 500, level = 50, right_margin = 72}, raw_out = false}, interrupt = {sample_limit = 0.3}, refresh = {after = nil, before = nil, dirs = nil}, test = {current_form_names = {"deftest"}, runner = "clojure", call_suffix = nil, raw_out = false}, mapping = {disconnect = "cd", connect_port_file = "cf", interrupt = "ei", last_exception = "ve", result_1 = "v1", result_2 = "v2", result_3 = "v3", view_source = "vs", session_clone = "sc", session_fresh = "sf", session_close = "sq", session_close_all = "sQ", session_list = "sl", session_next = "sn", session_prev = "sp", session_select = "ss", run_all_tests = "ta", run_current_ns_tests = "tn", run_alternate_ns_tests = "tN", run_current_test = "tc", refresh_changed = "rr", refresh_all = "ra", refresh_clear = "rc"}, completion = {cljs = {use_suitable = true}, with_context = false}}}}})
local function context(header)
local _1_ = header
if (nil ~= _1_) then
Expand Down
2 changes: 1 addition & 1 deletion lua/conjure/client/clojure/nrepl/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ local function eval(opts, cb)
else
_14_ = nil
end
return send({op = "eval", ns = opts.context, code = un_comment(opts.code), file = opts["file-path"], line = a["get-in"](opts, {"range", "start", 1}), column = _12_, session = opts.session, ["nrepl.middleware.print/options"] = {associative = 1, level = (config["get-in"]({"client", "clojure", "nrepl", "eval", "print_options", "level"}) or nil), length = (config["get-in"]({"client", "clojure", "nrepl", "eval", "print_options", "length"}) or nil)}, ["nrepl.middleware.print/quota"] = config["get-in"]({"client", "clojure", "nrepl", "eval", "print_quota"}), ["nrepl.middleware.print/buffer-size"] = config["get-in"]({"client", "clojure", "nrepl", "eval", "print_buffer_size"}), ["nrepl.middleware.print/print"] = _14_}, cb)
return send({op = "eval", ns = opts.context, code = un_comment(opts.code), file = opts["file-path"], line = a["get-in"](opts, {"range", "start", 1}), column = _12_, session = opts.session, ["nrepl.middleware.print/options"] = {associative = 1, level = (config["get-in"]({"client", "clojure", "nrepl", "eval", "print_options", "level"}) or nil), length = (config["get-in"]({"client", "clojure", "nrepl", "eval", "print_options", "length"}) or nil), ["right-margin"] = (config["get-in"]({"client", "clojure", "nrepl", "eval", "print_options", "right_margin"}) or nil)}, ["nrepl.middleware.print/quota"] = config["get-in"]({"client", "clojure", "nrepl", "eval", "print_quota"}), ["nrepl.middleware.print/buffer-size"] = config["get-in"]({"client", "clojure", "nrepl", "eval", "print_buffer_size"}), ["nrepl.middleware.print/print"] = _14_}, cb)
end
return with_conn_or_warn(_10_)
end
Expand Down

0 comments on commit 5119706

Please sign in to comment.