dotfiles

personal dotfiles
git clone anongit@rnpnr.xyz:dotfiles.git
Log | Files | Refs | Feed | Submodules

Commit: 4d98a0151fc05fa78240d3c7f0639d4d9f717537
Parent: 238634e80666700a6f0c9cc27815c325e9375e06
Author: Randy Palamar
Date:   Tue,  2 Apr 2024 09:39:15 -0600

vis: update latex macros and builder

Diffstat:
M.config/vis/build.lua | 22++++++++++++++++++----
M.config/vis/macros.lua | 15++++++++-------
2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/.config/vis/build.lua b/.config/vis/build.lua @@ -17,7 +17,7 @@ vis.events.subscribe(vis.events.FILE_SAVE_PRE, fmt_file) local function build_files(win) local build_tex = function (f) - local cmd = "pdflatex -halt-on-error -shell-escape " + local cmd = "xelatex -halt-on-error -shell-escape " -- build in draft mode to update references local err, ostr = vis:pipe(cmd .. "-draftmode " .. f.name) @@ -39,10 +39,21 @@ local function build_files(win) err = vis:pipe(cmd .. f.name) if err ~= 0 then return false end + -- check for FIXMEs + local pos = win.selection.pos + local info + vis:command("x/FIXME/") + -- pathological case: if cursor is on the end of a FIXME + if #win.selections and pos ~= win.selection.pos then + info = "FIXMEs: " .. tostring(#win.selections) + end + vis:feedkeys("<Escape><Escape>") + win.selection.pos = pos + -- reload pdf (zathura does this automatically) -- vis:command('!pkill -HUP mupdf') - return true + return true, info end local lang = {} @@ -58,8 +69,11 @@ local function build_files(win) win:map(vis.modes.NORMAL, " c", function () vis:command('w') - vis:info("building: " .. win.file.name) - return builder(win.file) + local s = "built: " .. win.file.name + local ret, info = builder(win.file) + if info then s = s .. " | info: " .. info end + if ret == true then vis:info(s) end + return ret end, "build file in current window") end vis.events.subscribe(vis.events.WIN_OPEN, build_files) diff --git a/.config/vis/macros.lua b/.config/vis/macros.lua @@ -12,12 +12,13 @@ local function ins(str) end -- surround selection -local function sur(p, s) +local function sur(pre, suf, trim) return function () local win = vis.win + if trim then vis:feedkeys("_") end for sel in win:selections_iterator() do - win.file:insert(sel.range.start, p) - win.file:insert(sel.range.finish, s) + win.file:insert(sel.range.start, pre) + win.file:insert(sel.range.finish, suf) end win:draw() return true @@ -42,17 +43,17 @@ local function macros(win) { m.NORMAL, "\\cb", fc({ lenv("center", "\\colorboxed{blue}{\n}"), fk("kO") }) }, { m.NORMAL, "\\en", fc({ lenv("enumerate","\n\\item \n"), fk("kkA") }) }, { m.NORMAL, "\\eq", fc({ lenv("equation*"), fk("O") }) }, - { m.NORMAL, "\\fi", fc({ lenv("figure", "\\includegraphics[width=\\textwidth]{}"), fk("k$hi") }) }, + { m.NORMAL, "\\fi", fc({ lenv("figure", "\t\\includegraphics[width=\\textwidth]{}"), fk("k$hi") }) }, { m.NORMAL, "\\it", fc({ lenv("itemize", "\n\\item \n"), fk("kkA") }) }, { m.NORMAL, "\\mi", fc({ ins("\\begin{minipage}[c]{0.49\\textwidth}\n\\end{minipage}\\hfill"), fk("O") }) }, { m.NORMAL, "\\ne", fc({ lenv("equation"), fk("O") }) }, { m.NORMAL, "\\se", fc({ ins("\\section{}"), fk("hi") }) }, { m.NORMAL, "\\su", fc({ ins("\\subsection{}"), fk("hi") }) }, - { m.VISUAL, "\\bf", sur("\\textbf{", "}") }, + { m.VISUAL, "\\bf", sur("\\textbf{", "}", true) }, { m.VISUAL, "\\cb", sur("\\colorboxed{blue}{\n", "}\n") }, { m.VISUAL, "\\ce", sur("\\begin{center}\n", "\\end{center}\n") }, - { m.VISUAL, "\\em", sur("\\emph{", "}") }, - { m.VISUAL, "\\hl", sur("\\hl{", "}") }, + { m.VISUAL, "\\em", sur("\\emph{", "}", true) }, + { m.VISUAL, "\\hl", sur("\\hl{", "}", true) }, { m.VISUAL, "\\mi", sur("\\begin{minipage}[c]{0.49\\textwidth}\n", "\\end{minipage}\\hfill\n") }, } lang["haskell"] = {