diff options
author | Steven Arcangeli <stevearc@stevearc.com> | 2023-09-29 12:04:30 -0700 |
---|---|---|
committer | Steven Arcangeli <stevearc@stevearc.com> | 2023-09-29 12:23:26 -0700 |
commit | 0c52ee248245f40610a4957b6bc9515ce1fd9ab6 (patch) | |
tree | 451e753d11427e91aaf995609eda6653ce9ef10a /lua/conform/util.lua | |
parent | c5280d586e50ad6193b42df27e494b74a9efc5b7 (diff) |
fix: format_after_save blocks on exit for lsp formatting
Diffstat (limited to 'lua/conform/util.lua')
-rw-r--r-- | lua/conform/util.lua | 16 |
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 |