aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/conform/util.lua')
-rw-r--r--lua/conform/util.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/lua/conform/util.lua b/lua/conform/util.lua
index ec6af45..8a0073a 100644
--- a/lua/conform/util.lua
+++ b/lua/conform/util.lua
@@ -156,4 +156,20 @@ M.add_formatter_args = function(formatter, extra_args, opts)
end
end
+---@param bufnr integer
+---@return integer
+M.buf_get_changedtick = function(bufnr)
+ if not vim.api.nvim_buf_is_valid(bufnr) then
+ return -2
+ end
+ local changedtick = vim.b[bufnr].changedtick
+ -- changedtick gets set to -1 when vim is exiting. We have an autocmd that should store it in
+ -- last_changedtick before it is set to -1.
+ if changedtick == -1 then
+ return vim.b[bufnr].last_changedtick or -1
+ else
+ return changedtick
+ end
+end
+
return M