diff options
-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 |