From 4a8a56ec2c3f1ad2e39fcabfd44793cf9402a135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 24 Jun 2026 15:02:23 +0900 Subject: [PATCH] book: Document some common code actions on save --- book/src/languages.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/book/src/languages.md b/book/src/languages.md index 845b496a..8882b44c 100644 --- a/book/src/languages.md +++ b/book/src/languages.md @@ -140,6 +140,29 @@ argument to the formatter: formatter = { command = "mylang-formatter" , args = ["--stdin", "--stdin-filename", "%{buffer_name}"] } ``` +### Configuring code actions on save + +The `code-actions-on-save` key lists LSP code actions to run (in order) when +the buffer is saved. The available actions depend on available language servers, +below are common examples and may need adjusting for your setup. + +```toml +# Python with ruff +[[language]] +name = "python" +code-actions-on-save = ["source.organizeImports", "source.fixAll"] + +# TS/JS with tsserver +[[language]] +name = "typescript" +code-actions-on-save = ["source.addMissingImports.ts"] + +# TS/JS with eslint +[[language]] +name = "javascript" +code-actions-on-save = ["source.fixAll.eslint", "source.organizeImports"] +``` + ## Language Server configuration Language servers are configured separately in the table `language-server` in the same file as the languages `languages.toml` -- 2.51.2