dotfiles

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

Commit: 09dbe9495e5fc87f760db3385e7b88b0931d3955
Parent: 8467baa6c507cbed9689e8384cd67386670a9f79
Author: Randy Palamar
Date:   Wed, 26 Jul 2023 07:10:39 -0600

vis: build.lua: use fix from vis-lint for formatting

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

diff --git a/.config/vis/build.lua b/.config/vis/build.lua @@ -1,26 +1,16 @@ local util = require('util') local function fmt_file(file) - local win = vis.win - local fmt = {} - fmt["ansi_c"] = "clang-format -fallback-style=none" - fmt["cpp"] = "clang-format -fallback-style=none" - fmt["bibtex"] = "bibtidy" - - local cmd = fmt[win.syntax] - if cmd == nil then return 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 + local M = require('plugins/vis-lint') + M.logger = function(str, level) + if level == M.log.ERROR then + vis:message(str) + end end - - local pos = win.selection.pos - file:delete(0, file.size) - file:insert(0, ostr) - win.selection.pos = pos - return true + M.fixers["ansi_c"] = { "clang-format -fallback-style=none" } + M.fixers["cpp"] = { "clang-format -fallback-style=none" } + M.fixers["bibtex"] = { "bibtidy" } + return M.fix(file) end vis.events.subscribe(vis.events.FILE_SAVE_PRE, fmt_file)