vis: Guardar sin formatear
This commit is contained in:
parent
693415e3a9
commit
8dfabb5952
1 changed files with 14 additions and 2 deletions
|
@ -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<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)
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue