diff options
Diffstat (limited to 'lua/conform/formatters')
-rw-r--r-- | lua/conform/formatters/injected.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lua/conform/formatters/injected.lua b/lua/conform/formatters/injected.lua index 363889e..fd67439 100644 --- a/lua/conform/formatters/injected.lua +++ b/lua/conform/formatters/injected.lua @@ -127,7 +127,10 @@ return { local errors = require("conform.errors") local log = require("conform.log") local util = require("conform.util") - local text = table.concat(lines, "\n") + -- Need to add a trailing newline; some parsers need this. + -- For example, if a markdown code block ends at the end of the file, a trailing newline is + -- required otherwise the ``` will be grabbed as part of the injected block + local text = table.concat(lines, "\n") .. "\n" local buf_lang = vim.treesitter.language.get_lang(vim.bo[ctx.buf].filetype) local ok, parser = pcall(vim.treesitter.get_string_parser, text, buf_lang) if not ok then |