Skip to content

Commit 82b8d97

Browse files
committed
feat: add field always_save
1 parent 5025070 commit 82b8d97

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ vim.g.guard_config = {
104104
lint_interval = 500
105105
-- show diagnostic after format done
106106
refresh_diagnostic = true,
107+
-- always save file after call Guard fmt
108+
always_save = false,
107109
}
108110
```
109111

lua/guard/format.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ local function update_buffer(bufnr, prev_lines, new_lines, srow, erow, old_inden
4242
restore_views(views)
4343
end
4444

45-
if util.getopt('save_on_fmt') and need_write then
45+
if util.getopt('always_save') or (util.getopt('save_on_fmt') and need_write) then
4646
api.nvim_command('silent! noautocmd write!')
4747
end
4848
end

lua/guard/util.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ function M.getopt(opt)
193193
auto_lint = true,
194194
lint_interval = 500,
195195
refresh_diagnostic = true,
196+
always_save = false,
196197
}
197198
if
198199
not vim.g.guard_config

0 commit comments

Comments
 (0)