aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2021-06-06 21:05:07 +0200
committerMatěj Cepl <mcepl@cepl.eu>2021-06-06 21:05:07 +0200
commit7080a540246de28f214165d4a6ec13e74573a364 (patch)
treecf9cad8937ff16ff6b84177bacce6bcf71ab03b5
parentc88ab421ae0e3b6bab1a3623e5a1a7baa4a29334 (diff)
downloadvis-par-7080a540246de28f214165d4a6ec13e74573a364.tar.gz
Some intelligence to par handling.0.1.0
Hard dependency on par.
-rw-r--r--init.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/init.lua b/init.lua
index e7b57ef..f4653a5 100644
--- a/init.lua
+++ b/init.lua
@@ -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