From 8dfabb595209490eb1432fe5be0c8be7df596870 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sun, 20 Mar 2022 12:37:33 -0300 Subject: [PATCH] vis: Guardar sin formatear --- .config/vis/visrc.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua index e8701fa..9dd3bfa 100644 --- a/.config/vis/visrc.lua +++ b/.config/vis/visrc.lua @@ -9,12 +9,19 @@ plugins = { ["cursors"] = require 'plugins/cursors', } +local disable_formating = false vis.events.subscribe(vis.events.INIT, function() require 'themes/minimal-light' require 'plugins/commentary' vis:map(vis.modes.NORMAL, ',f', ':fzf') vis:map(vis.modes.NORMAL, ',b', ':fzfmru') + vis:command_register('W', function(argv) + disable_formating = true + vis:command('w') + disable_formating = false + return true + end, "Write file without formatting") end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) @@ -24,11 +31,16 @@ end) local function format(file, path) local win = vis.win local fmt = nil - if win.syntax == "javascript" or win.syntax == "typescript" or win.syntax == "json" or win.syntax == "css" then + if + win.syntax == "javascript" + or win.syntax == "typescript" + or win.syntax == "json" + or win.syntax == "css" + then fmt = "prettier --stdin-filepath "..file.path end - if fmt == nil then + if fmt == nil or disable_formating then return true end