@@ -464,59 +464,46 @@ under the [`lsp.ruff.initialization_options.settings`](https://zed.dev/docs/conf
464464}
465465```
466466
467- !!! note
468-
469- Support for multiple formatters for a given language is only available in Zed version
470- `0.146.0` and later.
471-
472467You can configure Ruff to format Python code on-save by registering the Ruff formatter
473468and enabling the [ ` format_on_save ` ] ( https://zed.dev/docs/configuring-zed#format-on-save ) setting:
474469
475- === "Zed 0.146.0+"
476-
477- ```json
478- {
479- "languages": {
480- "Python": {
481- "language_servers": ["ruff"],
482- "format_on_save": "on",
483- "formatter": [
484- {
485- "language_server": {
486- "name": "ruff"
487- }
488- }
489- ]
470+ ``` json
471+ {
472+ "languages" : {
473+ "Python" : {
474+ "language_servers" : [" ruff" ],
475+ "format_on_save" : " on" ,
476+ "formatter" : [
477+ {
478+ "language_server" : {
479+ "name" : " ruff"
480+ }
490481 }
491- }
482+ ]
492483 }
493- ```
484+ }
485+ }
486+ ```
494487
495488You can configure Ruff to fix lint violations and/or organize imports on-save by enabling the
496489` source.fixAll.ruff ` and ` source.organizeImports.ruff ` code actions respectively:
497490
498- === "Zed 0.146.0+"
499-
500- ```json
501- {
502- "languages": {
503- "Python": {
504- "language_servers": ["ruff"],
505- "format_on_save": "on",
506- "formatter": [
507- {
508- "code_actions": {
509- // Fix all auto-fixable lint violations
510- "source.fixAll.ruff": true,
511- // Organize imports
512- "source.organizeImports.ruff": true
513- }
514- }
515- ]
516- }
517- }
491+ ``` json
492+ {
493+ "languages" : {
494+ "Python" : {
495+ "language_servers" : [" ruff" ],
496+ "format_on_save" : " on" ,
497+ "formatter" : [
498+ // Fix all auto-fixable lint violations
499+ { "code_action" : " source.fixAll.ruff" },
500+ // Organize imports
501+ { "code_action" : " source.organizeImports.ruff" }
502+ ]
518503 }
519- ```
504+ }
505+ }
506+ ```
520507
521508Taken together, you can configure Ruff to format, fix, and organize imports on-save via the
522509following ` settings.json ` :
@@ -528,28 +515,18 @@ following `settings.json`:
528515 ensure that the formatter takes care of any remaining style issues after the code actions have
529516 been applied.
530517
531- === "Zed 0.146.0+"
532-
533- ```json
534- {
535- "languages": {
536- "Python": {
537- "language_servers": ["ruff"],
538- "format_on_save": "on",
539- "formatter": [
540- {
541- "code_actions": {
542- "source.organizeImports.ruff": true,
543- "source.fixAll.ruff": true
544- }
545- },
546- {
547- "language_server": {
548- "name": "ruff"
549- }
550- }
551- ]
552- }
553- }
518+ ``` json
519+ {
520+ "languages" : {
521+ "Python" : {
522+ "language_servers" : [" ruff" ],
523+ "format_on_save" : " on" ,
524+ "formatter" : [
525+ { "code_action" : " source.fixAll.ruff" },
526+ { "code_action" : " source.organizeImports.ruff" },
527+ { "language_server" : { "name" : " ruff" } }
528+ ]
554529 }
555- ```
530+ }
531+ }
532+ ```
0 commit comments