Neovim version (nvim -v)
NVIM v0.10.2
Operating system/version
NixOS unstable-d70bd19e0a38ad4790d3913bf08fcbfc9eeca507
Read debugging tips
Add the debug logs
Log file
2024-12-25 01:49:03[DEBUG] Running formatters on /home/aitvann/playground/conform/example.md: { "injected" }
2024-12-25 01:49:03[INFO] Run injected on /home/aitvann/playground/conform/example.md
2024-12-25 01:49:03[DEBUG] Injected format rust:10:11: { "rustfmt" }
2024-12-25 01:49:04[INFO] Run rustfmt on /home/aitvann/playground/conform/example.md.1.rs
2024-12-25 01:49:04[DEBUG] Run command: { "/nix/store/qpma970g7a0a36qdqrp6aqagynkriygd-rust-default-1.83.0/bin/rustfmt", "--emit=stdout", "--edition=2021" }
2024-12-25 01:49:04[DEBUG] Run default CWD: /home/aitvann/playground/conform
2024-12-25 01:49:04[DEBUG] Injected format rust:8:9: { "rustfmt" }
2024-12-25 01:49:04[INFO] Run rustfmt on /home/aitvann/playground/conform/example.md.3.rs
2024-12-25 01:49:04[DEBUG] Run command: { "/nix/store/qpma970g7a0a36qdqrp6aqagynkriygd-rust-default-1.83.0/bin/rustfmt", "--emit=stdout", "--edition=2021" }
2024-12-25 01:49:04[DEBUG] Run default CWD: /home/aitvann/playground/conform
2024-12-25 01:49:04[DEBUG] Injected format rust:5:7: { "rustfmt" }
2024-12-25 01:49:04[INFO] Run rustfmt on /home/aitvann/playground/conform/example.md.5.rs
2024-12-25 01:49:04[DEBUG] Run command: { "/nix/store/qpma970g7a0a36qdqrp6aqagynkriygd-rust-default-1.83.0/bin/rustfmt", "--emit=stdout", "--edition=2021" }
2024-12-25 01:49:04[DEBUG] Run default CWD: /home/aitvann/playground/conform
2024-12-25 01:49:04[INFO] rustfmt exited with code 1
2024-12-25 01:49:04[DEBUG] rustfmt stdout: { "" }
2024-12-25 01:49:04[DEBUG] rustfmt stderr: { "error: unexpected closing delimiter: `}`", " --> <stdin>:1:1", " |", "1 | }", " | ^ unexpected closing delimiter", "", "" }
2024-12-25 01:49:04[ERROR] Formatter 'rustfmt' error: error: unexpected closing delimiter: `}`
--> <stdin>:1:1
|
1 | }
| ^ unexpected closing delimiter
2024-12-25 01:49:04[INFO] rustfmt exited with code 1
2024-12-25 01:49:04[DEBUG] rustfmt stdout: { "" }
2024-12-25 01:49:04[DEBUG] rustfmt stderr: { "error: expected item, found keyword `let`", " --> <stdin>:1:1", " |", "1 | let a = a;", " | ^^^ consider using `const` or `static` instead of `let` for global variables", "", "" }
2024-12-25 01:49:04[ERROR] Formatter 'rustfmt' error: error: expected item, found keyword `let`
--> <stdin>:1:1
|
1 | let a = a;
| ^^^ consider using `const` or `static` instead of `let` for global variables
2024-12-25 01:49:04[DEBUG] rustfmt exited with code 0
2024-12-25 01:49:04[ERROR] error formatting log line: '{
code = 6,
message = "Formatter 'rustfmt' error: error: unexpected closing delimiter: `}`\n --> <stdin>:1:1\n |\n1 | }\n | ^ unexpected closing delimiter\n\n"
}' args {
n = 0
}
Describe the bug
formatting works as expected when code block does not have indentation.:
1. first line
``` rust
// hi
fn foo(a: u8) {
let a = a;
let b = a ;
}
\```
but if I indent the code block to be the part of a list like this:
1. first line
``` rust
// hi
fn foo(a: u8) {
let a = a;
let b = a ;
}
\ ```
it breaks half way through (notice a blank line disappeared but ; stayed at the same place:
1. first line
``` rust
// hi
fn foo(a: u8) {
let a = a;
let b = a ;
}
\```
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
example Markdown file:
1. first line
``` rust
// hi
fn foo(a: u8) {
let a = a;
let b = a ;
}
\ ```
Expected Behavior
the expected Markdown file:
1. first line
``` rust
// hi
fn foo(a: u8) {
let a = a;
let b = a;
}
\```
Minimal example file
1. first line
``` rust
// hi
fn foo(a: u8) {
let a = a;
let b = a ;
}
\ ```
Minimal init.lua
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
{
"stevearc/conform.nvim",
config = function()
require("conform").setup({
log_level = vim.log.levels.DEBUG,
-- add your config here
})
end,
},
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
require('conform').setup({
formatters_by_ft = {
sql = { "injected", lsp_format = "last" },
rust = { "injected", lsp_format = "last" },
markdown = { "injected", lsp_format = "last" },
},
formatters = {
injected = {
options = {
ignore_errors = false,
lang_to_formatters = {
sql = { "sqlfluff" },
rust = { "rustfmt" },
},
},
}
}
})
Additional context
No response
Neovim version (nvim -v)
NVIM v0.10.2
Operating system/version
NixOS unstable-d70bd19e0a38ad4790d3913bf08fcbfc9eeca507
Read debugging tips
Add the debug logs
log_level = vim.log.levels.DEBUGand pasted the log contents below.Log file
Describe the bug
formatting works as expected when code block does not have indentation.:
but if I indent the code block to be the part of a list like this:
it breaks half way through (notice a blank line disappeared but
;stayed at the same place:What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
example Markdown file:
Expected Behavior
the expected Markdown file:
Minimal example file
Minimal init.lua
Additional context
No response