Range formatting?
Is it possible to enable lsp_format_document_range for rust-analyzer? I can't make it working with
{
"settings": {
"rust-analyzer.cargo.targetDir": true,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.buildScripts.rebuildOnSave": false,
"rust-analyzer.rustfmt.rangeFormatting.enable": true,
"rust-analyzer.rustfmt.overrideCommand": [
"/usr/bin/rustfmt",
"+nightly",
"--edition=2024",
"--unstable-features",
"--emit=stdout",
"--"
],
},
"command": [
"/usr/lib/rustup/bin/rust-analyzer"
],
"experimental_capabilities": {
"documentRangeFormattingProvider": {
"rangesSupport": true,
},
},
"disabled_capabilities": {
"diagnosticProvider": true,
},
}
This feature works in VsCode using Format Selection command
It looks like it also requires this:
"initializationOptions": {
"rustfmt.rangeFormatting.enable": true
},
related issue: https://github.com/rust-lang/rust-analyzer/issues/17301
Once they support dynamic registration for range formatting then having it configured in settings would be enough.
BTW. That experimental_capabilities that you are setting doesn't seem to do anything.
It looks like it also requires this:
"initializationOptions": { "rustfmt.rangeFormatting.enable": true },related issue: rust-lang/rust-analyzer#17301
Once they support dynamic registration for range formatting then having it configured in
settingswould be enough.BTW. That
experimental_capabilitiesthat you are setting doesn't seem to do anything.
Nice! But now it formats whole document even with lsp_format_document_range command! 😅