aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2022-07-05 09:28:51 +0200
committerMatěj Cepl <mcepl@cepl.eu>2022-07-05 09:46:50 +0200
commit773ecabacabd26b611a200f6bf3058eb90e658d0 (patch)
tree2e3e1f53d66f2a8811887ab0de2ccb30ddbc8a5f
parent6caeb15c66e61b3d4c26b09e67ff2a50cddc2ab5 (diff)
downloadvis-par-773ecabacabd26b611a200f6bf3058eb90e658d0.tar.gz
Make whole plugin configurable and export object.
-rw-r--r--init.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/init.lua b/init.lua
index 4f23eac..793a9d3 100644
--- a/init.lua
+++ b/init.lua
@@ -1,11 +1,13 @@
require("vis")
-par_prg = "par"
-par_tw = 65
-ex_args = "RET4bhgqw" .. par_tw
+
+local M = {}
+
+M.par_prg = "par"
+M.par_tw = 72
+M.ex_args = function () return "RET4bhgqw" .. M.par_tw end
-- ex_args = "RET4bhgqB=.,?_A_aQ=_s>|w" .. par_tw
-- export PARINIT='Tbp2hgqR B=.,?_A_a Q=_s>|'
-
function print(...)
_print_ = _print_ or io.open("/tmp/visprint", "w")
_print_:write(..., "\n")
@@ -126,7 +128,7 @@ end
function new_segment(segment, p_arg)
if next(segment) then
- local new_text = run_shell_cmd(par_prg, ex_args .. p_arg,
+ local new_text = run_shell_cmd(M.par_prg, M.ex_args() .. p_arg,
table.concat(segment, "\n"))
print("new_text = " .. new_text)
return new_text, {}, 0 -- add-to-out, segment, p_arg
@@ -166,7 +168,7 @@ vis:operator_new(
-- continuous line in a segment, just collect it
table.insert(segment, line)
end
- else -- this is an empty line, so do whole circus FIXME
+ else -- this is an empty line
seg_pared, segment, p_arg = new_segment(segment, p_arg)
if seg_pared then
out = out .. seg_pared
@@ -198,3 +200,5 @@ vis:option_register(
end,
"Automatically format current paragraph."
)
+
+return M