You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the best use cases of the injected formatter is for use with Markdown and markup languages that embed code blocks or intertwine different languages together.
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
save the repro.lua and test.md into a folder
nvim -u repro.lua test.md, start up the minimal reproduction environment and open the minimal example file. Wait for plugins to install and treesitter to install the html and markdown parsers
run :InspectTree and see that there is html_block as well as a separate section recognized as markdown
:lua require("conform").format(), run the formatter and see that the white space is clobbered surrounding the HTML code block which breaks the markdown parsing
:InspectTree, Inspect the tree post processing and see that now the entire block without whitespace is considered the html_block because white space is removed.
In larger example files, like if there was a paragraph below the header, continuing to run require("conform").format() will continuously clobber the file since the treesitter parser now considers this new block as "HTML"
Expected Behavior
Injected formatter shouldn't destroy the file and should preserve the white space around the content since white space in a mixed language document is typically very important.
Minimal example file
Hello World
Test
Minimal init.lua
-- DO NOT change the paths and don't remove the colorschemelocalroot=vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .reprofor_, nameinipairs { "config", "data", "state", "cache" } dovim.env[("XDG_%s_HOME"):format(name:upper())] =root.."/" ..nameend-- bootstrap lazylocallazypath=root.."/plugins/lazy.nvim"ifnotvim.loop.fs_stat(lazypath) thenvim.fn.system {
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
}
endvim.opt.runtimepath:prepend(lazypath)
-- install pluginslocalplugins= {
"folke/tokyonight.nvim",
{
"stevearc/conform.nvim",
config=function()
require("conform").setup {
log_level=vim.log.levels.TRACE,
-- add your config hereformatters_by_ft= {
["*"] = { "injected" },
html= { "prettier" },
markdown= { "prettier" },
},
}
end,
},
-- add any other plugins here
{
"nvim-treesitter/nvim-treesitter",
config=function()
require("nvim-treesitter.configs").setup {
ensure_installed= { "markdown", "html" },
}
end,
},
}
require("lazy").setup(plugins, {
root=root.."/plugins",
})
vim.cmd.colorscheme"tokyonight"-- add anything else here
Additional context
No response
The text was updated successfully, but these errors were encountered:
Neovim version (nvim -v)
NVIM v0.9.5
Operating system/version
Arch Linux
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
Describe the bug
One of the best use cases of the injected formatter is for use with Markdown and markup languages that embed code blocks or intertwine different languages together.
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
repro.lua
andtest.md
into a foldernvim -u repro.lua test.md
, start up the minimal reproduction environment and open the minimal example file. Wait for plugins to install and treesitter to install thehtml
andmarkdown
parsers:InspectTree
and see that there ishtml_block
as well as a separate section recognized as markdown:lua require("conform").format()
, run the formatter and see that the white space is clobbered surrounding the HTML code block which breaks the markdown parsing:InspectTree
, Inspect the tree post processing and see that now the entire block without whitespace is considered thehtml_block
because white space is removed.In larger example files, like if there was a paragraph below the header, continuing to run
require("conform").format()
will continuously clobber the file since the treesitter parser now considers this new block as "HTML"Expected Behavior
Injected formatter shouldn't destroy the file and should preserve the white space around the content since white space in a mixed language document is typically very important.
Minimal example file
Hello World
Test
Minimal init.lua
Additional context
No response
The text was updated successfully, but these errors were encountered: