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
I have set log_level = vim.log.levels.DEBUG and pasted the log contents below.
Log file
23:48:42[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:42[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:42[DEBUG] Injected format html:30:32: { "djlint" }
23:48:42[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.1.html
23:48:42[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:42[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:42[DEBUG] Injected format html:14:18: { "djlint" }
23:48:42[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:42[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:42[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:42[DEBUG] Injected format html:8:10: { "djlint" }
23:48:42[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.3.html
23:48:42[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:42[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:42[DEBUG] djlint exited with code 0
23:48:42[DEBUG] djlint exited with code 0
23:48:42[DEBUG] djlint exited with code 0
23:48:43[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:43[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:43[DEBUG] Injected format html:8:19: { "djlint" }
23:48:43[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:43[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:43[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:44[DEBUG] djlint exited with code 0
23:48:45[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:45[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:45[DEBUG] Injected format html:8:21: { "djlint" }
23:48:45[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:45[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:45[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:45[DEBUG] djlint exited with code 0
23:48:46[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:46[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:46[DEBUG] Injected format html:8:22: { "djlint" }
23:48:46[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:46[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:46[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:47[DEBUG] djlint exited with code 0
23:48:48[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:48[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
Describe the bug
It looks like from injected(with tree-sitter) point of view in markdown both code blocks and html tags are "injected languages". As result injected tries to call html formatter on html tags inside markdown (not inside code block!). And this leads to really bad results: all available html formatters fail to handle this (in different ways), and only work around is to completely disable injected html formatter.
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
Install any supported html formatter ('djlint' or 'prettierd' or 'htmlbeautifier'). They all have issues in this use case, just a different ones, so you can try any of them (just update repro.lua accordingly).
Download example README.md file (attached below) to a directory containing repro.lua.
nvim -u repro.lua README.md
:lua require('conform').format() (repeat few times, result of repeating depends on chosen formatter).
README.md will became incorrectly formatted (in different ways, depending on chosen formatter).
prettierd will produce extra closing tags and thus break formatting.
djlint and htmlbeautifier won't produce final result on first run, it'll take about 4-5 times to apply formatting until they'll get final version - also with broken formatting, but in another way.
Expected Behavior
HTML tags inside markdown file shouldn't be processed by 'injected' when using plugin 'tree-sitter' with installed 'markdown' and 'html' languages.
Neovim version (nvim -v)
v0.10.0
Operating system/version
Gentoo Linux
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
23:48:42[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:42[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:42[DEBUG] Injected format html:30:32: { "djlint" }
23:48:42[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.1.html
23:48:42[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:42[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:42[DEBUG] Injected format html:14:18: { "djlint" }
23:48:42[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:42[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:42[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:42[DEBUG] Injected format html:8:10: { "djlint" }
23:48:42[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.3.html
23:48:42[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:42[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:42[DEBUG] djlint exited with code 0
23:48:42[DEBUG] djlint exited with code 0
23:48:42[DEBUG] djlint exited with code 0
23:48:43[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:43[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:43[DEBUG] Injected format html:8:19: { "djlint" }
23:48:43[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:43[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:43[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:44[DEBUG] djlint exited with code 0
23:48:45[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:45[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:45[DEBUG] Injected format html:8:21: { "djlint" }
23:48:45[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:45[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:45[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:45[DEBUG] djlint exited with code 0
23:48:46[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:46[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
23:48:46[DEBUG] Injected format html:8:22: { "djlint" }
23:48:46[INFO] Run djlint on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md.2.html
23:48:46[DEBUG] Run command: { "djlint", "--reformat", "--indent", 4, "-" }
23:48:46[DEBUG] Run default CWD: /home/powerman/tmp/bug-nvim-conform-injected-html
23:48:47[DEBUG] djlint exited with code 0
23:48:48[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md: { "injected" }
23:48:48[INFO] Run injected on /home/powerman/tmp/bug-nvim-conform-injected-html/README.md
Describe the bug
It looks like from
injected
(with tree-sitter) point of view in markdown both code blocks and html tags are "injected languages". As resultinjected
tries to callhtml
formatter on html tags inside markdown (not inside code block!). And this leads to really bad results: all available html formatters fail to handle this (in different ways), and only work around is to completely disable injected html formatter.What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
repro.lua
accordingly).README.md
file (attached below) to a directory containingrepro.lua
.nvim -u repro.lua README.md
:lua require('conform').format()
(repeat few times, result of repeating depends on chosen formatter).prettierd
will produce extra closing tags and thus break formatting.djlint
andhtmlbeautifier
won't produce final result on first run, it'll take about 4-5 times to apply formatting until they'll get final version - also with broken formatting, but in another way.Expected Behavior
HTML tags inside markdown file shouldn't be processed by 'injected' when using plugin 'tree-sitter' with installed 'markdown' and 'html' languages.
Minimal example file
README.md
Minimal init.lua
Additional context
No response
The text was updated successfully, but these errors were encountered: