Refresh generated neovim config
This commit is contained in:
@ -18,16 +18,16 @@ Lightweight yet powerful formatter plugin for Neovim
|
||||
- [setup(opts)](#setupopts)
|
||||
- [format(opts, callback)](#formatopts-callback)
|
||||
- [list_formatters(bufnr)](#list_formattersbufnr)
|
||||
- [list_formatters_to_run(bufnr)](#list_formatters_to_runbufnr)
|
||||
- [list_all_formatters()](#list_all_formatters)
|
||||
- [get_formatter_info(formatter, bufnr)](#get_formatter_infoformatter-bufnr)
|
||||
- [will_fallback_lsp(options)](#will_fallback_lspoptions)
|
||||
- [Acknowledgements](#acknowledgements)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
## Requirements
|
||||
|
||||
- Neovim 0.8+
|
||||
- Neovim 0.9+ (for older versions, use a [nvim-0.x branch](https://github.com/stevearc/conform.nvim/branches))
|
||||
|
||||
## Features
|
||||
|
||||
@ -129,8 +129,10 @@ require("conform").setup({
|
||||
lua = { "stylua" },
|
||||
-- Conform will run multiple formatters sequentially
|
||||
python = { "isort", "black" },
|
||||
-- Use a sub-list to run only the first available formatter
|
||||
javascript = { { "prettierd", "prettier" } },
|
||||
-- You can customize some of the format options for the filetype (:help conform.format)
|
||||
rust = { "rustfmt", lsp_format = "fallback" },
|
||||
-- Conform will run the first available formatter
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
},
|
||||
})
|
||||
```
|
||||
@ -196,24 +198,31 @@ You can view this list in vim with `:help conform-formatters`
|
||||
- [blade-formatter](https://github.com/shufo/blade-formatter) - An opinionated blade template formatter for Laravel that respects readability.
|
||||
- [blue](https://github.com/grantjenks/blue) - The slightly less uncompromising Python code formatter.
|
||||
- [bpfmt](https://source.android.com/docs/setup/reference/androidbp) - Android Blueprint file formatter.
|
||||
- [bsfmt](https://github.com/rokucommunity/brighterscript-formatter) - A code formatter for BrighterScript (and BrightScript).
|
||||
- [buf](https://buf.build/docs/reference/cli/buf/format) - A new way of working with Protocol Buffers.
|
||||
- [buildifier](https://github.com/bazelbuild/buildtools/tree/master/buildifier) - buildifier is a tool for formatting bazel BUILD and .bzl files with a standard convention.
|
||||
- [cabal_fmt](https://hackage.haskell.org/package/cabal-fmt) - Format cabal files with cabal-fmt
|
||||
- [caramel_fmt](https://caramel.run/manual/reference/cli/fmt.html) - Format Caramel code.
|
||||
- [cbfmt](https://github.com/lukas-reineke/cbfmt) - A tool to format codeblocks inside markdown and org documents.
|
||||
- [clang-format](https://www.kernel.org/doc/html/latest/process/clang-format.html) - Tool to format C/C++/… code according to a set of rules and heuristics.
|
||||
- [cljstyle](https://github.com/greglook/cljstyle) - Formatter for Clojure code.
|
||||
- [cmake_format](https://github.com/cheshirekow/cmake_format) - Parse cmake listfiles and format them nicely.
|
||||
- [codespell](https://github.com/codespell-project/codespell) - Check code for common misspellings.
|
||||
- [crlfmt](https://github.com/cockroachdb/crlfmt) - Formatter for CockroachDB's additions to the Go style guide.
|
||||
- [crystal](https://crystal-lang.org/) - Format Crystal code.
|
||||
- [csharpier](https://github.com/belav/csharpier) - The opinionated C# code formatter.
|
||||
- [cue_fmt](https://cuelang.org) - Format CUE files using `cue fmt` command.
|
||||
- [d2](https://github.com/terrastruct/d2) - D2 is a modern diagram scripting language that turns text to diagrams.
|
||||
- [darker](https://github.com/akaihola/darker) - Run black only on changed lines.
|
||||
- [dart_format](https://dart.dev/tools/dart-format) - Replace the whitespace in your program with formatting that follows Dart guidelines.
|
||||
- [dcm_fix](https://dcm.dev/docs/cli/formatting/fix/) - Fixes issues produced by dcm analyze, dcm check-unused-code or dcm check-dependencies commands.
|
||||
- [dcm_format](https://dcm.dev/docs/cli/formatting/format/) - Formats .dart files.
|
||||
- [deno_fmt](https://deno.land/manual/tools/formatter) - Use [Deno](https://deno.land/) to format TypeScript, JavaScript/JSON and markdown.
|
||||
- [dfmt](https://github.com/dlang-community/dfmt) - Formatter for D source code.
|
||||
- [djlint](https://github.com/Riverside-Healthcare/djLint) - ✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang.
|
||||
- [docformatter](https://pypi.org/project/docformatter/) - docformatter automatically formats docstrings to follow a subset of the PEP 257 conventions.
|
||||
- [docstrfmt](https://github.com/LilSpazJoekp/docstrfmt) - reStructuredText formatter.
|
||||
- [doctoc](https://github.com/thlorenz/doctoc) - Generates table of contents for markdown files inside local git repository.
|
||||
- [dprint](https://github.com/dprint/dprint) - Pluggable and configurable code formatting platform written in Rust.
|
||||
- [easy-coding-standard](https://github.com/easy-coding-standard/easy-coding-standard) - ecs - Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer.
|
||||
- [efmt](https://github.com/sile/efmt) - Erlang code formatter.
|
||||
@ -234,6 +243,7 @@ You can view this list in vim with `:help conform-formatters`
|
||||
- [gdformat](https://github.com/Scony/godot-gdscript-toolkit) - A formatter for Godot's gdscript.
|
||||
- [gersemi](https://github.com/BlankSpruce/gersemi) - A formatter to make your CMake code the real treasure.
|
||||
- [gleam](https://github.com/gleam-lang/gleam) - ⭐️ A friendly language for building type-safe, scalable systems!
|
||||
- [gluon_fmt](https://github.com/gluon-lang/gluon) - Code formatting for the gluon programming language.
|
||||
- [gn](https://gn.googlesource.com/gn/) - gn build system.
|
||||
- [gofmt](https://pkg.go.dev/cmd/gofmt) - Formats go programs.
|
||||
- [gofumpt](https://github.com/mvdan/gofumpt) - Enforce a stricter format than gofmt, while being backwards compatible. That is, gofumpt is happy with a subset of the formats that gofmt is happy with.
|
||||
@ -241,9 +251,11 @@ You can view this list in vim with `:help conform-formatters`
|
||||
- [goimports-reviser](https://github.com/incu6us/goimports-reviser) - Right imports sorting & code formatting tool (goimports alternative).
|
||||
- [golines](https://github.com/segmentio/golines) - A golang formatter that fixes long lines.
|
||||
- [google-java-format](https://github.com/google/google-java-format) - Reformats Java source code according to Google Java Style.
|
||||
- [grain_format](https://grain-lang.org/docs/tooling/grain_cli#grain-format) - Code formatter for the grain programming language.
|
||||
- [hcl](https://github.com/hashicorp/hcl) - A formatter for HCL files.
|
||||
- [hindent](https://github.com/mihaimaruseac/hindent) - Haskell pretty printer.
|
||||
- [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier) - A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.
|
||||
- [imba_fmt](https://imba.io/) - Code formatter for the Imba programming language.
|
||||
- [indent](https://www.gnu.org/software/indent/) - GNU Indent.
|
||||
- [injected](doc/advanced_topics.md#injected-language-formatting-code-blocks) - Format treesitter injected languages.
|
||||
- [inko](https://inko-lang.org/) - A language for building concurrent software with confidence
|
||||
@ -267,6 +279,7 @@ You can view this list in vim with `:help conform-formatters`
|
||||
- [mdsf](https://github.com/hougesen/mdsf) - Format markdown code blocks using your favorite code formatters.
|
||||
- [mdslw](https://github.com/razziel89/mdslw) - Prepare your markdown for easy diff'ing by adding line breaks after every sentence.
|
||||
- [mix](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html) - Format Elixir files using the mix format command.
|
||||
- [nickel](https://nickel-lang.org/) - Code formatter for the Nickel programming language.
|
||||
- [nimpretty](https://github.com/nim-lang/nim) - nimpretty is a Nim source code beautifier that follows the official style guide.
|
||||
- [nixfmt](https://github.com/serokell/nixfmt) - nixfmt is a formatter for Nix code, intended to apply a uniform style.
|
||||
- [nixpkgs_fmt](https://github.com/nix-community/nixpkgs-fmt) - nixpkgs-fmt is a Nix code formatter for nixpkgs.
|
||||
@ -306,6 +319,7 @@ You can view this list in vim with `:help conform-formatters`
|
||||
- [shellcheck](https://github.com/koalaman/shellcheck) - A static analysis tool for shell scripts.
|
||||
- [shellharden](https://github.com/anordal/shellharden) - The corrective bash syntax highlighter.
|
||||
- [shfmt](https://github.com/mvdan/sh) - A shell parser, formatter, and interpreter with `bash` support.
|
||||
- [sleek](https://github.com/nrempel/sleek) - Sleek is a CLI tool for formatting SQL.
|
||||
- [smlfmt](https://github.com/shwestrick/smlfmt) - A custom parser and code formatter for Standard ML.
|
||||
- [snakefmt](https://github.com/snakemake/snakefmt) - a formatting tool for Snakemake files following the design of Black.
|
||||
- [sql_formatter](https://github.com/sql-formatter-org/sql-formatter) - A whitespace formatter for different query languages.
|
||||
@ -320,14 +334,15 @@ You can view this list in vim with `:help conform-formatters`
|
||||
- [stylua](https://github.com/JohnnyMorganz/StyLua) - An opinionated code formatter for Lua.
|
||||
- [swift_format](https://github.com/apple/swift-format) - Swift formatter from apple. Requires building from source with `swift build`.
|
||||
- [swiftformat](https://github.com/nicklockwood/SwiftFormat) - SwiftFormat is a code library and command-line tool for reformatting `swift` code on macOS or Linux.
|
||||
- [swiftlint](https://github.com/realm/SwiftLint) - A tool to enforce Swift style and conventions.
|
||||
- [taplo](https://github.com/tamasfe/taplo) - A TOML toolkit written in Rust.
|
||||
- [templ](https://templ.guide/commands-and-tools/cli/#formatting-templ-files) - Formats templ template files.
|
||||
- [terraform_fmt](https://www.terraform.io/docs/cli/commands/fmt.html) - The terraform-fmt command rewrites `terraform` configuration files to a canonical format and style.
|
||||
- [terragrunt_hclfmt](https://terragrunt.gruntwork.io/docs/reference/cli-options/#hclfmt) - Format hcl files into a canonical format.
|
||||
- [tlint](https://github.com/tighten/tlint) - Tighten linter for Laravel conventions with support for auto-formatting.
|
||||
- [tofu_fmt](https://opentofu.org/docs/cli/commands/fmt/) - The tofu-fmt command rewrites OpenTofu configuration files to a canonical format and style.
|
||||
- [trim_newlines](https://www.gnu.org/software/gawk/manual/gawk.html) - Trim new lines with awk.
|
||||
- [trim_whitespace](https://www.gnu.org/software/gawk/manual/gawk.html) - Trim whitespaces with awk.
|
||||
- [trim_newlines](https://github.com/stevearc/conform.nvim/blob/master/lua/conform/formatters/trim_whitespace.lua) - Trim empty lines at the end of the file.
|
||||
- [trim_whitespace](https://github.com/stevearc/conform.nvim/blob/master/lua/conform/formatters/trim_whitespace.lua) - Trim trailing whitespace.
|
||||
- [twig-cs-fixer](https://github.com/VincentLanglet/Twig-CS-Fixer) - Automatically fix Twig Coding Standards issues
|
||||
- [typos](https://github.com/crate-ci/typos) - Source code spell checker
|
||||
- [typstyle](https://github.com/Enter-tainer/typstyle) - Beautiful and reliable typst code formatter.
|
||||
@ -419,6 +434,8 @@ require("conform").formatters.shfmt = {
|
||||
- [Command to toggle format-on-save](doc/recipes.md#command-to-toggle-format-on-save)
|
||||
- [Automatically run slow formatters async](doc/recipes.md#automatically-run-slow-formatters-async)
|
||||
- [Lazy loading with lazy.nvim](doc/recipes.md#lazy-loading-with-lazynvim)
|
||||
- [Leave visual mode after range format](doc/recipes.md#leave-visual-mode-after-range-format)
|
||||
- [Run the first available formatter followed by more formatters](doc/recipes.md#run-the-first-available-formatter-followed-by-more-formatters)
|
||||
|
||||
<!-- /RECIPES -->
|
||||
|
||||
@ -445,8 +462,8 @@ require("conform").setup({
|
||||
lua = { "stylua" },
|
||||
-- Conform will run multiple formatters sequentially
|
||||
go = { "goimports", "gofmt" },
|
||||
-- Use a sub-list to run only the first available formatter
|
||||
javascript = { { "prettierd", "prettier" } },
|
||||
-- You can also customize some of the format options for the filetype
|
||||
rust = { "rustfmt", lsp_format = "fallback" },
|
||||
-- You can use a function here to determine the formatters dynamically
|
||||
python = function(bufnr)
|
||||
if require("conform").get_formatter_info("ruff_format", bufnr).available then
|
||||
@ -461,6 +478,11 @@ require("conform").setup({
|
||||
-- have other formatters configured.
|
||||
["_"] = { "trim_whitespace" },
|
||||
},
|
||||
-- Set this to change the default values when calling conform.format()
|
||||
-- This will also affect the default values for format_on_save/format_after_save
|
||||
default_format_opts = {
|
||||
lsp_format = "fallback",
|
||||
},
|
||||
-- If this is set, Conform will run the formatter on save.
|
||||
-- It will pass the table to conform.format().
|
||||
-- This can also be a function that returns the table.
|
||||
@ -479,6 +501,8 @@ require("conform").setup({
|
||||
log_level = vim.log.levels.ERROR,
|
||||
-- Conform will notify you when a formatter errors
|
||||
notify_on_error = true,
|
||||
-- Conform will notify you when no formatters are available for the buffer
|
||||
notify_no_formatters = true,
|
||||
-- Custom formatters and overrides for built-in formatters
|
||||
formatters = {
|
||||
my_formatter = {
|
||||
@ -515,7 +539,6 @@ require("conform").setup({
|
||||
-- Set to false to disable merging the config with the base definition
|
||||
inherit = true,
|
||||
-- When inherit = true, add these additional arguments to the beginning of the command.
|
||||
-- When inherit = true, add these additional arguments to the command.
|
||||
-- This can also be a function, like args
|
||||
prepend_args = { "--use-tabs" },
|
||||
-- When inherit = true, add these additional arguments to the end of the command.
|
||||
@ -564,9 +587,11 @@ require("conform").formatters.my_formatter = {
|
||||
| opts | `nil\|conform.setupOpts` | | |
|
||||
| | formatters_by_ft | `nil\|table<string, conform.FiletypeFormatter>` | Map of filetype to formatters |
|
||||
| | format_on_save | `nil\|conform.FormatOpts\|fun(bufnr: integer): nil\|conform.FormatOpts` | If this is set, Conform will run the formatter on save. It will pass the table to conform.format(). This can also be a function that returns the table. |
|
||||
| | default_format_opts | `nil\|conform.DefaultFormatOpts` | The default options to use when calling conform.format() |
|
||||
| | format_after_save | `nil\|conform.FormatOpts\|fun(bufnr: integer): nil\|conform.FormatOpts` | If this is set, Conform will run the formatter asynchronously after save. It will pass the table to conform.format(). This can also be a function that returns the table. |
|
||||
| | log_level | `nil\|integer` | Set the log level (e.g. `vim.log.levels.DEBUG`). Use `:ConformInfo` to see the location of the log file. |
|
||||
| | notify_on_error | `nil\|boolean` | Conform will notify you when a formatter errors (default true). |
|
||||
| | notify_no_formatters | `nil\|boolean` | Conform will notify you when no formatters are available for the buffer (default true). |
|
||||
| | formatters | `nil\|table<string, conform.FormatterConfigOverride\|fun(bufnr: integer): nil\|conform.FormatterConfigOverride>` | Custom formatters and overrides for built-in formatters. |
|
||||
|
||||
### format(opts, callback)
|
||||
@ -574,21 +599,28 @@ require("conform").formatters.my_formatter = {
|
||||
`format(opts, callback): boolean` \
|
||||
Format a buffer
|
||||
|
||||
| Param | Type | Desc | |
|
||||
| -------- | ---------------------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| opts | `nil\|conform.FormatOpts` | | |
|
||||
| | timeout_ms | `nil\|integer` | Time in milliseconds to block for formatting. Defaults to 1000. No effect if async = true. |
|
||||
| | bufnr | `nil\|integer` | Format this buffer (default 0) |
|
||||
| | async | `nil\|boolean` | If true the method won't block. Defaults to false. If the buffer is modified before the formatter completes, the formatting will be discarded. |
|
||||
| | dry_run | `nil\|boolean` | If true don't apply formatting changes to the buffer |
|
||||
| | formatters | `nil\|string[]` | List of formatters to run. Defaults to all formatters for the buffer filetype. |
|
||||
| | lsp_format | `nil\|"never"\|"fallback"\|"prefer"\|"first"\|"last"` | "fallback" LSP formatting when no other formatters are available, "prefer" only LSP formatting when available, "first" LSP formatting then other formatters, "last" other formatters then LSP. |
|
||||
| | quiet | `nil\|boolean` | Don't show any notifications for warnings or failures. Defaults to false. |
|
||||
| | range | `nil\|table` | Range to format. Table must contain `start` and `end` keys with {row, col} tuples using (1,0) indexing. Defaults to current selection in visual mode |
|
||||
| | id | `nil\|integer` | Passed to vim.lsp.buf.format when using LSP formatting |
|
||||
| | name | `nil\|string` | Passed to vim.lsp.buf.format when using LSP formatting |
|
||||
| | filter | `nil\|fun(client: table): boolean` | Passed to vim.lsp.buf.format when using LSP formatting |
|
||||
| callback | `nil\|fun(err: nil\|string, did_edit: nil\|boolean)` | Called once formatting has completed | |
|
||||
| Param | Type | Desc | |
|
||||
| -------- | ---------------------------------------------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| opts | `nil\|conform.FormatOpts` | | |
|
||||
| | timeout_ms | `nil\|integer` | Time in milliseconds to block for formatting. Defaults to 1000. No effect if async = true. |
|
||||
| | bufnr | `nil\|integer` | Format this buffer (default 0) |
|
||||
| | async | `nil\|boolean` | If true the method won't block. Defaults to false. If the buffer is modified before the formatter completes, the formatting will be discarded. |
|
||||
| | dry_run | `nil\|boolean` | If true don't apply formatting changes to the buffer |
|
||||
| | undojoin | `nil\|boolean` | Use undojoin to merge formatting changes with previous edit (default false) |
|
||||
| | formatters | `nil\|string[]` | List of formatters to run. Defaults to all formatters for the buffer filetype. |
|
||||
| | lsp_format | `nil\|conform.LspFormatOpts` | Configure if and when LSP should be used for formatting. Defaults to "never". |
|
||||
| | | > `"never"` | never use the LSP for formatting (default) |
|
||||
| | | > `"fallback"` | LSP formatting is used when no other formatters are available |
|
||||
| | | > `"prefer"` | use only LSP formatting when available |
|
||||
| | | > `"first"` | LSP formatting is used when available and then other formatters |
|
||||
| | | > `"last"` | other formatters are used then LSP formatting when available |
|
||||
| | stop_after_first | `nil\|boolean` | Only run the first available formatter in the list. Defaults to false. |
|
||||
| | quiet | `nil\|boolean` | Don't show any notifications for warnings or failures. Defaults to false. |
|
||||
| | range | `nil\|conform.Range` | Range to format. Table must contain `start` and `end` keys with {row, col} tuples using (1,0) indexing. Defaults to current selection in visual mode |
|
||||
| | id | `nil\|integer` | Passed to vim.lsp.buf.format when using LSP formatting |
|
||||
| | name | `nil\|string` | Passed to vim.lsp.buf.format when using LSP formatting |
|
||||
| | filter | `nil\|fun(client: table): boolean` | Passed to vim.lsp.buf.format when using LSP formatting |
|
||||
| callback | `nil\|fun(err: nil\|string, did_edit: nil\|boolean)` | Called once formatting has completed | |
|
||||
|
||||
Returns:
|
||||
|
||||
@ -605,6 +637,27 @@ Retrieve the available formatters for a buffer
|
||||
| ----- | -------------- | ---- |
|
||||
| bufnr | `nil\|integer` | |
|
||||
|
||||
### list_formatters_to_run(bufnr)
|
||||
|
||||
`list_formatters_to_run(bufnr): conform.FormatterInfo[], boolean` \
|
||||
Get the exact formatters that will be run for a buffer.
|
||||
|
||||
| Param | Type | Desc |
|
||||
| ----- | -------------- | ---- |
|
||||
| bufnr | `nil\|integer` | |
|
||||
|
||||
Returns:
|
||||
|
||||
| Type | Desc |
|
||||
| ----------------------- | -------------------------- |
|
||||
| conform.FormatterInfo[] | |
|
||||
| boolean | lsp Will use LSP formatter |
|
||||
|
||||
**Note:**
|
||||
<pre>
|
||||
This accounts for stop_after_first, lsp fallback logic, etc.
|
||||
</pre>
|
||||
|
||||
### list_all_formatters()
|
||||
|
||||
`list_all_formatters(): conform.FormatterInfo[]` \
|
||||
@ -620,15 +673,6 @@ Get information about a formatter (including availability)
|
||||
| --------- | -------------- | ------------------------- |
|
||||
| formatter | `string` | The name of the formatter |
|
||||
| bufnr | `nil\|integer` | |
|
||||
|
||||
### will_fallback_lsp(options)
|
||||
|
||||
`will_fallback_lsp(options): boolean` \
|
||||
Check if the buffer will use LSP formatting when lsp_format = "fallback"
|
||||
|
||||
| Param | Type | Desc |
|
||||
| ------- | ------------ | ------------------------------------ |
|
||||
| options | `nil\|table` | Options passed to vim.lsp.buf.format |
|
||||
<!-- /API -->
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Reference in New Issue
Block a user