Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: format() takes an optional callback #21

Merged
merged 15 commits into from
Aug 31, 2023
Merged

Conversation

stevearc
Copy link
Owner

@stevearc stevearc commented Aug 31, 2023

closes #19

Enables async format-on-save workflow that re-saves the buffer after formatting completes.

vim.api.nvim_create_autocmd("BufWritePost", {
  pattern = "*",
  callback = function(args)
    require("conform").format({ async = true, lsp_fallback = true, buf = args.buf }, function(err)
      if not err then
        vim.api.nvim_buf_call(args.buf, function()
          vim.cmd.update()
        end)
      end
    end)
  end,
})

@stevearc stevearc merged commit 3f34f2d into master Aug 31, 2023
14 checks passed
@stevearc stevearc deleted the stevearc-callback branch August 31, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: async format after buffer changes only fires after saving twice
1 participant