Skip to content

Commit

Permalink
fix: load temp buffer once created to load the context for formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Nov 27, 2023
1 parent fb96be3 commit 3b13b70
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/conform/formatters/injected.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ return {
-- This is using the language name as the file extension, but that is a reasonable
-- approximation for now. We can add special cases as the need arises.
local buf = vim.fn.bufadd(string.format("%s.%s", vim.api.nvim_buf_get_name(ctx.buf), lang))
-- Actually load the buffer to set the buffer context which is required by some formatters such as `filetype`
vim.fn.bufload(buf)
tmp_bufs[buf] = true
local format_opts = { async = true, bufnr = buf, quiet = true }
conform.format_lines(formatter_names, input_lines, format_opts, function(err, new_lines)
Expand Down

0 comments on commit 3b13b70

Please sign in to comment.