aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform/util.lua
diff options
context:
space:
mode:
authorSteven Arcangeli <506791+stevearc@users.noreply.github.com>2023-08-31 08:54:11 -0700
committerGitHub <noreply@github.com>2023-08-31 08:54:11 -0700
commit3f34f2de48e393b2ee289f2c8fa613c7eabae6d8 (patch)
treee4f6e725d345cdbd07cd3f39f69ee7243592378e /lua/conform/util.lua
parent860bd36663b9b02b42a80c6b7f19642add0551ab (diff)
feat: format() takes an optional callback (#21)
* refactor: replicate lsp.buf.format call * feat: format() takes an optional callback * fix: improper logging * fix: callback returns error if buffer is no longer valid * fix: provide more detailed error message to callback * fix: properly detect task interruption * cleanup: remove unnecessary error code translation * fix: lsp formatting for Neovim 0.9 * doc: add example of async formatting on save * fix: async LSP formatter discards changes if buffer was modified * fix: error code comparison * fix: use the same LSP client filtering logic everywhere * fix: add buffer validity guard checks * fix: add buffer validity guard to LSP formatter * refactor: change the default log level to WARN
Diffstat (limited to 'lua/conform/util.lua')
-rw-r--r--lua/conform/util.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/lua/conform/util.lua b/lua/conform/util.lua
index a408675..ea13e2d 100644
--- a/lua/conform/util.lua
+++ b/lua/conform/util.lua
@@ -61,9 +61,10 @@ M.tbl_slice = function(tbl, start_idx, end_idx)
return ret
end
----@param cb fun(...)
----@param wrapper fun(...)
----@return fun(...)
+---@generic T : fun()
+---@param cb T
+---@param wrapper T
+---@return T
M.wrap_callback = function(cb, wrapper)
return function(...)
wrapper(...)