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
01:21:50[DEBUG] Running formatters on /tmp/repro/repro.js: { "injected" }
01:21:50[INFO] Run injected on /tmp/repro/repro.js
01:21:50[DEBUG] Injected format glsl:5:10: { "tee" }
01:21:50[INFO] Run tee on /tmp/repro/repro.js.glsl
01:21:50[DEBUG] Run command: { "tee", "/tmp/repro/.repro//intercepted.glsl" }
01:21:50[DEBUG] tee exited with code 0
Describe the bug
When running formatters on injected code blocks within JavaScript/TypeScript, code from outside of the block is sent to the formatter.
To demonstrate this, in the minimal init.lua below, I've set up conform to use the injected formatter for JS files. I plan to demonstrate this with glsl injected code blocks, so for the glsl filetype, I've set up a simple formatter that uses the tee command to log stdin to a file and print stdin to stdout. By looking at the file written by tee, we can see exactly what text was sent to the formatter.
Steps To Reproduce
nvim -u repro.lua
make sure to restart neovim after the initial lazy install so that treesitter loads correctly
nvim -u repro.lua repro.js
:write to trigger format on save
take a look at .repro/intercepted.glsl to see what was sent to the formatter, it will look like this:
constvert=glsl`
voidmain(){vec4 position =vec4(0.0,0.0,0.0,1.0);position=position*projectionMatrix;gl_Position=position;}
As you can see, the entire line where the start of the injected region occurs is sent to the formatter, including code that's not intended to be part of the injected region.
Expected Behavior
I would expect intercepted.glsl to look like this:
void main() {
vec4 position =vec4(0.0, 0.0, 0.0, 1.0);
position = position * projectionMatrix;
gl_Position= position;
}
Minimal example file
// This is a testconstfoo="bar";constvert=glsl` void main() { vec4 position = vec4(0.0, 0.0, 0.0, 1.0); position = position * projectionMatrix; gl_Position = position; }`;consthello="world";
Neovim version (nvim -v)
v0.10.0-dev-1711+g65de1a22c4
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
When running formatters on injected code blocks within JavaScript/TypeScript, code from outside of the block is sent to the formatter.
To demonstrate this, in the minimal
init.lua
below, I've set up conform to use theinjected
formatter for JS files. I plan to demonstrate this withglsl
injected code blocks, so for theglsl
filetype, I've set up a simple formatter that uses thetee
command to log stdin to a file and print stdin to stdout. By looking at the file written bytee
, we can see exactly what text was sent to the formatter.Steps To Reproduce
nvim -u repro.lua
nvim -u repro.lua repro.js
:write
to trigger format on save.repro/intercepted.glsl
to see what was sent to the formatter, it will look like this:As you can see, the entire line where the start of the injected region occurs is sent to the formatter, including code that's not intended to be part of the injected region.
Expected Behavior
I would expect
intercepted.glsl
to look like this:Minimal example file
Minimal init.lua
Additional context
No response
The text was updated successfully, but these errors were encountered: