dotfiles

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

Commit: e23e7e713ee1a6ec3fc7c1bc1f9df749e470ce77
Parent: 67c2680e09da67522e0baeee331f674f272343ff
Author: Randy Palamar
Date:   Fri, 16 Dec 2022 22:01:44 -0700

vis: fmt files before writing

currently only used for latex bib files

Diffstat:
M.config/vis/build.lua | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/.config/vis/build.lua b/.config/vis/build.lua @@ -1,5 +1,29 @@ require('util') +local function fmt(file, path) + local win = vis.win + local fmt = {} + fmt["bibtex"] = "bibtidy" + + local cmd = fmt[win.syntax] + if cmd == nil then return true end + + local err, ostr, estr = vis:pipe(file, {start = 0, finish = file.size}, cmd) + if err ~= 0 then + if estr then + vis:message(estr) + end + return false + end + + local pos = win.selection.pos + file:delete(0, file.size) + file:insert(0, ostr) + win.selection.pos = pos + return true +end +vis.events.subscribe(vis.events.FILE_SAVE_PRE, fmt) + local function build_files(win) function error() vis:info('This filetype is not supported')