vis: Guardar sin formatear

This commit is contained in:
Cat /dev/Nulo 2022-03-20 12:37:33 -03:00
parent 693415e3a9
commit 8dfabb5952

View file

@ -9,12 +9,19 @@ plugins = {
["cursors"] = require 'plugins/cursors', ["cursors"] = require 'plugins/cursors',
} }
local disable_formating = false
vis.events.subscribe(vis.events.INIT, function() vis.events.subscribe(vis.events.INIT, function()
require 'themes/minimal-light' require 'themes/minimal-light'
require 'plugins/commentary' require 'plugins/commentary'
vis:map(vis.modes.NORMAL, ',f', ':fzf<Enter>') vis:map(vis.modes.NORMAL, ',f', ':fzf<Enter>')
vis:map(vis.modes.NORMAL, ',b', ':fzfmru<Enter>') vis:map(vis.modes.NORMAL, ',b', ':fzfmru<Enter>')
vis:command_register('W', function(argv)
disable_formating = true
vis:command('w')
disable_formating = false
return true
end, "Write file without formatting")
end) end)
vis.events.subscribe(vis.events.WIN_OPEN, function(win) vis.events.subscribe(vis.events.WIN_OPEN, function(win)
@ -24,11 +31,16 @@ end)
local function format(file, path) local function format(file, path)
local win = vis.win local win = vis.win
local fmt = nil 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 fmt = "prettier --stdin-filepath "..file.path
end end
if fmt == nil then if fmt == nil or disable_formating then
return true return true
end end