alfredodeza / jacinto.vim

Format and validate JSON files
29 stars 5 forks source link

Plugin operates on saved file, not on buffer #1

Open datagrok opened 12 years ago

datagrok commented 12 years ago

If I don't :w my changes before I call the plugin, it will silently overwrite my buffer and lose recent changes.

You mentioned you might add an option to make it auto-save the buffer before it does its work.

I'd prefer that the plugin just validate the current buffer without even having a saved file or a filename, but you said that's difficult/impossible. Maybe we can investigate workarounds later. The solution you mentioned above would be sufficient.

alfredodeza commented 12 years ago

You present a valid point. We talked about this briefly but would a plugin option to save the buffer before validation/formatting be acceptable? I am thinking something like this on your .vimrc:

let g:jacinto_auto_save = 1

This of course, would only happen just when the plugin is called and before any formatting/validation is attempted. If this is an acceptable compromise I should be able to have the fix in no time.

datagrok commented 12 years ago

Yes, that would be great!

Something that might be slightly better, if it is possible and not too much work, is to employ the current value of the 'autowrite' global boolean. If it is set, it auto-saves, if not it does not auto-reload the buffer after changing the file. Or something like that.