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`