diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2021-06-06 21:05:07 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2021-06-06 21:05:07 +0200 |
commit | 7080a540246de28f214165d4a6ec13e74573a364 (patch) | |
tree | cf9cad8937ff16ff6b84177bacce6bcf71ab03b5 | |
parent | c88ab421ae0e3b6bab1a3623e5a1a7baa4a29334 (diff) | |
download | vis-par-7080a540246de28f214165d4a6ec13e74573a364.tar.gz |
Some intelligence to par handling.0.1.0
Hard dependency on par.
-rw-r--r-- | init.lua | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,10 +1,20 @@ require('vis') -par_prg = "fmt -c -w 65" +par_prg = "par" vis:operator_new("gq", function(file, range, pos) - vis:info("par_prg = " .. par_prg) - local status, out, err = vis:pipe(file, range, par_prg) - -- local status, out, err = vis:pipe(file, range, "par -w 65") + local cur_line = file.lines[vis.win.selection.line] + local beg, fin = string.find(cur_line, "^%s+") + local exec = par_prg .. " ET4w65" + if beg ~= nil then + local ind = fin + if string.find(cur_line, "[-+*]", fin) then + exec = exec .. "h" + ind = ind + 2 + end + exec = exec .. "p" .. ind + vis:info("beg = " .. beg .. ", fin = " .. fin .. ", exec = " .. exec) + end + local status, out, err = vis:pipe(file, range, exec) if not status then vis:info(err) else |