1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -0,0 +1,2 @@
layout python
python -c 'import pyparsing' 2> /dev/null || pip install pyparsing==3.0.9 black isort mypy

View File

@ -0,0 +1,129 @@
name: Bug Report
description: File a bug/issue
title: "bug: "
labels: [bug]
body:
- type: markdown
attributes:
value: |
Before reporting a bug, make sure to search [existing issues](https://github.com/stevearc/conform.nvim/issues)
- type: input
attributes:
label: "Neovim version (nvim -v)"
placeholder: "0.8.0 commit db1b0ee3b30f"
validations:
required: true
- type: input
attributes:
label: "Operating system/version"
placeholder: "MacOS 11.5"
validations:
required: true
- type: checkboxes
attributes:
label: Add the debug logs
options:
- label: I have set `log_level = vim.log.levels.DEBUG` and pasted the log contents below.
required: true
- type: textarea
attributes:
label: "Log file"
description: "Recent contents from the log file. You can find it with :ConformInfo"
validations:
required: true
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: dropdown
attributes:
label: What is the severity of this bug?
options:
- minor (annoyance)
- tolerable (can work around it)
- breaking (some functionality is broken)
- blocking (cannot use plugin)
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. nvim -u repro.lua
2.
3.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: A concise description of what you expected to happen.
validations:
required: true
- type: textarea
attributes:
label: Minimal example file
description: A small example file you are editing that produces the issue
validations:
required: false
- type: textarea
attributes:
label: Minimal init.lua
description:
Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
This uses lazy.nvim (a plugin manager).
value: |
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
{
"stevearc/conform.nvim",
config = function()
require("conform").setup({
log_level = vim.log.levels.DEBUG,
-- add your config here
})
end,
},
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
render: Lua
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: Any additional information or screenshots you would like to provide
validations:
required: false

View File

@ -0,0 +1,43 @@
name: Feature Request
description: Submit a feature request
title: "feature request: "
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
Before submitting a feature request, make sure to search for [existing requests](https://github.com/stevearc/conform.nvim/issues)
- type: checkboxes
attributes:
label: Did you check existing requests?
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Describe the feature
description: A short summary of the feature you want
validations:
required: true
- type: textarea
attributes:
label: Provide background
description: Describe the reasoning behind why you want the feature.
placeholder: I am trying to do X. My current workflow is Y.
validations:
required: false
- type: dropdown
attributes:
label: What is the significance of this feature?
options:
- nice to have
- strongly desired
- cannot use this plugin without it
validations:
required: true
- type: textarea
attributes:
label: Additional details
description: Any additional information you would like to provide. Things you've tried, alternatives considered, examples from other plugins, etc.
validations:
required: false

View File

@ -0,0 +1,3 @@
#!/nix/store/306znyj77fv49kwnkpxmb0j2znqpa8bj-bash-5.2p26/bin/bash
set -e
make fastlint

View File

@ -0,0 +1,11 @@
#!/nix/store/306znyj77fv49kwnkpxmb0j2znqpa8bj-bash-5.2p26/bin/bash
set -e
IFS=' '
while read local_ref _local_sha _remote_ref _remote_sha; do
remote_main=$( (git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null || echo "///master") | cut -f 4 -d / | tr -d "[:space:]")
local_ref_short=$(echo "$local_ref" | cut -f 3 -d / | tr -d "[:space:]")
if [ "$local_ref_short" = "$remote_main" ]; then
make lint
make test
fi
done

View File

@ -0,0 +1,16 @@
name: Remove Question Label on Issue Comment
on: [issue_comment]
jobs:
# Remove the "question" label when a new comment is added.
# This lets me ask a question, tag the issue with "question", and filter out all "question"-tagged
# issues in my "needs triage" filter.
remove_question:
runs-on: ubuntu-latest
if: github.event.sender.login != 'stevearc'
steps:
- uses: actions/checkout@v4
- uses: actions-ecosystem/action-remove-labels@v1
with:
labels: question

View File

@ -0,0 +1,27 @@
name: Request Review
permissions:
pull-requests: write
on:
pull_request_target:
types: [opened, reopened, ready_for_review, synchronize]
branches-ignore:
- "release-please--**"
jobs:
# Request review automatically when PRs are opened
request_review:
runs-on: ubuntu-latest
steps:
- name: Request Review
uses: actions/github-script@v7
if: github.actor != 'stevearc'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request;
github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
reviewers: ['stevearc']
});

View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
PLUGINS="$HOME/.local/share/nvim/site/pack/plugins/start"
mkdir -p "$PLUGINS"
wget "https://github.com/neovim/neovim/releases/download/${NVIM_TAG-stable}/nvim.appimage"
chmod +x nvim.appimage
./nvim.appimage --appimage-extract >/dev/null
rm -f nvim.appimage
mkdir -p ~/.local/share/nvim
mv squashfs-root ~/.local/share/nvim/appimage
sudo ln -s "$HOME/.local/share/nvim/appimage/AppRun" /usr/bin/nvim

View File

@ -0,0 +1,124 @@
name: Run tests
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
luacheck:
name: Luacheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
sudo apt-get update
sudo add-apt-repository universe
sudo apt install luarocks -y
sudo luarocks install luacheck
- name: Run Luacheck
run: luacheck lua tests
typecheck:
name: typecheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: stevearc/nvim-typecheck-action@v1
with:
path: lua
stylua:
name: StyLua
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Stylua
uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.20.0
args: --check lua tests
run_tests:
strategy:
matrix:
include:
- nvim_tag: v0.8.3
- nvim_tag: v0.9.4
- nvim_tag: v0.10.0
name: Run tests
runs-on: ubuntu-22.04
env:
NVIM_TAG: ${{ matrix.nvim_tag }}
steps:
- uses: actions/checkout@v4
- name: Install Neovim and dependencies
run: |
bash ./.github/workflows/install_nvim.sh
- name: Run tests
run: |
bash ./run_tests.sh
update_docs:
name: Update docs
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Neovim and dependencies
run: |
bash ./.github/workflows/install_nvim.sh
- name: Update docs
run: |
python -m pip install pyparsing==3.0.9
make doc
- name: Commit changes
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MSG: |
[docgen] Update docs
skip-checks: true
run: |
git config user.email "actions@github"
git config user.name "Github Actions"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git add README.md doc
# Only commit and push if we have changes
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF})
release:
name: release
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- luacheck
- stylua
- typecheck
- run_tests
- update_docs
runs-on: ubuntu-22.04
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: simple
- uses: actions/checkout@v4
- uses: rickstaa/action-create-tag@v1
if: ${{ steps.release.outputs.release_created }}
with:
tag: stable
message: "Current stable release: ${{ steps.release.outputs.tag_name }}"
tag_exists_error: false
force_push_tag: true

View File

@ -0,0 +1,48 @@
# Compiled Lua sources
luac.out
# luarocks build files
*.src.rock
*.zip
*.tar.gz
# Object files
*.o
*.os
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
.direnv/
.testenv/
doc/tags
tests/testfile.txt
tests/fake_formatter_output
scripts/nvim_doc_tools
scripts/nvim-typecheck-action

View File

@ -0,0 +1,19 @@
max_comment_line_length = false
codes = true
exclude_files = {
"tests/treesitter",
}
ignore = {
"212", -- Unused argument
"631", -- Line is too long
"122", -- Setting a readonly global
"542", -- Empty if branch
}
read_globals = {
"vim",
"a",
"assert",
}

View File

@ -0,0 +1,5 @@
column_width = 100
indent_type = "Spaces"
indent_width = 2
[sort_requires]
enabled = true

View File

@ -0,0 +1,571 @@
# Changelog
## [5.8.0](https://github.com/stevearc/conform.nvim/compare/v5.7.0...v5.8.0) (2024-05-22)
### Features
* add `ruff_organize_imports` formatter ([#418](https://github.com/stevearc/conform.nvim/issues/418)) ([184756b](https://github.com/stevearc/conform.nvim/commit/184756b7522f82ccdac0013adff1caa313cb897a))
* add forge_fmt formatter support for solidity filetype ([#417](https://github.com/stevearc/conform.nvim/issues/417)) ([18a3fa4](https://github.com/stevearc/conform.nvim/commit/18a3fa45d841c941399b4559ef60b39f2e3ded7c))
* add support for leptosfmt ([#415](https://github.com/stevearc/conform.nvim/issues/415)) ([b999fad](https://github.com/stevearc/conform.nvim/commit/b999fad66fd797a57d745c1a999d000b889bd587))
* add support for typstyle ([#412](https://github.com/stevearc/conform.nvim/issues/412)) ([e47dcde](https://github.com/stevearc/conform.nvim/commit/e47dcde340c80645ab32b09da2c492174e6660c4))
## [5.7.0](https://github.com/stevearc/conform.nvim/compare/v5.6.0...v5.7.0) (2024-05-16)
### Features
* add hcl formatter (hclfmt) ([#402](https://github.com/stevearc/conform.nvim/issues/402)) ([37cbcea](https://github.com/stevearc/conform.nvim/commit/37cbceab0a3b4979c4f0f1ae7aede0d0fa84c1d1))
* add ktfmt formatter for Kotlin ([#392](https://github.com/stevearc/conform.nvim/issues/392)) ([b72f650](https://github.com/stevearc/conform.nvim/commit/b72f650206ddfeadd6c7df0f775a928e82ece353))
* add ormolu formatter for Haskell ([#377](https://github.com/stevearc/conform.nvim/issues/377)) ([#397](https://github.com/stevearc/conform.nvim/issues/397)) ([6207f41](https://github.com/stevearc/conform.nvim/commit/6207f41e8f3813d72ef4499a8132c11d8baabe9f))
* add snakefmt formatter for snakemake files ([#399](https://github.com/stevearc/conform.nvim/issues/399)) ([dc950e5](https://github.com/stevearc/conform.nvim/commit/dc950e5717f1da65b1fcd986b1bbff0d6bd0e2ee))
* add support for bicep ([#368](https://github.com/stevearc/conform.nvim/issues/368)) ([588f357](https://github.com/stevearc/conform.nvim/commit/588f357d305943371de5c945aea65959fd4d80b9))
* add support for bpfmt ([#405](https://github.com/stevearc/conform.nvim/issues/405)) ([3c278a7](https://github.com/stevearc/conform.nvim/commit/3c278a7e09e135e524545adcd725f89bfcc7ffbd))
* add support for mdsf ([#380](https://github.com/stevearc/conform.nvim/issues/380)) ([34d3c5f](https://github.com/stevearc/conform.nvim/commit/34d3c5f58017b1a7e1cd23739b263d7af0f66d7c))
* add support for yew-fmt ([#398](https://github.com/stevearc/conform.nvim/issues/398)) ([b52d462](https://github.com/stevearc/conform.nvim/commit/b52d462cb7bea5e81174ece43eb349357add2f11))
* add verible formatter for SystemVerilog ([#391](https://github.com/stevearc/conform.nvim/issues/391)) ([fb2d35f](https://github.com/stevearc/conform.nvim/commit/fb2d35f2875967b92af9e1e7d31724ce0456fa83))
* formatters can use $RELATIVE_FILEPATH in args ([#349](https://github.com/stevearc/conform.nvim/issues/349)) ([6dc1603](https://github.com/stevearc/conform.nvim/commit/6dc1603ea408f476a57937bbeaf7f86520a21a98))
### Bug Fixes
* **biome-check:** use safe fixes ([#373](https://github.com/stevearc/conform.nvim/issues/373)) ([500a6ae](https://github.com/stevearc/conform.nvim/commit/500a6ae6c10b2a96e85e64045ad9f3b16e2af7f8))
* **biome:** support biome.jsonc file ([#394](https://github.com/stevearc/conform.nvim/issues/394)) ([3cd1135](https://github.com/stevearc/conform.nvim/commit/3cd1135cb2978c9d45b8dc6afc80045fb8a93157))
* handle windows line ending when config.stdin is true ([#361](https://github.com/stevearc/conform.nvim/issues/361)) ([820eec9](https://github.com/stevearc/conform.nvim/commit/820eec990d5f332d30cf939954c8672a43a0459e))
* **isort:** explicitly pass line endings ([#395](https://github.com/stevearc/conform.nvim/issues/395)) ([a3e3e0e](https://github.com/stevearc/conform.nvim/commit/a3e3e0e2966a9fa477bbc86487e920ee0c34f133))
* lazily compute relative filepath ([40faaa8](https://github.com/stevearc/conform.nvim/commit/40faaa8fdd0b7f98f58070943306fd93abb5caad))
* **mix:** allow mix formatter to format different filetypes ([#389](https://github.com/stevearc/conform.nvim/issues/389)) ([12b3995](https://github.com/stevearc/conform.nvim/commit/12b3995537f52ba2810a9857e8ca256881febbda))
* **prettierd:** correctly find prettierd executable on windows ([#378](https://github.com/stevearc/conform.nvim/issues/378)) ([a6965ac](https://github.com/stevearc/conform.nvim/commit/a6965ac128eba75537ec2bc5ddd5d5e357062bdc))
* refactor deprecated methods in neovim 0.10 ([7a205c9](https://github.com/stevearc/conform.nvim/commit/7a205c944d228ca0a5ec67656f59d20ba11ccca2))
* **util:** new function throwing an error when the given extended value is nil ([#385](https://github.com/stevearc/conform.nvim/issues/385)) ([4660e53](https://github.com/stevearc/conform.nvim/commit/4660e534bf7678ee0f85879aa75fdcb6855612c2))
* warning messages for improper async in format_on_save ([#401](https://github.com/stevearc/conform.nvim/issues/401)) ([59d0dd2](https://github.com/stevearc/conform.nvim/commit/59d0dd233a2cafacfa1235ab22054c4d80a72319))
* **windows:** assertion failure when computing relative path ([#400](https://github.com/stevearc/conform.nvim/issues/400)) ([4f0cdf0](https://github.com/stevearc/conform.nvim/commit/4f0cdf07b5498935c34d6cfefde059a3a91584c4))
## [5.6.0](https://github.com/stevearc/conform.nvim/compare/v5.5.0...v5.6.0) (2024-03-28)
### Features
* a formatter for SML (Standard ML) ([#353](https://github.com/stevearc/conform.nvim/issues/353)) ([ae6a069](https://github.com/stevearc/conform.nvim/commit/ae6a069e33027fc522151bf656ab06cf93abca46))
* add formatter for Inko ([#351](https://github.com/stevearc/conform.nvim/issues/351)) ([6874087](https://github.com/stevearc/conform.nvim/commit/68740871bd1b7aecc3759136d576ecb704c4a636))
* add ocp-indent for OCaml formatting ([#335](https://github.com/stevearc/conform.nvim/issues/335)) ([551d02f](https://github.com/stevearc/conform.nvim/commit/551d02f472b646cb82657700e3459f16d9933005))
* add support for nimpretty ([#343](https://github.com/stevearc/conform.nvim/issues/343)) ([67f7fb2](https://github.com/stevearc/conform.nvim/commit/67f7fb2fe82d170c681e6c0da67aa848e6f5a742))
* add support for purs-tidy ([#345](https://github.com/stevearc/conform.nvim/issues/345)) ([bf109f0](https://github.com/stevearc/conform.nvim/commit/bf109f061fc3cd75394b7823923187ae045cbf22))
* add support for roc format ([#342](https://github.com/stevearc/conform.nvim/issues/342)) ([293236a](https://github.com/stevearc/conform.nvim/commit/293236aa7445fb24aba56d8e9a03be54d0c1c2e8))
* **prettier, prettierd:** add mjs files to supported config files ([#350](https://github.com/stevearc/conform.nvim/issues/350)) ([ac4a022](https://github.com/stevearc/conform.nvim/commit/ac4a022c9e10e9697235f657f166372326139e8b))
* support crystal tool format ([#344](https://github.com/stevearc/conform.nvim/issues/344)) ([f8c64b8](https://github.com/stevearc/conform.nvim/commit/f8c64b835f60a80639375500a80e8cd303d8eda6))
### Bug Fixes
* **injected:** ignore indentation of final whitespace line ([#340](https://github.com/stevearc/conform.nvim/issues/340)) ([0a530b3](https://github.com/stevearc/conform.nvim/commit/0a530b31acacf10eca9f9a74b2434ece4d232ca3))
* **terraform_fmt:** do not output color escape codes ([#354](https://github.com/stevearc/conform.nvim/issues/354)) ([f3363ad](https://github.com/stevearc/conform.nvim/commit/f3363ad4b1453b0c9a591d2571c540ed145323d7))
* use `--force-exclude` with Ruff ([#348](https://github.com/stevearc/conform.nvim/issues/348)) ([93f3d4c](https://github.com/stevearc/conform.nvim/commit/93f3d4cabe41473477a314c731e635175458f591))
## [5.5.0](https://github.com/stevearc/conform.nvim/compare/v5.4.0...v5.5.0) (2024-03-17)
### Features
* add formatter config option to change name of temporary file ([#332](https://github.com/stevearc/conform.nvim/issues/332)) ([b059626](https://github.com/stevearc/conform.nvim/commit/b05962622d3eebeefe6b1a90deb9eb86947e0349))
### Bug Fixes
* **phpcbf:** use non-stdin formatting and customize tempfile name ([#333](https://github.com/stevearc/conform.nvim/issues/333)) ([67ee225](https://github.com/stevearc/conform.nvim/commit/67ee2258e08ccb91345d52f62484b657feccef25))
* **rustfmt:** parse edition from Cargo.toml ([#330](https://github.com/stevearc/conform.nvim/issues/330)) ([a605ce4](https://github.com/stevearc/conform.nvim/commit/a605ce4b2db397c84ae6fa8bcfc85f00b985bc73))
* **sqlfluff:** remove --force flag since it's default now ([#338](https://github.com/stevearc/conform.nvim/issues/338)) ([42f3d8e](https://github.com/stevearc/conform.nvim/commit/42f3d8e1c1a90e1114d12a49be838409cbbd1239))
## [5.4.0](https://github.com/stevearc/conform.nvim/compare/v5.3.0...v5.4.0) (2024-03-13)
### Features
* add `gersemi` formatter ([#305](https://github.com/stevearc/conform.nvim/issues/305)) ([79d7fd9](https://github.com/stevearc/conform.nvim/commit/79d7fd9ee84e603bdb66038b1d1ed2703ec08d14))
* add formatter sqlfmt ([#307](https://github.com/stevearc/conform.nvim/issues/307)) ([015f9e9](https://github.com/stevearc/conform.nvim/commit/015f9e90d945545b665dfda52e6c96590c3d1292))
* add gleam formatter ([#327](https://github.com/stevearc/conform.nvim/issues/327)) ([2ebfcaa](https://github.com/stevearc/conform.nvim/commit/2ebfcaa4f2e85550d985eae8ed417401319ebccd))
* add OpenTofu formatter ([#313](https://github.com/stevearc/conform.nvim/issues/313)) ([68dad93](https://github.com/stevearc/conform.nvim/commit/68dad93cde8d8b71e53d07ac43029d0fca06bf26))
* add the cabal-fmt formatter ([#318](https://github.com/stevearc/conform.nvim/issues/318)) ([ea73026](https://github.com/stevearc/conform.nvim/commit/ea73026a163e124edb47fe48075091d924d139af))
* **formatter:** add liquidsoap-prettier ([#312](https://github.com/stevearc/conform.nvim/issues/312)) ([dc873e9](https://github.com/stevearc/conform.nvim/commit/dc873e94f300cdadf0c1949c14b6e9137e7a9981))
### Bug Fixes
* add cwd to honor project php-cs-fixer ([#325](https://github.com/stevearc/conform.nvim/issues/325)) ([f5f8498](https://github.com/stevearc/conform.nvim/commit/f5f8498cf27931e06645c9fe020b9c28dce49d98))
* **prettier:** Fix range formatting of buffer ([#322](https://github.com/stevearc/conform.nvim/issues/322)) ([bc93756](https://github.com/stevearc/conform.nvim/commit/bc937565f251866c0ff344fd13fe27f00a4c0d25))
* remove call to deprecated tbl_add_reverse_lookup ([5a15cc4](https://github.com/stevearc/conform.nvim/commit/5a15cc46e75cad804fd51ec5af9227aeb1d1bdaa))
* **rustfmt:** use Cargo.toml settings and default to recent edition ([#328](https://github.com/stevearc/conform.nvim/issues/328)) ([0ff1b7d](https://github.com/stevearc/conform.nvim/commit/0ff1b7d32fd3e8df194ca5ebec1dab9c61fb9911))
* **swiftformat:** range formatting support and add cwd ([#326](https://github.com/stevearc/conform.nvim/issues/326)) ([db2c697](https://github.com/stevearc/conform.nvim/commit/db2c697fe8302f0328b50b480204be1b577a1e2f))
## [5.3.0](https://github.com/stevearc/conform.nvim/compare/v5.2.1...v5.3.0) (2024-02-20)
### Features
* add awk formatter ([#286](https://github.com/stevearc/conform.nvim/issues/286)) ([338c307](https://github.com/stevearc/conform.nvim/commit/338c3070ae7f7028185ae6123541c2ca71cfe7ff))
* add biome-check formatter ([#287](https://github.com/stevearc/conform.nvim/issues/287)) ([5a71b60](https://github.com/stevearc/conform.nvim/commit/5a71b6064ec6ecf0fff91af67e95200aae9e9562))
* add fantomas formatter ([#302](https://github.com/stevearc/conform.nvim/issues/302)) ([0d99714](https://github.com/stevearc/conform.nvim/commit/0d997149a0472ab811bcfdca5dc45d9db483f949))
* Add reorder-python-imports formatter ([#284](https://github.com/stevearc/conform.nvim/issues/284)) ([9a07f60](https://github.com/stevearc/conform.nvim/commit/9a07f60f7499cdc76ed40af62bb9a50ac928d7d2))
* add ReScript formatter ([#293](https://github.com/stevearc/conform.nvim/issues/293)) ([a34b66f](https://github.com/stevearc/conform.nvim/commit/a34b66f9a4a8f4fb8e270ebfa9c8836fdb8381c1))
* add terragrunt_hclfmt formatter ([#278](https://github.com/stevearc/conform.nvim/issues/278)) ([375258f](https://github.com/stevearc/conform.nvim/commit/375258f1fe1500f175d7135aef1dc6a87dbd83b2))
* add twig-cs-fixer ([#304](https://github.com/stevearc/conform.nvim/issues/304)) ([766812b](https://github.com/stevearc/conform.nvim/commit/766812b0e830c2e40613f99f89102d8840431c6a))
* add yq formatter ([#288](https://github.com/stevearc/conform.nvim/issues/288)) ([15c4a02](https://github.com/stevearc/conform.nvim/commit/15c4a0273bb5468004bb46f632dc5326bc5634d7))
### Bug Fixes
* `swift_format` doesn't respect `.swift-format` file ([#283](https://github.com/stevearc/conform.nvim/issues/283)) ([4588008](https://github.com/stevearc/conform.nvim/commit/4588008a7c5b57fbff97fdfb529c059235cdc7ee))
* set a cwd for biome ([#282](https://github.com/stevearc/conform.nvim/issues/282)) ([03feeb5](https://github.com/stevearc/conform.nvim/commit/03feeb5024a4b44754d63dec55b79b8133a8ea9f))
## [5.2.1](https://github.com/stevearc/conform.nvim/compare/v5.2.0...v5.2.1) (2024-01-21)
### Bug Fixes
* handle windows line endings ([#274](https://github.com/stevearc/conform.nvim/issues/274)) ([9a785eb](https://github.com/stevearc/conform.nvim/commit/9a785eb8f0199ac47ce8bb9e9b6103de5ad8e3a7))
## [5.2.0](https://github.com/stevearc/conform.nvim/compare/v5.1.0...v5.2.0) (2024-01-16)
### Features
* add cue_fmt formatter ([#265](https://github.com/stevearc/conform.nvim/issues/265)) ([03de11a](https://github.com/stevearc/conform.nvim/commit/03de11a0dcf686fda58d64a895483e284dd0c5b6))
* Add dry_run option and report if buffer was/would be changed by formatters ([#273](https://github.com/stevearc/conform.nvim/issues/273)) ([e0276bb](https://github.com/stevearc/conform.nvim/commit/e0276bb32e9b33ece11fef2a5cfc8fb2108df0df))
* add opa_fmt formatter ([#267](https://github.com/stevearc/conform.nvim/issues/267)) ([a4e84d5](https://github.com/stevearc/conform.nvim/commit/a4e84d56d5959dae685c5e22db202cd86b5b322b))
* add xmllint formatter ([#259](https://github.com/stevearc/conform.nvim/issues/259)) ([c50ba4b](https://github.com/stevearc/conform.nvim/commit/c50ba4baad90f02840cc31ee745b09078b7a1777))
* **formatexpr:** don't require LSP range formatting if operating on whole file ([#272](https://github.com/stevearc/conform.nvim/issues/272)) ([47ceff6](https://github.com/stevearc/conform.nvim/commit/47ceff644e9d00872f410be374cc973eefa20ba9))
### Bug Fixes
* **black:** formatting excluded files results in blank buffer ([#254](https://github.com/stevearc/conform.nvim/issues/254)) ([c4b2efb](https://github.com/stevearc/conform.nvim/commit/c4b2efb8aee4af0ef179a9b49ba401de3c4ef5d2))
* copy input parameters for will_fallback_lsp ([ad347d7](https://github.com/stevearc/conform.nvim/commit/ad347d70e66737a8b9d62c19df1c0e2c5b2cd008))
* injected formatter works on nightly ([#270](https://github.com/stevearc/conform.nvim/issues/270)) ([229e9ab](https://github.com/stevearc/conform.nvim/commit/229e9ab5d6e90bc5e6d24141dce3cc28ba95293a))
* LSP deprecated method warning on nvim nightly ([75e7c5c](https://github.com/stevearc/conform.nvim/commit/75e7c5c7eb5fbd53f8b12dc420b31ec70770b231))
* pass explicit bufnr to avoid race conditions ([#260](https://github.com/stevearc/conform.nvim/issues/260)) ([a8e3935](https://github.com/stevearc/conform.nvim/commit/a8e39359814b7b5df5fac7423b4dc93826d64464))
* set a cwd for djlint ([#264](https://github.com/stevearc/conform.nvim/issues/264)) ([0802406](https://github.com/stevearc/conform.nvim/commit/08024063232a7bd38ecdfaf89f06162a5ba2df91))
* set a cwd for dprint ([#263](https://github.com/stevearc/conform.nvim/issues/263)) ([e6c1353](https://github.com/stevearc/conform.nvim/commit/e6c135338257f69c018e8351a6e5f63683f86318))
## [5.1.0](https://github.com/stevearc/conform.nvim/compare/v5.0.0...v5.1.0) (2023-12-26)
### Features
* add fnlfmt formatter ([#247](https://github.com/stevearc/conform.nvim/issues/247)) ([af6643a](https://github.com/stevearc/conform.nvim/commit/af6643afa10e17c0228da97c84d4c32f144a6ad3))
* ConformInfo shows path to executable ([#244](https://github.com/stevearc/conform.nvim/issues/244)) ([fb9b050](https://github.com/stevearc/conform.nvim/commit/fb9b0500270ba05b89cc27cd8b7762443bcfae22))
* **prettier:** add `options` for configuring prettier parser based on filetype and extension ([#241](https://github.com/stevearc/conform.nvim/issues/241)) ([8df1bed](https://github.com/stevearc/conform.nvim/commit/8df1bed7b8de9cf40476996fb5ab73ed667aed35))
### Bug Fixes
* crash in error handling ([4185249](https://github.com/stevearc/conform.nvim/commit/41852493b5abd7b5a0fd61ff007994c777a08ec9))
* **formatexpr:** does not fallback to the built-in formatexpr ([#238](https://github.com/stevearc/conform.nvim/issues/238)) ([48bc999](https://github.com/stevearc/conform.nvim/commit/48bc9996ebfe90e7766f46338360f75fd6ecb174))
* **injected:** code block at end of markdown file ([9245b61](https://github.com/stevearc/conform.nvim/commit/9245b616d1edb159775a0832c03324bf92884494))
* **injected:** handle inline injections ([#251](https://github.com/stevearc/conform.nvim/issues/251)) ([f245cca](https://github.com/stevearc/conform.nvim/commit/f245cca8ad42c9d344b53a18c3fc1a3c6724c2d4))
* **prettier:** use correct prettier executable on windows ([#236](https://github.com/stevearc/conform.nvim/issues/236)) ([7396fc0](https://github.com/stevearc/conform.nvim/commit/7396fc0208539e2bd70e3e446f27529e28dba12b))
* **rubocop:** pass --server for faster execution ([#246](https://github.com/stevearc/conform.nvim/issues/246)) ([0ec6edd](https://github.com/stevearc/conform.nvim/commit/0ec6edd67689e8df6726b83333106bcec13c36d4))
## [5.0.0](https://github.com/stevearc/conform.nvim/compare/v4.3.0...v5.0.0) (2023-12-07)
### ⚠ BREAKING CHANGES
* formatter config functions take self as first argument ([#233](https://github.com/stevearc/conform.nvim/issues/233))
### Features
* add asmfmt ([#239](https://github.com/stevearc/conform.nvim/issues/239)) ([a5ef494](https://github.com/stevearc/conform.nvim/commit/a5ef4943f6382f36a5a8d6e16eb0a0c60af5e7a5))
* add joker for clojure formatting ([#240](https://github.com/stevearc/conform.nvim/issues/240)) ([6b13100](https://github.com/stevearc/conform.nvim/commit/6b1310014ceec5752fd5859f9cc62ef7c93d72b2))
### Code Refactoring
* formatter config functions take self as first argument ([#233](https://github.com/stevearc/conform.nvim/issues/233)) ([659838f](https://github.com/stevearc/conform.nvim/commit/659838ff4244ef6af095395ce68aaaf99fa8e696))
## [4.3.0](https://github.com/stevearc/conform.nvim/compare/v4.2.0...v4.3.0) (2023-12-07)
### Features
* add `auto-optional` ([#196](https://github.com/stevearc/conform.nvim/issues/196)) ([9156364](https://github.com/stevearc/conform.nvim/commit/9156364c23cff19734a0055377321c22b1484c0f))
* add `typos` ([#214](https://github.com/stevearc/conform.nvim/issues/214)) ([d86c186](https://github.com/stevearc/conform.nvim/commit/d86c186ba910d28a6266c4d6210578dca984f3e3))
* add autocorrect ([#223](https://github.com/stevearc/conform.nvim/issues/223)) ([cd81d21](https://github.com/stevearc/conform.nvim/commit/cd81d215d39b16186186a1539c71b48705bb081d))
* add beancount formatter ([#212](https://github.com/stevearc/conform.nvim/issues/212)) ([c0924a6](https://github.com/stevearc/conform.nvim/commit/c0924a61e079d94f0be40da2d4188210c6e4ffea))
* add cbfmt ([#198](https://github.com/stevearc/conform.nvim/issues/198)) ([aa36bc0](https://github.com/stevearc/conform.nvim/commit/aa36bc05563d5390a2ef67956d72560048acdc2e))
* add fourmolu support ([#209](https://github.com/stevearc/conform.nvim/issues/209)) ([e688864](https://github.com/stevearc/conform.nvim/commit/e688864883aa4f468cc73a4c1db661c7c94addc4))
* add jsonnetfmt ([#230](https://github.com/stevearc/conform.nvim/issues/230)) ([769dde8](https://github.com/stevearc/conform.nvim/commit/769dde8ddccf8338c68da706e46fd2fb004e6455))
* add packer formatter ([#202](https://github.com/stevearc/conform.nvim/issues/202)) ([a0cabaa](https://github.com/stevearc/conform.nvim/commit/a0cabaaf5c94137c8dc34043244a34b552860af6))
* add pangu ([#188](https://github.com/stevearc/conform.nvim/issues/188)) ([f0780e2](https://github.com/stevearc/conform.nvim/commit/f0780e2231df2e4751e31db32c1545872412ba75))
* add phpinsights ([#170](https://github.com/stevearc/conform.nvim/issues/170)) ([5235405](https://github.com/stevearc/conform.nvim/commit/5235405cc6d4ac98dc9008ffa850038e3325bbce))
* add styler formatter for R ([#184](https://github.com/stevearc/conform.nvim/issues/184)) ([6afc64e](https://github.com/stevearc/conform.nvim/commit/6afc64e9f36cbae35c2a8b6852d0b91c9807a72a))
* add support for buildifier ([#216](https://github.com/stevearc/conform.nvim/issues/216)) ([e478834](https://github.com/stevearc/conform.nvim/commit/e478834227e0958e21a54f31c9cd896a3a8bdde0))
* add support for sqlfluff ([#213](https://github.com/stevearc/conform.nvim/issues/213)) ([e8c8683](https://github.com/stevearc/conform.nvim/commit/e8c8683a00fb932dfe669e1c96832da12b8054bd))
### Bug Fixes
* **biome:** perform formatting over stdin ([#220](https://github.com/stevearc/conform.nvim/issues/220)) ([eddd643](https://github.com/stevearc/conform.nvim/commit/eddd6431370814caacec1d1e3c7d6d95d41b133d))
* **biome:** use binary from node_modules ([#226](https://github.com/stevearc/conform.nvim/issues/226)) ([5bf1405](https://github.com/stevearc/conform.nvim/commit/5bf1405fd234d469243ea6f394e0aeec9ea53bd8))
* injected formatter adds language to file extension ([#199](https://github.com/stevearc/conform.nvim/issues/199)) ([e2b889e](https://github.com/stevearc/conform.nvim/commit/e2b889e26586acf30dda7b4a5c3f1a063bc18f18))
* injected parser shouldn't format combined injections ([#205](https://github.com/stevearc/conform.nvim/issues/205)) ([eeef888](https://github.com/stevearc/conform.nvim/commit/eeef88849fb644d84a5856524adf10d0ad2d7cbe))
* invalid prettier configuration in last commit ([e8ac7f1](https://github.com/stevearc/conform.nvim/commit/e8ac7f1a9a3973ecce6942b2f26d16e65902aa70))
* range format method for async formatters and injected ([a36c68d](https://github.com/stevearc/conform.nvim/commit/a36c68d2cd551e49883ddb2492c178d915567f58))
* respect excluded-files-config from `typos.toml` ([#219](https://github.com/stevearc/conform.nvim/issues/219)) ([db9da1a](https://github.com/stevearc/conform.nvim/commit/db9da1aa57e8be683ada1b1e5f8129c28d2576eb))
* show more logs in ConformInfo when log level is TRACE ([0963118](https://github.com/stevearc/conform.nvim/commit/0963118e60e0895e2e4842aeffc67cdf9e2bcd10))
* various fixes for the `injected` formatter ([#235](https://github.com/stevearc/conform.nvim/issues/235)) ([07fcbfc](https://github.com/stevearc/conform.nvim/commit/07fcbfc13490786f5983bce3f404643fcfd83775))
## [4.2.0](https://github.com/stevearc/conform.nvim/compare/v4.1.0...v4.2.0) (2023-11-09)
### Features
* add typstfmt ([#180](https://github.com/stevearc/conform.nvim/issues/180)) ([b1f1194](https://github.com/stevearc/conform.nvim/commit/b1f1194338c96d385ec6370ac734ab63c0289776))
### Bug Fixes
* catch jobstart errors ([#183](https://github.com/stevearc/conform.nvim/issues/183)) ([dcbe650](https://github.com/stevearc/conform.nvim/commit/dcbe650bd4811cefe5a885fafb6309c7d592bda6))
* injected formatter not working ([#187](https://github.com/stevearc/conform.nvim/issues/187)) ([68abada](https://github.com/stevearc/conform.nvim/commit/68abada5a348f448eabdbd7d71884c195969484f))
* nonzero exit code on :wq ([#176](https://github.com/stevearc/conform.nvim/issues/176)) ([161d95b](https://github.com/stevearc/conform.nvim/commit/161d95bfbb1ad1a2b89ba2ea75ca1b5e012a111e))
* rename `astgrep` to `ast-grep` ([#178](https://github.com/stevearc/conform.nvim/issues/178)) ([bfa69a9](https://github.com/stevearc/conform.nvim/commit/bfa69a942e19159d3a3e958a5be85cb7cdae19a7))
## [4.1.0](https://github.com/stevearc/conform.nvim/compare/v4.0.0...v4.1.0) (2023-11-05)
### Features
* add `ast-grep` ([#177](https://github.com/stevearc/conform.nvim/issues/177)) ([fa3cf1c](https://github.com/stevearc/conform.nvim/commit/fa3cf1c40716492fd0df0c3dedd54c8018f9ea70))
* add CSharpier ([#165](https://github.com/stevearc/conform.nvim/issues/165)) ([b2368ff](https://github.com/stevearc/conform.nvim/commit/b2368ff18a9dd9452170d3a6f41b1f872ae5d0b2))
* add markdownlint-cli2 ([#171](https://github.com/stevearc/conform.nvim/issues/171)) ([9bb3a94](https://github.com/stevearc/conform.nvim/commit/9bb3a940389dda796192a477a016069472692526))
* add mdslw markdown formatter ([#175](https://github.com/stevearc/conform.nvim/issues/175)) ([369c7fe](https://github.com/stevearc/conform.nvim/commit/369c7fe690b3fec0ecdd7c17faeebf3f8113a0f5))
* add pretty-php ([#161](https://github.com/stevearc/conform.nvim/issues/161)) ([4653408](https://github.com/stevearc/conform.nvim/commit/4653408d5c270168e31ffd0585d1cf2de27fc827))
* add puppet-lint formatter ([#153](https://github.com/stevearc/conform.nvim/issues/153)) ([0219648](https://github.com/stevearc/conform.nvim/commit/0219648cd9a2bafc13fda64903e49fda5db0016b))
* add tlint ([#162](https://github.com/stevearc/conform.nvim/issues/162)) ([2538784](https://github.com/stevearc/conform.nvim/commit/253878436e2b6d73dfd91ccf0ac12d04cc683d34))
* add usort ([#167](https://github.com/stevearc/conform.nvim/issues/167)) ([f7766d2](https://github.com/stevearc/conform.nvim/commit/f7766d2fbe23f0f22a3db1513beba7d03a8dc261))
* allow formatters_by_ft to be a function ([#174](https://github.com/stevearc/conform.nvim/issues/174)) ([0bbe838](https://github.com/stevearc/conform.nvim/commit/0bbe83830be5a07a1161bb1a23d7280310656177))
* gn build file format cmd ([#155](https://github.com/stevearc/conform.nvim/issues/155)) ([3716927](https://github.com/stevearc/conform.nvim/commit/37169273a0776752a3c01cbe01227e275b642b89))
* zprint formatter for clojure ([#146](https://github.com/stevearc/conform.nvim/issues/146)) ([2800552](https://github.com/stevearc/conform.nvim/commit/280055248661a4fc7b692db2d5ee80a465ebb577))
### Bug Fixes
* **formatexpr:** use default formatexpr if no formatters or LSP clients ([#55](https://github.com/stevearc/conform.nvim/issues/55)) ([278bcd8](https://github.com/stevearc/conform.nvim/commit/278bcd8bf2017e187e963b515017341fdd87fe2f))
* **rubyfmt:** exit code 1 should not be a success ([#157](https://github.com/stevearc/conform.nvim/issues/157)) ([e4ecb6e](https://github.com/stevearc/conform.nvim/commit/e4ecb6e8ed3163c86d7e647f1dc3d94de77ca687))
## [4.0.0](https://github.com/stevearc/conform.nvim/compare/v3.10.0...v4.0.0) (2023-10-16)
### ⚠ BREAKING CHANGES
* merge configs in conform.formatters with defaults ([#140](https://github.com/stevearc/conform.nvim/issues/140))
### Features
* add blade-formatter ([#136](https://github.com/stevearc/conform.nvim/issues/136)) ([f90b222](https://github.com/stevearc/conform.nvim/commit/f90b2229c481252c43a71a004972b473952c1c3c))
* add blue formatter ([#142](https://github.com/stevearc/conform.nvim/issues/142)) ([a97ddff](https://github.com/stevearc/conform.nvim/commit/a97ddfff2d701245ad49daf24ef436a50ee72a50))
* Add config for laravel/pint ([#144](https://github.com/stevearc/conform.nvim/issues/144)) ([43414c8](https://github.com/stevearc/conform.nvim/commit/43414c8ebd22921f44806fb9612a2f4f376419af))
* add goimports-reviser ([#143](https://github.com/stevearc/conform.nvim/issues/143)) ([3fcebb0](https://github.com/stevearc/conform.nvim/commit/3fcebb0001e6d5b943dbb36fe5c035e3ef8c3509))
* add ktlint ([#137](https://github.com/stevearc/conform.nvim/issues/137)) ([8b02f47](https://github.com/stevearc/conform.nvim/commit/8b02f478fefe93f76a7f57c983418744287f4c69))
* add rufo support ([#132](https://github.com/stevearc/conform.nvim/issues/132)) ([aca5d30](https://github.com/stevearc/conform.nvim/commit/aca5d307232a22600bd0ab57571a8b6e2dc9a12c))
* merge configs in conform.formatters with defaults ([#140](https://github.com/stevearc/conform.nvim/issues/140)) ([7027ebb](https://github.com/stevearc/conform.nvim/commit/7027ebbd772e2d3593f7dd566dea06d2d20622ee))
* support for rubyfmt ([#139](https://github.com/stevearc/conform.nvim/issues/139)) ([ae33777](https://github.com/stevearc/conform.nvim/commit/ae337775e46804a8347ea7c3da92be5587e5850e))
### Bug Fixes
* prevent format-after-save autocmd from running on invalid buffers ([80f2f70](https://github.com/stevearc/conform.nvim/commit/80f2f70740431b07d725cc66f63abbfd66aaae6d))
* prevent format-on-save autocmd from running on invalid buffers ([#128](https://github.com/stevearc/conform.nvim/issues/128)) ([69ee0bf](https://github.com/stevearc/conform.nvim/commit/69ee0bfde439e30344ae57de6227cb3a035dd0bb))
* **shellcheck:** support filenames with spaces ([#135](https://github.com/stevearc/conform.nvim/issues/135)) ([64a8956](https://github.com/stevearc/conform.nvim/commit/64a89568925c3f62b7ecdcf60b612001d2749eb1))
## [3.10.0](https://github.com/stevearc/conform.nvim/compare/v3.9.0...v3.10.0) (2023-10-09)
### Features
* add easy-coding-standard ([#121](https://github.com/stevearc/conform.nvim/issues/121)) ([e758196](https://github.com/stevearc/conform.nvim/commit/e75819642c36810a55a7235b6b5e16a5ce896ed3))
* add fixjson ([#126](https://github.com/stevearc/conform.nvim/issues/126)) ([280360e](https://github.com/stevearc/conform.nvim/commit/280360eb019fe52433a68b7918790c9187076865))
* add justfile formatter ([#114](https://github.com/stevearc/conform.nvim/issues/114)) ([4c91b52](https://github.com/stevearc/conform.nvim/commit/4c91b5270a6f741850de2eef3a804ff1dc6ec3ee))
* errors do not stop formatting early ([a94f686](https://github.com/stevearc/conform.nvim/commit/a94f686986631d5b97bd75b3877813c39de55c47))
* expose configuration options for injected formatter ([#118](https://github.com/stevearc/conform.nvim/issues/118)) ([ba1ca20](https://github.com/stevearc/conform.nvim/commit/ba1ca20bb5f89a8bdd94b268411263275550843a))
### Bug Fixes
* **biome:** do not use stdin due to biome bug ([#120](https://github.com/stevearc/conform.nvim/issues/120)) ([e5ed063](https://github.com/stevearc/conform.nvim/commit/e5ed0635d9aa66c6c2f7eac3235e6a8eb2de0653))
* catch and fix more cases of bad-behaving LSP formatters ([#119](https://github.com/stevearc/conform.nvim/issues/119)) ([9bd1690](https://github.com/stevearc/conform.nvim/commit/9bd169029ac7fac5d0b3899a47556549d113a4c2))
* handle one failure mode with range formatting ([#123](https://github.com/stevearc/conform.nvim/issues/123)) ([b5a2da9](https://github.com/stevearc/conform.nvim/commit/b5a2da9410d56bd7bc229d0185ad427a966cac50))
* injected formatter handles markdown code blocks in blockquotes ([#117](https://github.com/stevearc/conform.nvim/issues/117)) ([0bffab5](https://github.com/stevearc/conform.nvim/commit/0bffab53672d62cbfe8fc450e78757982e656318))
* move justfile formatter to correct directory ([8217144](https://github.com/stevearc/conform.nvim/commit/8217144491e8aba3a24828a71ee768b007a2ec43))
## [3.9.0](https://github.com/stevearc/conform.nvim/compare/v3.8.0...v3.9.0) (2023-10-04)
### Features
* add phpcbf ([#103](https://github.com/stevearc/conform.nvim/issues/103)) ([db5af4b](https://github.com/stevearc/conform.nvim/commit/db5af4b04e5d61236a142ab78ec3f9416aab848c))
* gci formatter for Go ([#109](https://github.com/stevearc/conform.nvim/issues/109)) ([362e4ec](https://github.com/stevearc/conform.nvim/commit/362e4ec709d241e47d6093dd4b030125ce214cfa))
### Bug Fixes
* format on save autocmds ignore nonstandard buffers ([cb87cab](https://github.com/stevearc/conform.nvim/commit/cb87cab7a6baa6192bf13123c2a5af6fd059d62c))
* injected formatter silent failure on nvim nightly ([#100](https://github.com/stevearc/conform.nvim/issues/100)) ([0156beb](https://github.com/stevearc/conform.nvim/commit/0156beb8397169d7ec18d4f4ea8dd002ee9bcc96))
* phpcbf invalid stdin-path arguments ([#108](https://github.com/stevearc/conform.nvim/issues/108)) ([ce427b0](https://github.com/stevearc/conform.nvim/commit/ce427b03b9cc428ee7a64cb77487ed19efec202d))
* support for mix format ([#107](https://github.com/stevearc/conform.nvim/issues/107)) ([6836930](https://github.com/stevearc/conform.nvim/commit/6836930ed5a0ec6e8bb531116c62cc10f475c298))
## [3.8.0](https://github.com/stevearc/conform.nvim/compare/v3.7.2...v3.8.0) (2023-10-02)
### Features
* add 'google-java-format' formatter ([#99](https://github.com/stevearc/conform.nvim/issues/99)) ([e887736](https://github.com/stevearc/conform.nvim/commit/e8877369df244515af20e18bf1307632fc638d2a))
* add standardrb ([#91](https://github.com/stevearc/conform.nvim/issues/91)) ([37d0367](https://github.com/stevearc/conform.nvim/commit/37d036704a100ef6e6457be45b4dfc2f8e429572))
* metatable to make accessing formatters a bit easier ([#89](https://github.com/stevearc/conform.nvim/issues/89)) ([d8170c1](https://github.com/stevearc/conform.nvim/commit/d8170c14db0f3c90fa799db3bca29d3fb3c089c3))
### Bug Fixes
* alternations follow notification rules ([3f89275](https://github.com/stevearc/conform.nvim/commit/3f8927532bc8ce4fc4b5b75eab1bf8f1fc83f6b9))
* error handling for injected formatter ([f7b82fb](https://github.com/stevearc/conform.nvim/commit/f7b82fb395a4cd636a26ee879b5fd7690612e5a9))
* injected formatter doesn't have interruption errors ([af3d59d](https://github.com/stevearc/conform.nvim/commit/af3d59da20d2bc37933df409f8fc9e24ec15e066))
* injected formatter operates on input lines ([501319e](https://github.com/stevearc/conform.nvim/commit/501319eed2ff26f856ea91b5456bef1d00f77df7))
## [3.7.2](https://github.com/stevearc/conform.nvim/compare/v3.7.1...v3.7.2) (2023-09-29)
### Bug Fixes
* injected formatter hangs on empty file ([671186e](https://github.com/stevearc/conform.nvim/commit/671186e4b29e26ee9fc0f1df4e529134bc334666))
* injected formatter preserves indentation of code blocks ([470d419](https://github.com/stevearc/conform.nvim/commit/470d41988e83913df428c9e832c15b8bb84301ad))
* lsp format calls method from wrong util file ([df69e3e](https://github.com/stevearc/conform.nvim/commit/df69e3ee61e1a0cbb960c8466ace74c696cc7830))
## [3.7.1](https://github.com/stevearc/conform.nvim/compare/v3.7.0...v3.7.1) (2023-09-29)
### Bug Fixes
* format_after_save blocks on exit for lsp formatting ([0c52ee2](https://github.com/stevearc/conform.nvim/commit/0c52ee248245f40610a4957b6bc9515ce1fd9ab6))
## [3.7.0](https://github.com/stevearc/conform.nvim/compare/v3.6.0...v3.7.0) (2023-09-29)
### Features
* add 'JavaScript Standard Style' formatter ([#82](https://github.com/stevearc/conform.nvim/issues/82)) ([971fa7f](https://github.com/stevearc/conform.nvim/commit/971fa7f2e4005454ce141ca8ee0462a3c34d2922))
* add darker ([#80](https://github.com/stevearc/conform.nvim/issues/80)) ([e359687](https://github.com/stevearc/conform.nvim/commit/e359687e3684452ff45d7a5f1a59cd40b0bfa320))
* format injected languages ([#83](https://github.com/stevearc/conform.nvim/issues/83)) ([a5526fb](https://github.com/stevearc/conform.nvim/commit/a5526fb2ee963cf426ab6d6ba1f3eb82887b1c22))
### Bug Fixes
* format_after_save autocmd blocks nvim exit until complete ([388d6e2](https://github.com/stevearc/conform.nvim/commit/388d6e2440bccded26d5e67ce6a7039c1953ae70))
* only show "no formatters" warning if formatters passed in explicitly ([#85](https://github.com/stevearc/conform.nvim/issues/85)) ([45edf94](https://github.com/stevearc/conform.nvim/commit/45edf9462d06db0809d4a4a7afc6b7896b63fa35))
## [3.6.0](https://github.com/stevearc/conform.nvim/compare/v3.5.0...v3.6.0) (2023-09-27)
### Features
* add `markdown-toc` ([#75](https://github.com/stevearc/conform.nvim/issues/75)) ([de58b06](https://github.com/stevearc/conform.nvim/commit/de58b06d434047c6ecd5ec2d52877335d37b05fd))
* Add support for php-cs-fixer ([#78](https://github.com/stevearc/conform.nvim/issues/78)) ([e691eca](https://github.com/stevearc/conform.nvim/commit/e691ecaf41139a68ccb79fde824cb534ca11abd2))
* add templ support ([#73](https://github.com/stevearc/conform.nvim/issues/73)) ([28ecd5c](https://github.com/stevearc/conform.nvim/commit/28ecd5cf9132213417bff41d79477354cb81f50c))
* another utility for extending formatter arguments ([aada09c](https://github.com/stevearc/conform.nvim/commit/aada09c9cfea38187966ce47f34b9008e1104d21))
* new utility function ([9e1fcd5](https://github.com/stevearc/conform.nvim/commit/9e1fcd5cafc42b5dfbe2e942ddbece0dada4e1d0))
### Bug Fixes
* rubocop succeeds even if some errors are not autocorrected ([#74](https://github.com/stevearc/conform.nvim/issues/74)) ([34daf23](https://github.com/stevearc/conform.nvim/commit/34daf23415e9d212697f79506039498db2b35240))
## [3.5.0](https://github.com/stevearc/conform.nvim/compare/v3.4.1...v3.5.0) (2023-09-22)
### Features
* add `bibtex-tidy` ([#69](https://github.com/stevearc/conform.nvim/issues/69)) ([f5e7f84](https://github.com/stevearc/conform.nvim/commit/f5e7f84fb27f05d9a3f3893634cbb6c7f7f89056))
* add dprint ([#71](https://github.com/stevearc/conform.nvim/issues/71)) ([0e2c97a](https://github.com/stevearc/conform.nvim/commit/0e2c97ab640f14f7da92278c731879efcb11f563))
* add mdformat ([#68](https://github.com/stevearc/conform.nvim/issues/68)) ([4a4c927](https://github.com/stevearc/conform.nvim/commit/4a4c92715b174b847ba0fcdccf9dfea71c8ed33e))
* add ruff formatter and improve ruff root finding ([#66](https://github.com/stevearc/conform.nvim/issues/66)) ([44e9e82](https://github.com/stevearc/conform.nvim/commit/44e9e8292d552f9a35498612a93dff934cc8802f))
### Bug Fixes
* `stylelint` and `markdownlint` when there are non-autofixable errors ([#70](https://github.com/stevearc/conform.nvim/issues/70)) ([5454fb5](https://github.com/stevearc/conform.nvim/commit/5454fb5a72a957b550fb7a0f5c4e84684c529920))
## [3.4.1](https://github.com/stevearc/conform.nvim/compare/v3.4.0...v3.4.1) (2023-09-19)
### Bug Fixes
* range formatting for LSP formatters ([#63](https://github.com/stevearc/conform.nvim/issues/63)) ([52280f0](https://github.com/stevearc/conform.nvim/commit/52280f032653e98dd6ecbb61488afcca39671964))
## [3.4.0](https://github.com/stevearc/conform.nvim/compare/v3.3.0...v3.4.0) (2023-09-18)
### Features
* add `squeeze_blanks` ([#62](https://github.com/stevearc/conform.nvim/issues/62)) ([3fa2a7b](https://github.com/stevearc/conform.nvim/commit/3fa2a7be8d91c3f0d7b79dde70d7849518cdc5bf))
* make lsp_fallback behavior more intuitive ([#59](https://github.com/stevearc/conform.nvim/issues/59)) ([1abbb82](https://github.com/stevearc/conform.nvim/commit/1abbb82bb8e519e652d8b31b12a311872e9090d1))
## [3.3.0](https://github.com/stevearc/conform.nvim/compare/v3.2.0...v3.3.0) (2023-09-17)
### Features
* '_' filetype to define fallback formatters ([a589750](https://github.com/stevearc/conform.nvim/commit/a589750635fcc5bb52c7e572cd853446c2c63855))
* add GNU/BSD indent ([#54](https://github.com/stevearc/conform.nvim/issues/54)) ([5abf6c2](https://github.com/stevearc/conform.nvim/commit/5abf6c2c89ff6ed7d17285ec1da759013463bfc7))
* Add rustywind formatter ([#56](https://github.com/stevearc/conform.nvim/issues/56)) ([a839ed1](https://github.com/stevearc/conform.nvim/commit/a839ed1384c21cbd8861f2850b552a4db10ead2f))
* add shellcheck ([#44](https://github.com/stevearc/conform.nvim/issues/44)) ([508ec8a](https://github.com/stevearc/conform.nvim/commit/508ec8a899e039a56f9110011125ab56284db1fa))
* alejandra formatter ([#52](https://github.com/stevearc/conform.nvim/issues/52)) ([e6552b5](https://github.com/stevearc/conform.nvim/commit/e6552b5c9b3a2b12bacb476b00c80c736b9f7963))
* allow running commands in a shell ([#49](https://github.com/stevearc/conform.nvim/issues/49)) ([fbb18a5](https://github.com/stevearc/conform.nvim/commit/fbb18a5b92e2f11aaaef379d74d4a1132a138cb3))
* format_on_save functions can return a callback as the second value ([1a568c6](https://github.com/stevearc/conform.nvim/commit/1a568c66f16650290fffcfbf5aefebe2d8254b83))
* provide a formatexpr ([#55](https://github.com/stevearc/conform.nvim/issues/55)) ([aa38b05](https://github.com/stevearc/conform.nvim/commit/aa38b05575dab57b813ddcd14780f65ff20a6d49))
* utility function to extend the built-in formatter args ([#50](https://github.com/stevearc/conform.nvim/issues/50)) ([cb5f939](https://github.com/stevearc/conform.nvim/commit/cb5f939ab27b2c2ef2e1d4ac6fe16c5ba6332f39))
### Bug Fixes
* `q` keymap in ConformInfo and `codespell` exit codes ([#53](https://github.com/stevearc/conform.nvim/issues/53)) ([d3fe431](https://github.com/stevearc/conform.nvim/commit/d3fe43167c7d96036c8c037ef1b4e03b448efbe7))
* ConformInfo shows available LSP formatters ([3aa2fd5](https://github.com/stevearc/conform.nvim/commit/3aa2fd5f828f8fcabd65605a41953aba1f0f5cb0))
* LSP formatter respects quiet = true ([5e4d258](https://github.com/stevearc/conform.nvim/commit/5e4d258f8eba4090b9a515ee9b77d8647394b2cd))
* unify timeout error message format with LSP ([0d963f8](https://github.com/stevearc/conform.nvim/commit/0d963f82add9ca4faf49b54fc28f57038742ded3))
* use non-deprecated health report functions if available ([#48](https://github.com/stevearc/conform.nvim/issues/48)) ([b436902](https://github.com/stevearc/conform.nvim/commit/b43690264ebcb152365d5b46faa6561f12ea062a))
## [3.2.0](https://github.com/stevearc/conform.nvim/compare/v3.1.0...v3.2.0) (2023-09-14)
### Features
* add `markdownlint`, `stylelint`, `codespell`, and `biome` ([#45](https://github.com/stevearc/conform.nvim/issues/45)) ([580ab18](https://github.com/stevearc/conform.nvim/commit/580ab1880e740f4aebbc72a05350461f3cdef53d))
* add buf as protobuf linter ([#43](https://github.com/stevearc/conform.nvim/issues/43)) ([2b73887](https://github.com/stevearc/conform.nvim/commit/2b73887fd75e1f6efc352cec6bd7e39157c3732e))
* add deno fmt ([#46](https://github.com/stevearc/conform.nvim/issues/46)) ([db7461a](https://github.com/stevearc/conform.nvim/commit/db7461afcf751023adeb346d833f2e5d40a420c4))
* add djlint ([#47](https://github.com/stevearc/conform.nvim/issues/47)) ([ead0257](https://github.com/stevearc/conform.nvim/commit/ead025784c8e31b8e45016e620c2f17a13ff741a))
* latexindent ([#42](https://github.com/stevearc/conform.nvim/issues/42)) ([502a358](https://github.com/stevearc/conform.nvim/commit/502a3583663ede11c8db1e9980db342b117d79f2))
* ruff ([#41](https://github.com/stevearc/conform.nvim/issues/41)) ([fdc4a0f](https://github.com/stevearc/conform.nvim/commit/fdc4a0f05c21012f2445a993ebdad700380dcfbf))
### Bug Fixes
* extra trailing newline for LSP formatters that replace entire file ([e18cdaf](https://github.com/stevearc/conform.nvim/commit/e18cdaf529b94465592d0c2afe1b62bc26155070))
## [3.1.0](https://github.com/stevearc/conform.nvim/compare/v3.0.0...v3.1.0) (2023-09-13)
### Features
* format_on_save and format_after_save can be functions ([dd5b2f2](https://github.com/stevearc/conform.nvim/commit/dd5b2f2f7ca01c2f28239cbbc7f97e6f9024cd94))
### Bug Fixes
* modify diff calculation to handle end-of-file newlines better ([#35](https://github.com/stevearc/conform.nvim/issues/35)) ([00a5288](https://github.com/stevearc/conform.nvim/commit/00a528818463b10d84699b2e0f4a960d5a4aeb5c))
## [3.0.0](https://github.com/stevearc/conform.nvim/compare/v2.3.0...v3.0.0) (2023-09-08)
### ⚠ BREAKING CHANGES
* remove run_all_formatters config option
### Features
* add beautysh, taplo, trim_newlines and trim_whitespace ([#29](https://github.com/stevearc/conform.nvim/issues/29)) ([37a2d65](https://github.com/stevearc/conform.nvim/commit/37a2d65bd2ee41540cc426d2cffef6d6f8648357))
* format() can always fall back to LSP formatting ([c3028b3](https://github.com/stevearc/conform.nvim/commit/c3028b327bc44335cc2b5c3014cd6d5c12a54ee4))
* syntax for using first available formatter ([2568d74](https://github.com/stevearc/conform.nvim/commit/2568d746abbadf66a03c62b568ee73d874cd8617))
### Code Refactoring
* remove run_all_formatters config option ([bd1aa02](https://github.com/stevearc/conform.nvim/commit/bd1aa02ef191410b2ea0b3ef5caabe06592d9c51))
## [2.3.0](https://github.com/stevearc/conform.nvim/compare/v2.2.0...v2.3.0) (2023-09-06)
### Features
* format() takes an optional callback ([#21](https://github.com/stevearc/conform.nvim/issues/21)) ([3f34f2d](https://github.com/stevearc/conform.nvim/commit/3f34f2de48e393b2ee289f2c8fa613c7eabae6d8))
### Bug Fixes
* callback should always be called ([eb3ebb6](https://github.com/stevearc/conform.nvim/commit/eb3ebb6d2d114f6476a8f8d21d74f99c6d231a53))
## [2.2.0](https://github.com/stevearc/conform.nvim/compare/v2.1.0...v2.2.0) (2023-08-31)
### Features
* apply changes as text edits using LSP utils ([#18](https://github.com/stevearc/conform.nvim/issues/18)) ([92393f0](https://github.com/stevearc/conform.nvim/commit/92393f02efadfb1d9f97c74c8feb853c1caea9de))
## [2.1.0](https://github.com/stevearc/conform.nvim/compare/v2.0.0...v2.1.0) (2023-08-30)
### Features
* add golines ([#11](https://github.com/stevearc/conform.nvim/issues/11)) ([e1d68a5](https://github.com/stevearc/conform.nvim/commit/e1d68a58fa29d2a24f1a976c3c60521ffb31f32e))
* add perlimports ([#13](https://github.com/stevearc/conform.nvim/issues/13)) ([e6e99af](https://github.com/stevearc/conform.nvim/commit/e6e99af64db3f364086aaf55b8b5854ccd62bac4))
* add perltidy ([#12](https://github.com/stevearc/conform.nvim/issues/12)) ([882b759](https://github.com/stevearc/conform.nvim/commit/882b75994af34fed3c4fe6f1a97ad58b352ec25f))
* add shellharden ([#14](https://github.com/stevearc/conform.nvim/issues/14)) ([863fb46](https://github.com/stevearc/conform.nvim/commit/863fb46fc7a7fa66fafb4bb8fd8093c700c472e5))
* add support for environment variables ([#8](https://github.com/stevearc/conform.nvim/issues/8)) ([03a37f1](https://github.com/stevearc/conform.nvim/commit/03a37f1b53d83af7aee10fc3ffee9f3a05d09e2e))
* display last few lines of the log file in :ConformInfo ([c9327f2](https://github.com/stevearc/conform.nvim/commit/c9327f2af541e4a17a6e2e05682122f8c8455d29))
* formatter config function is passed the buffer number ([#9](https://github.com/stevearc/conform.nvim/issues/9)) ([8b2a574](https://github.com/stevearc/conform.nvim/commit/8b2a5741e07e2d6d5e8103e5e12356d3a9f0b8ba))
* notify when formatter errors, and add notify_on_error config option ([#16](https://github.com/stevearc/conform.nvim/issues/16)) ([08dc913](https://github.com/stevearc/conform.nvim/commit/08dc913fb22d402a98d1d9733536f2876c6f6314))
### Bug Fixes
* shellharden ([#15](https://github.com/stevearc/conform.nvim/issues/15)) ([288068b](https://github.com/stevearc/conform.nvim/commit/288068b1b78c79e64054ef443afbf6f2f5145da4))
## [2.0.0](https://github.com/stevearc/conform.nvim/compare/v1.1.0...v2.0.0) (2023-08-29)
### ⚠ BREAKING CHANGES
* remove ability for formatter list to disable autoformat
### Features
* can silence notification when running formatters ([#7](https://github.com/stevearc/conform.nvim/issues/7)) ([a4d793e](https://github.com/stevearc/conform.nvim/commit/a4d793e941e8e497ab9149ed09c946473d795c1b))
* ConformInfo command for debugging formatter status ([1fd547f](https://github.com/stevearc/conform.nvim/commit/1fd547fe98a5100a041106e2bc353363ab0d5ad8))
* range formatting ([cddd536](https://github.com/stevearc/conform.nvim/commit/cddd536e087a9fd3d2c9ea5b0a44e46c7b4b54c2))
### Bug Fixes
* don't show 'no formatters' warning if none configured ([9376d37](https://github.com/stevearc/conform.nvim/commit/9376d37bd7ab456b7df8e3d6f1ba75c05b4e5a8f))
* keep window position stable when LSP formatting ([90e8a8d](https://github.com/stevearc/conform.nvim/commit/90e8a8d63c7d77d1872dca3da720abfa07271054))
* remove unnecessary notify ([6082883](https://github.com/stevearc/conform.nvim/commit/6082883585a5c61c7a5c6697517931bc6e39f546))
* stable ordering when specifying multiple formatters ([69c4495](https://github.com/stevearc/conform.nvim/commit/69c4495ab5ad3c07c3a4f3c2bcac2f070718b4cb))
### Code Refactoring
* remove ability for formatter list to disable autoformat ([d508ae8](https://github.com/stevearc/conform.nvim/commit/d508ae8f46b5b41e2806b412311719a941167c1a))
## [1.1.0](https://github.com/stevearc/conform.nvim/compare/v1.0.0...v1.1.0) (2023-08-28)
### Features
* new formatter: fish_indent ([#5](https://github.com/stevearc/conform.nvim/issues/5)) ([446aa57](https://github.com/stevearc/conform.nvim/commit/446aa570048586f9c13f1ea88e280567f336691e))
### Bug Fixes
* gracefully handle another timeout case ([500d24d](https://github.com/stevearc/conform.nvim/commit/500d24dc1a2447a3c8f3f4f756f40bd27ff0b283))
* no need to save/restore window view ([5bc69d5](https://github.com/stevearc/conform.nvim/commit/5bc69d500a14fb06bf8f36005f76a7825be25931))
## 1.0.0 (2023-08-25)
### Features
* first working version ([eb5987e](https://github.com/stevearc/conform.nvim/commit/eb5987e9dd40ce1e27c9c07e41d09571f1bd876e))
### Bug Fixes
* don't modify files when no styling changes ([08b54ba](https://github.com/stevearc/conform.nvim/commit/08b54ba11e29e6df9f83c02539976331617a412c))
* ensure real buffer numbers get logged ([33ee8ba](https://github.com/stevearc/conform.nvim/commit/33ee8ba8cb6f29caec1edf01fa4987bbae52f18b))
* notification when no formatters available ([a757225](https://github.com/stevearc/conform.nvim/commit/a75722517d17d749a5ee86c8a3bbb098a61265fc))
* set a cwd for stylua ([a22781e](https://github.com/stevearc/conform.nvim/commit/a22781e0c3b609a5f90095f388589744567476c7))

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Steven Arcangeli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,27 @@
.PHONY: all doc test lint fastlint clean
all: doc lint test
doc: scripts/nvim_doc_tools
python scripts/main.py generate
python scripts/main.py lint
test:
./run_tests.sh
lint: scripts/nvim-typecheck-action fastlint
./scripts/nvim-typecheck-action/typecheck.sh --workdir scripts/nvim-typecheck-action lua
fastlint: scripts/nvim_doc_tools
python scripts/main.py lint
luacheck lua tests --formatter plain
stylua --check lua tests
scripts/nvim_doc_tools:
git clone https://github.com/stevearc/nvim_doc_tools scripts/nvim_doc_tools
scripts/nvim-typecheck-action:
git clone https://github.com/stevearc/nvim-typecheck-action scripts/nvim-typecheck-action
clean:
rm -rf scripts/nvim_doc_tools scripts/nvim-typecheck-action

View File

@ -0,0 +1,620 @@
# conform.nvim
Lightweight yet powerful formatter plugin for Neovim
<!-- TOC -->
- [Requirements](#requirements)
- [Features](#features)
- [Installation](#installation)
- [Setup](#setup)
- [Formatters](#formatters)
- [Customizing formatters](#customizing-formatters)
- [Recipes](#recipes)
- [Advanced topics](#advanced-topics)
- [Options](#options)
- [Formatter options](#formatter-options)
- [API](#api)
- [setup(opts)](#setupopts)
- [format(opts, callback)](#formatopts-callback)
- [list_formatters(bufnr)](#list_formattersbufnr)
- [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+
## Features
- **Preserves extmarks and folds** - Most formatters replace the entire buffer, which clobbers extmarks and folds, and can cause the viewport and cursor to jump unexpectedly. Conform calculates minimal diffs and applies them using the built-in LSP format utilities.
- **Fixes bad-behaving LSP formatters** - Some LSP servers are lazy and simply replace the entire buffer, leading to the problems mentioned above. Conform hooks into the LSP handler and turns these responses into proper piecewise changes.
- **Enables range formatting for all formatters** - Since conform calculates minimal diffs, it can perform range formatting [even if the underlying formatter doesn't support it.](doc/advanced_topics.md#range-formatting)
- **Simple API** - Conform exposes a simple, imperative API modeled after `vim.lsp.buf.format()`.
- **Formats embedded code blocks** - Can format code blocks inside markdown files or similar (see [injected language formatting](doc/advanced_topics.md#injected-language-formatting-code-blocks))
## Installation
conform.nvim supports all the usual plugin managers
<details>
<summary>lazy.nvim</summary>
```lua
{
'stevearc/conform.nvim',
opts = {},
}
```
For a more thorough configuration involving lazy-loading, see [Lazy loading with lazy.nvim](doc/recipes.md#lazy-loading-with-lazynvim).
</details>
<details>
<summary>Packer</summary>
```lua
require("packer").startup(function()
use({
"stevearc/conform.nvim",
config = function()
require("conform").setup()
end,
})
end)
```
</details>
<details>
<summary>Paq</summary>
```lua
require("paq")({
{ "stevearc/conform.nvim" },
})
```
</details>
<details>
<summary>vim-plug</summary>
```vim
Plug 'stevearc/conform.nvim'
```
</details>
<details>
<summary>dein</summary>
```vim
call dein#add('stevearc/conform.nvim')
```
</details>
<details>
<summary>Pathogen</summary>
```sh
git clone --depth=1 https://github.com/stevearc/conform.nvim.git ~/.vim/bundle/
```
</details>
<details>
<summary>Neovim native package</summary>
```sh
git clone --depth=1 https://github.com/stevearc/conform.nvim.git \
"${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/conform/start/conform.nvim
```
</details>
## Setup
At a minimum, you will need to set up some formatters by filetype
```lua
require("conform").setup({
formatters_by_ft = {
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" } },
},
})
```
Then you can use `conform.format()` just like you would `vim.lsp.buf.format()`. For example, to format on save:
```lua
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*",
callback = function(args)
require("conform").format({ bufnr = args.buf })
end,
})
```
As a shortcut, conform will optionally set up this format-on-save autocmd for you
```lua
require("conform").setup({
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_fallback = true,
},
})
```
See [conform.format()](#formatopts-callback) for more details about the parameters.
Conform also provides a formatexpr, same as the LSP client:
```lua
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
```
To view configured and available formatters, as well as to see the log file, run `:ConformInfo`
## Formatters
You can view this list in vim with `:help conform-formatters`
<details>
<summary>Expand to see all formatters</summary>
<!-- FORMATTERS -->
- [alejandra](https://kamadorueda.com/alejandra/) - The Uncompromising Nix Code Formatter.
- [asmfmt](https://github.com/klauspost/asmfmt) - Go Assembler Formatter
- [ast-grep](https://ast-grep.github.io/) - A CLI tool for code structural search, lint and rewriting. Written in Rust.
- [astyle](https://astyle.sourceforge.net/astyle.html) - A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective-C, C#, and Java Source Code.
- [auto_optional](https://auto-optional.daanluttik.nl/) - Adds the Optional type-hint to arguments where the default value is None.
- [autocorrect](https://github.com/huacnlee/autocorrect) - A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuations between CJK.
- [autoflake](https://github.com/PyCQA/autoflake) - Removes unused imports and unused variables as reported by pyflakes.
- [autopep8](https://github.com/hhatto/autopep8) - A tool that automatically formats Python code to conform to the PEP 8 style guide.
- [awk](https://www.gnu.org/software/gawk/manual/gawk.html) - Format awk programs with awk
- [bean-format](https://beancount.github.io/docs/running_beancount_and_generating_reports.html#bean-format) - Reformat Beancount files to right-align all the numbers at the same, minimal column.
- [beautysh](https://github.com/lovesegfault/beautysh) - A Bash beautifier for the masses.
- [bibtex-tidy](https://github.com/FlamingTempura/bibtex-tidy) - Cleaner and Formatter for BibTeX files.
- [bicep](https://github.com/Azure/bicep) - Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively.
- [biome](https://github.com/biomejs/biome) - A toolchain for web projects, aimed to provide functionalities to maintain them.
- [biome-check](https://github.com/biomejs/biome) - A toolchain for web projects, aimed to provide functionalities to maintain them.
- [black](https://github.com/psf/black) - The uncompromising Python code formatter.
- [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.
- [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
- [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.
- [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.
- [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.
- [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.
- [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.
- [elm_format](https://github.com/avh4/elm-format) - elm-format formats Elm source code according to a standard set of rules based on the official [Elm Style Guide](https://elm-lang.org/docs/style-guide).
- [erb_format](https://github.com/nebulab/erb-formatter) - Format ERB files with speed and precision.
- [eslint_d](https://github.com/mantoni/eslint_d.js/) - Like ESLint, but faster.
- [fantomas](https://github.com/fsprojects/fantomas) - F# source code formatter.
- [fish_indent](https://fishshell.com/docs/current/cmds/fish_indent.html) - Indent or otherwise prettify a piece of fish code.
- [fixjson](https://github.com/rhysd/fixjson) - JSON Fixer for Humans using (relaxed) JSON5.
- [fnlfmt](https://git.sr.ht/~technomancy/fnlfmt) - A formatter for Fennel code.
- [forge_fmt](https://github.com/foundry-rs/foundry) - Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts.
- [fourmolu](https://hackage.haskell.org/package/fourmolu) - A fork of ormolu that uses four space indentation and allows arbitrary configuration.
- [gci](https://github.com/daixiang0/gci) - GCI, a tool that controls Go package import order and makes it always deterministic.
- [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!
- [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.
- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) - Updates your Go import lines, adding missing ones and removing unreferenced ones.
- [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.
- [hcl](https://github.com/hashicorp/hcl) - A formatter for HCL files.
- [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier) - A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.
- [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
- [isort](https://github.com/PyCQA/isort) - Python utility / library to sort imports alphabetically and automatically separate them into sections and by type.
- [joker](https://github.com/candid82/joker) - Small Clojure interpreter, linter and formatter.
- [jq](https://github.com/stedolan/jq) - Command-line JSON processor.
- [jsonnetfmt](https://github.com/google/go-jsonnet/tree/master/cmd/jsonnetfmt) - jsonnetfmt is a command line tool to format jsonnet files.
- [just](https://github.com/casey/just) - Format Justfile.
- [ktfmt](https://github.com/facebook/ktfmt) - Reformats Kotlin source code to comply with the common community standard conventions.
- [ktlint](https://ktlint.github.io/) - An anti-bikeshedding Kotlin linter with built-in formatter.
- [latexindent](https://github.com/cmhughes/latexindent.pl) - A perl script for formatting LaTeX files that is generally included in major TeX distributions.
- [leptosfmt](https://github.com/bram209/leptosfmt) - A formatter for the Leptos view! macro.
- [liquidsoap-prettier](https://github.com/savonet/liquidsoap-prettier) - A binary to format Liquidsoap scripts
- [markdown-toc](https://github.com/jonschlinkert/markdown-toc) - API and CLI for generating a markdown TOC (table of contents) for a README or any markdown files.
- [markdownlint](https://github.com/DavidAnson/markdownlint) - A Node.js style checker and lint tool for Markdown/CommonMark files.
- [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) - A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library.
- [mdformat](https://github.com/executablebooks/mdformat) - An opinionated Markdown formatter.
- [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.
- [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.
- [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) - Auto-formatter for OCaml code.
- [ocp-indent](https://github.com/OCamlPro/ocp-indent) - Automatic indentation of OCaml source files.
- [opa_fmt](https://www.openpolicyagent.org/docs/latest/cli/#opa-fmt) - Format Rego files using `opa fmt` command.
- [ormolu](https://hackage.haskell.org/package/ormolu) - A formatter for Haskell source code.
- [packer_fmt](https://developer.hashicorp.com/packer/docs/commands/fmt) - The packer fmt Packer command is used to format HCL2 configuration files to a canonical format and style.
- [pangu](https://github.com/vinta/pangu.py) - Insert whitespace between CJK and half-width characters.
- [perlimports](https://github.com/perl-ide/App-perlimports) - Make implicit Perl imports explicit.
- [perltidy](https://github.com/perltidy/perltidy) - Perl::Tidy, a source code formatter for Perl.
- [pg_format](https://github.com/darold/pgFormatter) - PostgreSQL SQL syntax beautifier.
- [php_cs_fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) - The PHP Coding Standards Fixer.
- [phpcbf](https://phpqa.io/projects/phpcbf.html) - PHP Code Beautifier and Fixer fixes violations of a defined coding standard.
- [phpinsights](https://github.com/nunomaduro/phpinsights) - The perfect starting point to analyze the code quality of your PHP projects.
- [pint](https://github.com/laravel/pint) - Laravel Pint is an opinionated PHP code style fixer for minimalists.
- [prettier](https://github.com/prettier/prettier) - Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
- [prettierd](https://github.com/fsouza/prettierd) - prettier, as a daemon, for ludicrous formatting speed.
- [pretty-php](https://github.com/lkrms/pretty-php) - The opinionated PHP code formatter.
- [puppet-lint](https://github.com/puppetlabs/puppet-lint) - Check that your Puppet manifests conform to the style guide.
- [purs-tidy](https://github.com/natefaubion/purescript-tidy) - A syntax tidy-upper for PureScript.
- [reorder-python-imports](https://github.com/asottile/reorder-python-imports) - Rewrites source to reorder python imports
- [rescript-format](https://rescript-lang.org/) - The built-in ReScript formatter.
- [roc](https://github.com/roc-lang/roc) - A fast, friendly, functional language.
- [rubocop](https://github.com/rubocop/rubocop) - Ruby static code analyzer and formatter, based on the community Ruby style guide.
- [rubyfmt](https://github.com/fables-tales/rubyfmt) - Ruby Autoformatter! (Written in Rust)
- [ruff_fix](https://docs.astral.sh/ruff/) - An extremely fast Python linter, written in Rust. Fix lint errors.
- [ruff_format](https://docs.astral.sh/ruff/) - An extremely fast Python linter, written in Rust. Formatter subcommand.
- [ruff_organize_imports](https://docs.astral.sh/ruff/) - An extremely fast Python linter, written in Rust. Organize imports.
- [rufo](https://github.com/ruby-formatter/rufo) - Rufo is an opinionated ruby formatter.
- [rustfmt](https://github.com/rust-lang/rustfmt) - A tool for formatting rust code according to style guidelines.
- [rustywind](https://github.com/avencera/rustywind) - A tool for formatting Tailwind CSS classes.
- [scalafmt](https://github.com/scalameta/scalafmt) - Code formatter for Scala.
- [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.
- [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.
- [sqlfluff](https://github.com/sqlfluff/sqlfluff) - A modular SQL linter and auto-formatter with support for multiple dialects and templated code.
- [sqlfmt](https://docs.sqlfmt.com) - sqlfmt formats your dbt SQL files so you don't have to. It is similar in nature to Black, gofmt, and rustfmt (but for SQL)
- [squeeze_blanks](https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html#cat-invocation) - Squeeze repeated blank lines into a single blank line via `cat -s`.
- [standardjs](https://standardjs.com) - JavaScript Standard style guide, linter, and formatter.
- [standardrb](https://github.com/standardrb/standard) - Ruby's bikeshed-proof linter and formatter.
- [stylelint](https://github.com/stylelint/stylelint) - A mighty CSS linter that helps you avoid errors and enforce conventions.
- [styler](https://github.com/devOpifex/r.nvim) - R formatter and linter.
- [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.
- [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.
- [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
- [typstfmt](https://github.com/astrale-sharp/typstfmt) - Basic formatter for the Typst language with a future!
- [typstyle](https://github.com/Enter-tainer/typstyle) - Beautiful and reliable typst code formatter.
- [uncrustify](https://github.com/uncrustify/uncrustify) - A source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and Vala.
- [usort](https://github.com/facebook/usort) - Safe, minimal import sorting for Python projects.
- [verible](https://github.com/chipsalliance/verible/blob/master/verilog/tools/formatter/README.md) - The SystemVerilog formatter.
- [xmlformat](https://github.com/pamoller/xmlformatter) - xmlformatter is an Open Source Python package, which provides formatting of XML documents.
- [xmllint](http://xmlsoft.org/xmllint.html) - Despite the name, xmllint can be used to format XML files as well as lint them.
- [yamlfix](https://github.com/lyz-code/yamlfix) - A configurable YAML formatter that keeps comments.
- [yamlfmt](https://github.com/google/yamlfmt) - yamlfmt is an extensible command line tool or library to format yaml files.
- [yapf](https://github.com/google/yapf) - Yet Another Python Formatter.
- [yew-fmt](https://github.com/schvv31n/yew-fmt) - Code formatter for the Yew framework.
- [yq](https://github.com/mikefarah/yq) - YAML/JSON processor
- [zigfmt](https://github.com/ziglang/zig) - Reformat Zig source into canonical form.
- [zprint](https://github.com/kkinnear/zprint) - Formatter for Clojure and EDN.
<!-- /FORMATTERS -->
</details>
## Customizing formatters
You can override/add to the default values of formatters
```lua
require("conform").setup({
formatters = {
yamlfix = {
-- Change where to find the command
command = "local/path/yamlfix",
-- Adds environment args to the yamlfix formatter
env = {
YAMLFIX_SEQUENCE_STYLE = "block_style",
},
},
},
})
-- These can also be set directly
require("conform").formatters.yamlfix = {
env = {
YAMLFIX_SEQUENCE_STYLE = "block_style",
},
}
-- This can also be a function that returns the config,
-- which can be useful if you're doing lazy loading
require("conform").formatters.yamlfix = function(bufnr)
return {
command = require("conform.util").find_executable({
"local/path/yamlfix",
}, "yamlfix"),
}
end
```
In addition to being able to override any of the original properties on the formatter, there is another property for easily adding additional arguments to the format command
```lua
require("conform").formatters.shfmt = {
prepend_args = { "-i", "2" },
-- The base args are { "-filename", "$FILENAME" } so the final args will be
-- { "-i", "2", "-filename", "$FILENAME" }
}
-- prepend_args can be a function, just like args
require("conform").formatters.shfmt = {
prepend_args = function(self, ctx)
return { "-i", "2" }
end,
}
```
If you want to overwrite the entire formatter definition and _not_ merge with the default values, pass `inherit = false`. This is also the default behavior if there is no built-in formatter with the given name, which can be used to add your own custom formatters.
```lua
require("conform").formatters.shfmt = {
inherit = false,
command = "shfmt",
args = { "-i", "2", "-filename", "$FILENAME" },
}
```
## Recipes
<!-- RECIPES -->
- [Format command](doc/recipes.md#format-command)
- [Autoformat with extra features](doc/recipes.md#autoformat-with-extra-features)
- [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)
<!-- /RECIPES -->
## Advanced topics
<!-- ADVANCED -->
- [Minimal format diffs](doc/advanced_topics.md#minimal-format-diffs)
- [Range formatting](doc/advanced_topics.md#range-formatting)
- [Injected language formatting (code blocks)](doc/advanced_topics.md#injected-language-formatting-code-blocks)
<!-- /ADVANCED -->
## Options
A complete list of all configuration options
<!-- OPTIONS -->
```lua
require("conform").setup({
-- Map of filetype to formatters
formatters_by_ft = {
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 use a function here to determine the formatters dynamically
python = function(bufnr)
if require("conform").get_formatter_info("ruff_format", bufnr).available then
return { "ruff_format" }
else
return { "isort", "black" }
end
end,
-- Use the "*" filetype to run formatters on all filetypes.
["*"] = { "codespell" },
-- Use the "_" filetype to run formatters on filetypes that don't
-- have other formatters configured.
["_"] = { "trim_whitespace" },
},
-- 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.
format_on_save = {
-- I recommend these options. See :help conform.format for details.
lsp_fallback = true,
timeout_ms = 500,
},
-- 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.
format_after_save = {
lsp_fallback = true,
},
-- Set the log level. Use `:ConformInfo` to see the location of the log file.
log_level = vim.log.levels.ERROR,
-- Conform will notify you when a formatter errors
notify_on_error = true,
-- Custom formatters and overrides for built-in formatters
formatters = {
my_formatter = {
-- This can be a string or a function that returns a string.
-- When defining a new formatter, this is the only field that is required
command = "my_cmd",
-- A list of strings, or a function that returns a list of strings
-- Return a single string instead of a list to run the command in a shell
args = { "--stdin-from-filename", "$FILENAME" },
-- If the formatter supports range formatting, create the range arguments here
range_args = function(self, ctx)
return { "--line-start", ctx.range.start[1], "--line-end", ctx.range["end"][1] }
end,
-- Send file contents to stdin, read new contents from stdout (default true)
-- When false, will create a temp file (will appear in "$FILENAME" args). The temp
-- file is assumed to be modified in-place by the format command.
stdin = true,
-- A function that calculates the directory to run the command in
cwd = require("conform.util").root_file({ ".editorconfig", "package.json" }),
-- When cwd is not found, don't run the formatter (default false)
require_cwd = true,
-- When stdin=false, use this template to generate the temporary file that gets formatted
tmpfile_format = ".conform.$RANDOM.$FILENAME",
-- When returns false, the formatter will not be used
condition = function(self, ctx)
return vim.fs.basename(ctx.filename) ~= "README.md"
end,
-- Exit codes that indicate success (default { 0 })
exit_codes = { 0, 1 },
-- Environment variables. This can also be a function that returns a table.
env = {
VAR = "value",
},
-- Set to false to disable merging the config with the base definition
inherit = true,
-- When inherit = true, add these additional arguments to the command.
-- This can also be a function, like args
prepend_args = { "--use-tabs" },
},
-- These can also be a function that returns the formatter
other_formatter = function(bufnr)
return {
command = "my_cmd",
}
end,
},
})
-- You can set formatters_by_ft and formatters directly
require("conform").formatters_by_ft.lua = { "stylua" }
require("conform").formatters.my_formatter = {
command = "my_cmd",
}
```
<!-- /OPTIONS -->
## Formatter options
<!-- FORMATTER_OPTIONS -->
- [injected](doc/formatter_options.md#injected)
- [prettier](doc/formatter_options.md#prettier)
- [rustfmt](doc/formatter_options.md#rustfmt)
- [yew-fmt](doc/formatter_options.md#yew-fmt)
<!-- /FORMATTER_OPTIONS -->
## API
<!-- API -->
### setup(opts)
`setup(opts)`
| Param | Type | Desc | |
| ----- | ------------------------ | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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): 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. |
| | format_after_save | `nil\|conform.FormatOpts\|fun(bufnr: integer): 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). |
| | formatters | `nil\|table<string, conform.FormatterConfigOverride\|fun(bufnr: integer): nil\|conform.FormatterConfigOverride>` | Custom formatters and overrides for built-in formatters. |
### format(opts, callback)
`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_fallback | `nil\|boolean\|"always"` | Attempt LSP formatting if no formatters are available. Defaults to false. If "always", will attempt LSP formatting even if formatters are available. |
| | 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 lsp_fallback = true |
| | name | `nil\|string` | Passed to vim.lsp.buf.format when lsp_fallback = true |
| | filter | `nil\|fun(client: table): boolean` | Passed to vim.lsp.buf.format when lsp_fallback = true |
| callback | `nil\|fun(err: nil\|string, did_edit: nil\|boolean)` | Called once formatting has completed | |
Returns:
| Type | Desc |
| ------- | ------------------------------------- |
| boolean | True if any formatters were attempted |
### list_formatters(bufnr)
`list_formatters(bufnr): conform.FormatterInfo[]` \
Retrieve the available formatters for a buffer
| Param | Type | Desc |
| ----- | -------------- | ---- |
| bufnr | `nil\|integer` | |
### list_all_formatters()
`list_all_formatters(): conform.FormatterInfo[]` \
List information about all filetype-configured formatters
### get_formatter_info(formatter, bufnr)
`get_formatter_info(formatter, bufnr): conform.FormatterInfo` \
Get information about a formatter (including availability)
| Param | Type | Desc |
| --------- | -------------- | ------------------------- |
| 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_fallback = true
| Param | Type | Desc |
| ------- | ------------ | ------------------------------------ |
| options | `nil\|table` | Options passed to vim.lsp.buf.format |
<!-- /API -->
## Acknowledgements
Thanks to
- [nvim-lint](https://github.com/mfussenegger/nvim-lint) for providing inspiration for the config and API. It's an excellent plugin that balances power and simplicity.
- [null-ls](https://github.com/jose-elias-alvarez/null-ls.nvim) for formatter configurations and being my formatter/linter of choice for a long time.

View File

@ -0,0 +1,31 @@
# Advanced topics
<!-- TOC -->
- [Minimal format diffs](#minimal-format-diffs)
- [Range formatting](#range-formatting)
- [Injected language formatting (code blocks)](#injected-language-formatting-code-blocks)
<!-- /TOC -->
## Minimal format diffs
To understand why this is important and why conform.nvim is different we need a bit of historical context. Formatting tools work by taking in the current state of the file and outputting the same contents, with formatting applied. The way most formatting plugins work is they take the new content and replace the entire buffer. The benefit of this approach is that it's very simple. It's easy to code, it's easy to reason about, and it's easy to debug.
What conform does differently is it leverages `:help vim.diff`, Neovim's lua bindings for xdiff. We use this to compare the formatted lines to the original content and calculate minimal chunks where changes need to be applied. From there, we convert these chunks into LSP TextEdit objects and use `vim.lsp.util.apply_text_edits()` to actually apply the changes. Since we're using the built-in LSP utility, we get the benefits of all the work that was put into improving the LSP formatting experience, such as the preservation of extmarks. The piecewise update also does a better job of preserving cursor position, folds, viewport position, etc.
## Range formatting
When a formatting tool doesn't have built-in support for range formatting, conform will attempt to "fake it" when requested. This is necessarily a **best effort** operation and is **not** guaranteed to be correct or error-free, however in _most_ cases it should produce acceptable results.
The way this "aftermarket" range formatting works is conform will format the entire buffer as per usual, but during the diff process it will discard diffs that fall outside of the selected range. This usually approximates a correct result, but as you can guess it's possible for the formatting to exceed the range (if the diff covering the range is large) or for the results to be incorrect (if the formatting changes require two diffs in different locations to be semantically correct).
## Injected language formatting (code blocks)
Requires: Neovim 0.9+
Sometimes you may have a file that contains small chunks of code in another language. This is most common for markup formats like markdown and neorg, but can theoretically be present in any filetype (for example, embedded SQL queries in a host language). For files like this, it would be nice to be able to format these code chunks using their language-specific formatters.
The way that conform supports this is via the `injected` formatter. If you run this formatter on a file, it will use treesitter to parse out the blocks in the file that have different languages and runs the formatters for that filetype (configured with `formatters_by_ft`). The formatters are run in parallel, one job for each language block.
This formatter is experimental; the behavior and configuration options are still subject to change. The current list of configuration options can be found at [formatter options](formatter_options.md#injected)

View File

@ -0,0 +1,413 @@
*conform.txt*
*Conform* *conform* *conform.nvim*
--------------------------------------------------------------------------------
CONTENTS *conform-contents*
1. Options |conform-options|
2. Api |conform-api|
3. Formatters |conform-formatters|
--------------------------------------------------------------------------------
OPTIONS *conform-options*
>lua
require("conform").setup({
-- Map of filetype to formatters
formatters_by_ft = {
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 use a function here to determine the formatters dynamically
python = function(bufnr)
if require("conform").get_formatter_info("ruff_format", bufnr).available then
return { "ruff_format" }
else
return { "isort", "black" }
end
end,
-- Use the "*" filetype to run formatters on all filetypes.
["*"] = { "codespell" },
-- Use the "_" filetype to run formatters on filetypes that don't
-- have other formatters configured.
["_"] = { "trim_whitespace" },
},
-- 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.
format_on_save = {
-- I recommend these options. See :help conform.format for details.
lsp_fallback = true,
timeout_ms = 500,
},
-- 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.
format_after_save = {
lsp_fallback = true,
},
-- Set the log level. Use `:ConformInfo` to see the location of the log file.
log_level = vim.log.levels.ERROR,
-- Conform will notify you when a formatter errors
notify_on_error = true,
-- Custom formatters and overrides for built-in formatters
formatters = {
my_formatter = {
-- This can be a string or a function that returns a string.
-- When defining a new formatter, this is the only field that is required
command = "my_cmd",
-- A list of strings, or a function that returns a list of strings
-- Return a single string instead of a list to run the command in a shell
args = { "--stdin-from-filename", "$FILENAME" },
-- If the formatter supports range formatting, create the range arguments here
range_args = function(self, ctx)
return { "--line-start", ctx.range.start[1], "--line-end", ctx.range["end"][1] }
end,
-- Send file contents to stdin, read new contents from stdout (default true)
-- When false, will create a temp file (will appear in "$FILENAME" args). The temp
-- file is assumed to be modified in-place by the format command.
stdin = true,
-- A function that calculates the directory to run the command in
cwd = require("conform.util").root_file({ ".editorconfig", "package.json" }),
-- When cwd is not found, don't run the formatter (default false)
require_cwd = true,
-- When stdin=false, use this template to generate the temporary file that gets formatted
tmpfile_format = ".conform.$RANDOM.$FILENAME",
-- When returns false, the formatter will not be used
condition = function(self, ctx)
return vim.fs.basename(ctx.filename) ~= "README.md"
end,
-- Exit codes that indicate success (default { 0 })
exit_codes = { 0, 1 },
-- Environment variables. This can also be a function that returns a table.
env = {
VAR = "value",
},
-- Set to false to disable merging the config with the base definition
inherit = true,
-- When inherit = true, add these additional arguments to the command.
-- This can also be a function, like args
prepend_args = { "--use-tabs" },
},
-- These can also be a function that returns the formatter
other_formatter = function(bufnr)
return {
command = "my_cmd",
}
end,
},
})
-- You can set formatters_by_ft and formatters directly
require("conform").formatters_by_ft.lua = { "stylua" }
require("conform").formatters.my_formatter = {
command = "my_cmd",
}
<
--------------------------------------------------------------------------------
API *conform-api*
setup({opts}) *conform.setup*
Parameters:
{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): conform.FormatOpts` I
f 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.
{format_after_save} `nil|conform.FormatOpts|fun(bufnr: integer): conform.FormatOpts` I
f 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).
{formatters} `nil|table<string, conform.FormatterConfigOverride|fun(bufnr: integer): nil|conform.FormatterConfigOverride>` C
ustom formatters and overrides for built-in
formatters.
format({opts}, {callback}): boolean *conform.format*
Format a buffer
Parameters:
{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_fallback} `nil|boolean|"always"` Attempt LSP formatting if no
formatters are available. Defaults to false. If
"always", will attempt LSP formatting even if
formatters are available.
{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
lsp_fallback = true
{name} `nil|string` Passed to |vim.lsp.buf.format| when
lsp_fallback = true
{filter} `nil|fun(client: table): boolean` Passed to
|vim.lsp.buf.format| when lsp_fallback = true
{callback} `nil|fun(err: nil|string, did_edit: nil|boolean)` Called once
formatting has completed
Returns:
`boolean` True if any formatters were attempted
list_formatters({bufnr}): conform.FormatterInfo[] *conform.list_formatters*
Retrieve the available formatters for a buffer
Parameters:
{bufnr} `nil|integer`
list_all_formatters(): conform.FormatterInfo[] *conform.list_all_formatters*
List information about all filetype-configured formatters
get_formatter_info({formatter}, {bufnr}): conform.FormatterInfo *conform.get_formatter_info*
Get information about a formatter (including availability)
Parameters:
{formatter} `string` The name of the formatter
{bufnr} `nil|integer`
will_fallback_lsp({options}): boolean *conform.will_fallback_lsp*
Check if the buffer will use LSP formatting when lsp_fallback = true
Parameters:
{options} `nil|table` Options passed to |vim.lsp.buf.format|
--------------------------------------------------------------------------------
FORMATTERS *conform-formatters*
`alejandra` - The Uncompromising Nix Code Formatter.
`asmfmt` - Go Assembler Formatter
`ast-grep` - A CLI tool for code structural search, lint and rewriting. Written
in Rust.
`astyle` - A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI,
Objective-C, C#, and Java Source Code.
`auto_optional` - Adds the Optional type-hint to arguments where the default
value is None.
`autocorrect` - A linter and formatter to help you to improve copywriting,
correct spaces, words, and punctuations between CJK.
`autoflake` - Removes unused imports and unused variables as reported by
pyflakes.
`autopep8` - A tool that automatically formats Python code to conform to the PEP
8 style guide.
`awk` - Format awk programs with awk
`bean-format` - Reformat Beancount files to right-align all the numbers at the
same, minimal column.
`beautysh` - A Bash beautifier for the masses.
`bibtex-tidy` - Cleaner and Formatter for BibTeX files.
`bicep` - Bicep is a Domain Specific Language (DSL) for deploying Azure
resources declaratively.
`biome` - A toolchain for web projects, aimed to provide functionalities to
maintain them.
`biome-check` - A toolchain for web projects, aimed to provide functionalities
to maintain them.
`black` - The uncompromising Python code formatter.
`blade-formatter` - An opinionated blade template formatter for Laravel that
respects readability.
`blue` - The slightly less uncompromising Python code formatter.
`bpfmt` - Android Blueprint file formatter.
`buf` - A new way of working with Protocol Buffers.
`buildifier` - buildifier is a tool for formatting bazel BUILD and .bzl files
with a standard convention.
`cabal_fmt` - Format cabal files with cabal-fmt
`cbfmt` - A tool to format codeblocks inside markdown and org documents.
`clang-format` - Tool to format C/C++/… code according to a set of rules and
heuristics.
`cljstyle` - Formatter for Clojure code.
`cmake_format` - Parse cmake listfiles and format them nicely.
`codespell` - Check code for common misspellings.
`crystal` - Format Crystal code.
`csharpier` - The opinionated C# code formatter.
`cue_fmt` - Format CUE files using `cue fmt` command.
`darker` - Run black only on changed lines.
`dart_format` - Replace the whitespace in your program with formatting that
follows Dart guidelines.
`deno_fmt` - Use [Deno](https://deno.land/) to format TypeScript,
JavaScript/JSON and markdown.
`dfmt` - Formatter for D source code.
`djlint` - ✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks -
Handlebars - GoLang.
`dprint` - Pluggable and configurable code formatting platform written in Rust.
`easy-coding-standard` - ecs - Use Coding Standard with 0-knowledge of PHP-CS-
Fixer and PHP_CodeSniffer.
`elm_format` - elm-format formats Elm source code according to a standard set of
rules based on the official [Elm Style Guide](https://elm-
lang.org/docs/style-guide).
`erb_format` - Format ERB files with speed and precision.
`eslint_d` - Like ESLint, but faster.
`fantomas` - F# source code formatter.
`fish_indent` - Indent or otherwise prettify a piece of fish code.
`fixjson` - JSON Fixer for Humans using (relaxed) JSON5.
`fnlfmt` - A formatter for Fennel code.
`forge_fmt` - Forge is a command-line tool that ships with Foundry. Forge tests,
builds, and deploys your smart contracts.
`fourmolu` - A fork of ormolu that uses four space indentation and allows
arbitrary configuration.
`gci` - GCI, a tool that controls Go package import order and makes it always
deterministic.
`gdformat` - A formatter for Godot's gdscript.
`gersemi` - A formatter to make your CMake code the real treasure.
`gleam` - ⭐️ A friendly language for building type-safe, scalable systems!
`gn` - gn build system.
`gofmt` - Formats go programs.
`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.
`goimports` - Updates your Go import lines, adding missing ones and removing
unreferenced ones.
`goimports-reviser` - Right imports sorting & code formatting tool (goimports
alternative).
`golines` - A golang formatter that fixes long lines.
`google-java-format` - Reformats Java source code according to Google Java
Style.
`hcl` - A formatter for HCL files.
`htmlbeautifier` - A normaliser/beautifier for HTML that also understands
embedded Ruby. Ideal for tidying up Rails templates.
`indent` - GNU Indent.
`injected` - Format treesitter injected languages.
`inko` - A language for building concurrent software with confidence
`isort` - Python utility / library to sort imports alphabetically and
automatically separate them into sections and by type.
`joker` - Small Clojure interpreter, linter and formatter.
`jq` - Command-line JSON processor.
`jsonnetfmt` - jsonnetfmt is a command line tool to format jsonnet files.
`just` - Format Justfile.
`ktfmt` - Reformats Kotlin source code to comply with the common community
standard conventions.
`ktlint` - An anti-bikeshedding Kotlin linter with built-in formatter.
`latexindent` - A perl script for formatting LaTeX files that is generally
included in major TeX distributions.
`leptosfmt` - A formatter for the Leptos view! macro.
`liquidsoap-prettier` - A binary to format Liquidsoap scripts
`markdown-toc` - API and CLI for generating a markdown TOC (table of contents)
for a README or any markdown files.
`markdownlint` - A Node.js style checker and lint tool for Markdown/CommonMark
files.
`markdownlint-cli2` - A fast, flexible, configuration-based command-line
interface for linting Markdown/CommonMark files with the
markdownlint library.
`mdformat` - An opinionated Markdown formatter.
`mdsf` - Format markdown code blocks using your favorite code formatters.
`mdslw` - Prepare your markdown for easy diff'ing by adding line breaks after
every sentence.
`mix` - Format Elixir files using the mix format command.
`nimpretty` - nimpretty is a Nim source code beautifier that follows the
official style guide.
`nixfmt` - nixfmt is a formatter for Nix code, intended to apply a uniform
style.
`nixpkgs_fmt` - nixpkgs-fmt is a Nix code formatter for nixpkgs.
`ocamlformat` - Auto-formatter for OCaml code.
`ocp-indent` - Automatic indentation of OCaml source files.
`opa_fmt` - Format Rego files using `opa fmt` command.
`ormolu` - A formatter for Haskell source code.
`packer_fmt` - The packer fmt Packer command is used to format HCL2
configuration files to a canonical format and style.
`pangu` - Insert whitespace between CJK and half-width characters.
`perlimports` - Make implicit Perl imports explicit.
`perltidy` - Perl::Tidy, a source code formatter for Perl.
`pg_format` - PostgreSQL SQL syntax beautifier.
`php_cs_fixer` - The PHP Coding Standards Fixer.
`phpcbf` - PHP Code Beautifier and Fixer fixes violations of a defined coding
standard.
`phpinsights` - The perfect starting point to analyze the code quality of your
PHP projects.
`pint` - Laravel Pint is an opinionated PHP code style fixer for minimalists.
`prettier` - Prettier is an opinionated code formatter. It enforces a consistent
style by parsing your code and re-printing it with its own rules that
take the maximum line length into account, wrapping code when
necessary.
`prettierd` - prettier, as a daemon, for ludicrous formatting speed.
`pretty-php` - The opinionated PHP code formatter.
`puppet-lint` - Check that your Puppet manifests conform to the style guide.
`purs-tidy` - A syntax tidy-upper for PureScript.
`reorder-python-imports` - Rewrites source to reorder python imports
`rescript-format` - The built-in ReScript formatter.
`roc` - A fast, friendly, functional language.
`rubocop` - Ruby static code analyzer and formatter, based on the community Ruby
style guide.
`rubyfmt` - Ruby Autoformatter! (Written in Rust)
`ruff_fix` - An extremely fast Python linter, written in Rust. Fix lint errors.
`ruff_format` - An extremely fast Python linter, written in Rust. Formatter
subcommand.
`ruff_organize_imports` - An extremely fast Python linter, written in Rust.
Organize imports.
`rufo` - Rufo is an opinionated ruby formatter.
`rustfmt` - A tool for formatting rust code according to style guidelines.
`rustywind` - A tool for formatting Tailwind CSS classes.
`scalafmt` - Code formatter for Scala.
`shellcheck` - A static analysis tool for shell scripts.
`shellharden` - The corrective bash syntax highlighter.
`shfmt` - A shell parser, formatter, and interpreter with `bash` support.
`smlfmt` - A custom parser and code formatter for Standard ML.
`snakefmt` - a formatting tool for Snakemake files following the design of
Black.
`sql_formatter` - A whitespace formatter for different query languages.
`sqlfluff` - A modular SQL linter and auto-formatter with support for multiple
dialects and templated code.
`sqlfmt` - sqlfmt formats your dbt SQL files so you don't have to. It is similar
in nature to Black, gofmt, and rustfmt (but for SQL)
`squeeze_blanks` - Squeeze repeated blank lines into a single blank line via
`cat -s`.
`standardjs` - JavaScript Standard style guide, linter, and formatter.
`standardrb` - Ruby's bikeshed-proof linter and formatter.
`stylelint` - A mighty CSS linter that helps you avoid errors and enforce
conventions.
`styler` - R formatter and linter.
`stylua` - An opinionated code formatter for Lua.
`swift_format` - Swift formatter from apple. Requires building from source with
`swift build`.
`swiftformat` - SwiftFormat is a code library and command-line tool for
reformatting `swift` code on macOS or Linux.
`taplo` - A TOML toolkit written in Rust.
`templ` - Formats templ template files.
`terraform_fmt` - The terraform-fmt command rewrites `terraform` configuration
files to a canonical format and style.
`terragrunt_hclfmt` - Format hcl files into a canonical format.
`tlint` - Tighten linter for Laravel conventions with support for auto-
formatting.
`tofu_fmt` - The tofu-fmt command rewrites OpenTofu configuration files to a
canonical format and style.
`trim_newlines` - Trim new lines with awk.
`trim_whitespace` - Trim whitespaces with awk.
`twig-cs-fixer` - Automatically fix Twig Coding Standards issues
`typos` - Source code spell checker
`typstfmt` - Basic formatter for the Typst language with a future!
`typstyle` - Beautiful and reliable typst code formatter.
`uncrustify` - A source code beautifier for C, C++, C#, ObjectiveC, D, Java,
Pawn and Vala.
`usort` - Safe, minimal import sorting for Python projects.
`verible` - The SystemVerilog formatter.
`xmlformat` - xmlformatter is an Open Source Python package, which provides
formatting of XML documents.
`xmllint` - Despite the name, xmllint can be used to format XML files as well as
lint them.
`yamlfix` - A configurable YAML formatter that keeps comments.
`yamlfmt` - yamlfmt is an extensible command line tool or library to format yaml
files.
`yapf` - Yet Another Python Formatter.
`yew-fmt` - Code formatter for the Yew framework.
`yq` - YAML/JSON processor
`zigfmt` - Reformat Zig source into canonical form.
`zprint` - Formatter for Clojure and EDN.
================================================================================
vim:tw=80:ts=2:ft=help:norl:syntax=help:

View File

@ -0,0 +1,108 @@
# Formatter Options
<!-- TOC -->
- [injected](#injected)
- [prettier](#prettier)
- [rustfmt](#rustfmt)
- [yew-fmt](#yew-fmt)
<!-- /TOC -->
All formatters can be customized by directly changing the command, args, or other values (see [customizing formatters](../README.md#customizing-formatters)). Some formatters have a bit more advanced logic built in to those functions and expose additional configuration options. You can pass these values in like so:
```lua
-- Customize the "injected" formatter
require("conform").formatters.injected = {
-- Set the options field
options = {
-- Set individual option values
ignore_errors = true,
lang_to_formatters = {
json = { "jq" },
},
},
}
```
<!-- OPTIONS -->
## injected
```lua
options = {
-- Set to true to ignore errors
ignore_errors = false,
-- Map of treesitter language to file extension
-- A temporary file name with this extension will be generated during formatting
-- because some formatters care about the filename.
lang_to_ext = {
bash = "sh",
c_sharp = "cs",
elixir = "exs",
javascript = "js",
julia = "jl",
latex = "tex",
markdown = "md",
python = "py",
ruby = "rb",
rust = "rs",
teal = "tl",
typescript = "ts",
},
-- Map of treesitter language to formatters to use
-- (defaults to the value from formatters_by_ft)
lang_to_formatters = {},
}
```
## prettier
```lua
options = {
-- Use a specific prettier parser for a filetype
-- Otherwise, prettier will try to infer the parser from the file name
ft_parsers = {
-- javascript = "babel",
-- javascriptreact = "babel",
-- typescript = "typescript",
-- typescriptreact = "typescript",
-- vue = "vue",
-- css = "css",
-- scss = "scss",
-- less = "less",
-- html = "html",
-- json = "json",
-- jsonc = "json",
-- yaml = "yaml",
-- markdown = "markdown",
-- ["markdown.mdx"] = "mdx",
-- graphql = "graphql",
-- handlebars = "glimmer",
},
-- Use a specific prettier parser for a file extension
ext_parsers = {
-- qmd = "markdown",
},
}
```
## rustfmt
```lua
options = {
-- The default edition of Rust to use when no Cargo.toml file is found
default_edition = "2021",
}
```
## yew-fmt
```lua
options = {
-- The default edition of Rust to use when no Cargo.toml file is found
default_edition = "2021",
}
```
<!-- /OPTIONS -->

View File

@ -0,0 +1,180 @@
# Recipes
<!-- TOC -->
- [Format command](#format-command)
- [Autoformat with extra features](#autoformat-with-extra-features)
- [Command to toggle format-on-save](#command-to-toggle-format-on-save)
- [Automatically run slow formatters async](#automatically-run-slow-formatters-async)
- [Lazy loading with lazy.nvim](#lazy-loading-with-lazynvim)
<!-- /TOC -->
## Format command
Define a command to run async formatting
```lua
vim.api.nvim_create_user_command("Format", function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
["end"] = { args.line2, end_line:len() },
}
end
require("conform").format({ async = true, lsp_fallback = true, range = range })
end, { range = true })
```
## Autoformat with extra features
If you want more complex logic than the basic `format_on_save` option allows, you can use a function instead.
<!-- AUTOFORMAT -->
```lua
-- if format_on_save is a function, it will be called during BufWritePre
require("conform").setup({
format_on_save = function(bufnr)
-- Disable autoformat on certain filetypes
local ignore_filetypes = { "sql", "java" }
if vim.tbl_contains(ignore_filetypes, vim.bo[bufnr].filetype) then
return
end
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
-- Disable autoformat for files in a certain path
local bufname = vim.api.nvim_buf_get_name(bufnr)
if bufname:match("/node_modules/") then
return
end
-- ...additional logic...
return { timeout_ms = 500, lsp_fallback = true }
end,
})
-- There is a similar affordance for format_after_save, which uses BufWritePost.
-- This is good for formatters that are too slow to run synchronously.
require("conform").setup({
format_after_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
-- ...additional logic...
return { lsp_fallback = true }
end,
})
```
<!-- /AUTOFORMAT -->
## Command to toggle format-on-save
Create user commands to quickly enable/disable autoformatting
```lua
require("conform").setup({
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_fallback = true }
end,
})
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = "Disable autoformat-on-save",
bang = true,
})
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Re-enable autoformat-on-save",
})
```
## Automatically run slow formatters async
This snippet will automatically detect which formatters take too long to run synchronously and will run them async on save instead.
```lua
local slow_format_filetypes = {}
require("conform").setup({
format_on_save = function(bufnr)
if slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
local function on_format(err)
if err and err:match("timeout$") then
slow_format_filetypes[vim.bo[bufnr].filetype] = true
end
end
return { timeout_ms = 200, lsp_fallback = true }, on_format
end,
format_after_save = function(bufnr)
if not slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
return { lsp_fallback = true }
end,
})
```
## Lazy loading with lazy.nvim
Here is the recommended config for lazy-loading using lazy.nvim
```lua
return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
-- Customize or remove this keymap to your liking
"<leader>f",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
mode = "",
desc = "Format buffer",
},
},
-- Everything in opts will be passed to setup()
opts = {
-- Define your formatters
formatters_by_ft = {
lua = { "stylua" },
python = { "isort", "black" },
javascript = { { "prettierd", "prettier" } },
},
-- Set up format-on-save
format_on_save = { timeout_ms = 500, lsp_fallback = true },
-- Customize formatters
formatters = {
shfmt = {
prepend_args = { "-i", "2" },
},
},
},
init = function()
-- If you want the formatexpr, here is the place to set it
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
}
```

View File

@ -0,0 +1,66 @@
local M = {}
---@class conform.Error
---@field code conform.ERROR_CODE
---@field message string
---@field debounce_message? boolean
---@enum conform.ERROR_CODE
M.ERROR_CODE = {
-- Command was passed invalid arguments
INVALID_ARGS = 1,
-- Command was not executable
NOT_EXECUTABLE = 2,
-- Error occurred during when calling jobstart
JOBSTART = 3,
-- Command timed out during execution
TIMEOUT = 4,
-- Command was pre-empted by another call to format
INTERRUPTED = 5,
-- Command produced an error during execution
RUNTIME = 6,
-- Asynchronous formatter results were discarded due to a concurrent modification
CONCURRENT_MODIFICATION = 7,
}
---@param code conform.ERROR_CODE
---@return integer
M.level_for_code = function(code)
if code == M.ERROR_CODE.CONCURRENT_MODIFICATION then
return vim.log.levels.INFO
elseif code == M.ERROR_CODE.TIMEOUT or code == M.ERROR_CODE.INTERRUPTED then
return vim.log.levels.WARN
else
return vim.log.levels.ERROR
end
end
---Returns true if the error occurred while attempting to run the formatter
---@param code conform.ERROR_CODE
---@return boolean
M.is_execution_error = function(code)
return code == M.ERROR_CODE.RUNTIME
or code == M.ERROR_CODE.NOT_EXECUTABLE
or code == M.ERROR_CODE.INVALID_ARGS
or code == M.ERROR_CODE.JOBSTART
end
---@param err1? conform.Error
---@param err2? conform.Error
---@return nil|conform.Error
M.coalesce = function(err1, err2)
if not err1 then
return err2
elseif not err2 then
return err1
end
local level1 = M.level_for_code(err1.code)
local level2 = M.level_for_code(err2.code)
if level2 > level1 then
return err2
else
return err1
end
end
return M

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://kamadorueda.com/alejandra/",
description = "The Uncompromising Nix Code Formatter.",
},
command = "alejandra",
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/klauspost/asmfmt",
description = "Go Assembler Formatter",
},
command = "asmfmt",
stdin = true,
}

View File

@ -0,0 +1,11 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://ast-grep.github.io/",
description = "A CLI tool for code structural search, lint and rewriting. Written in Rust.",
},
command = "ast-grep",
args = { "scan", "--update-all", "$FILENAME" },
stdin = false,
exit_codes = { 0, 5 }, -- 5 = no config file exists
}

View File

@ -0,0 +1,14 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://astyle.sourceforge.net/astyle.html",
description = "A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective-C, C#, and Java Source Code.",
},
command = "astyle",
args = { "--quiet" },
cwd = util.root_file({
".astylerc",
"_astylerc",
}),
}

View File

@ -0,0 +1,12 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://auto-optional.daanluttik.nl/",
description = "Adds the Optional type-hint to arguments where the default value is None.",
},
command = "auto-optional",
args = {
"$FILENAME",
},
stdin = false,
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/huacnlee/autocorrect",
description = "A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuations between CJK.",
},
command = "autocorrect",
args = { "--stdin" },
stdin = true,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/PyCQA/autoflake",
description = "Removes unused imports and unused variables as reported by pyflakes.",
},
command = "autoflake",
args = { "--stdin-display-name", "$FILENAME", "-" },
}

View File

@ -0,0 +1,12 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/hhatto/autopep8",
description = "A tool that automatically formats Python code to conform to the PEP 8 style guide.",
},
command = "autopep8",
args = { "-" },
range_args = function(self, ctx)
return { "-", "--line-range", tostring(ctx.range.start[1]), tostring(ctx.range["end"][1]) }
end,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://www.gnu.org/software/gawk/manual/gawk.html",
description = "Format awk programs with awk",
},
command = "awk",
args = { "-f", "-", "-o-" },
}

View File

@ -0,0 +1,11 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://beancount.github.io/docs/running_beancount_and_generating_reports.html#bean-format",
description = "Reformat Beancount files to right-align all the numbers at the same, minimal column.",
},
command = "bean-format",
args = {
"-",
},
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/lovesegfault/beautysh",
description = "A Bash beautifier for the masses.",
},
command = "beautysh",
args = { "-" },
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/FlamingTempura/bibtex-tidy",
description = "Cleaner and Formatter for BibTeX files.",
},
command = "bibtex-tidy",
stdin = true,
args = { "--quiet" },
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/Azure/bicep",
description = "Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively.",
},
command = "bicep",
args = { "format", "--stdout", "$FILENAME" },
}

View File

@ -0,0 +1,15 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/biomejs/biome",
description = "A toolchain for web projects, aimed to provide functionalities to maintain them.",
},
command = util.from_node_modules("biome"),
stdin = true,
args = { "check", "--apply", "--stdin-file-path", "$FILENAME" },
cwd = util.root_file({
"biome.json",
"biome.jsonc",
}),
}

View File

@ -0,0 +1,15 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/biomejs/biome",
description = "A toolchain for web projects, aimed to provide functionalities to maintain them.",
},
command = util.from_node_modules("biome"),
stdin = true,
args = { "format", "--stdin-file-path", "$FILENAME" },
cwd = util.root_file({
"biome.json",
"biome.jsonc",
}),
}

View File

@ -0,0 +1,19 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/psf/black",
description = "The uncompromising Python code formatter.",
},
command = "black",
args = {
"--stdin-filename",
"$FILENAME",
"--quiet",
"-",
},
cwd = util.root_file({
-- https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file
"pyproject.toml",
}),
}

View File

@ -0,0 +1,12 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/shufo/blade-formatter",
description = "An opinionated blade template formatter for Laravel that respects readability.",
},
command = "blade-formatter",
args = { "--stdin" },
stdin = true,
cwd = util.root_file({ "composer.json", "composer.lock" }),
}

View File

@ -0,0 +1,21 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/grantjenks/blue",
description = "The slightly less uncompromising Python code formatter.",
},
command = "blue",
args = {
"--stdin-filename",
"$FILENAME",
"--quiet",
"-",
},
cwd = util.root_file({
"setup.cfg",
"pyproject.toml",
"tox.ini",
".blue",
}),
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://source.android.com/docs/setup/reference/androidbp",
description = "Android Blueprint file formatter.",
},
command = "bpfmt",
args = { "-w", "$FILENAME" },
stdin = false,
}

View File

@ -0,0 +1,11 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://buf.build/docs/reference/cli/buf/format",
description = "A new way of working with Protocol Buffers.",
},
command = "buf",
args = { "format", "-w", "$FILENAME" },
stdin = false,
cwd = require("conform.util").root_file({ "buf.yaml" }),
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/bazelbuild/buildtools/tree/master/buildifier",
description = "buildifier is a tool for formatting bazel BUILD and .bzl files with a standard convention.",
},
command = "buildifier",
}

View File

@ -0,0 +1,8 @@
return {
meta = {
url = "https://hackage.haskell.org/package/cabal-fmt",
description = "Format cabal files with cabal-fmt",
},
command = "cabal-fmt",
stdin = true,
}

View File

@ -0,0 +1,15 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/lukas-reineke/cbfmt",
description = "A tool to format codeblocks inside markdown and org documents.",
},
command = "cbfmt",
args = { "--write", "--best-effort", "$FILENAME" },
cwd = util.root_file({
-- https://github.com/lukas-reineke/cbfmt#config
".cbfmt.toml",
}),
stdin = false,
}

View File

@ -0,0 +1,22 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://www.kernel.org/doc/html/latest/process/clang-format.html",
description = "Tool to format C/C++/… code according to a set of rules and heuristics.",
},
command = "clang-format",
args = { "-assume-filename", "$FILENAME" },
range_args = function(self, ctx)
local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range)
local length = end_offset - start_offset
return {
"-assume-filename",
"$FILENAME",
"--offset",
tostring(start_offset),
"--length",
tostring(length),
}
end,
}

View File

@ -0,0 +1,4 @@
-- This was renamed to clang-format
local conf = vim.deepcopy(require("conform.formatters.clang-format"))
conf.meta.deprecated = true
return conf

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/greglook/cljstyle",
description = "Formatter for Clojure code.",
},
command = "cljstyle",
args = { "pipe" },
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/cheshirekow/cmake_format",
description = "Parse cmake listfiles and format them nicely.",
},
command = "cmake-format",
args = { "-" },
}

View File

@ -0,0 +1,15 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/codespell-project/codespell",
description = "Check code for common misspellings.",
},
command = "codespell",
stdin = false,
args = {
"$FILENAME",
"--write-changes",
"--check-hidden", -- conform's temp file is hidden
},
exit_codes = { 0, 65 }, -- code 65 is given when trying to format an ambiguous misspelling
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://crystal-lang.org/",
description = "Format Crystal code.",
},
command = "crystal",
args = { "tool", "format", "-" },
stdin = true,
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/belav/csharpier",
description = "The opinionated C# code formatter.",
},
command = "dotnet-csharpier",
args = { "--write-stdout" },
stdin = true,
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://cuelang.org",
description = "Format CUE files using `cue fmt` command.",
},
command = "cue",
args = { "fmt", "-" },
stdin = true,
}

View File

@ -0,0 +1,35 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/akaihola/darker",
description = "Run black only on changed lines.",
},
command = "darker",
args = function(self, ctx)
-- make sure pre-save doesn't lose changes while post-save respects
-- the revision setting potentially set in pyproject.toml
if vim.bo[ctx.buf].modified then
return {
"--quiet",
"--no-color",
"--stdout",
"--revision",
"HEAD..:STDIN:",
"--stdin-filename",
"$FILENAME",
}
else
return {
"--quiet",
"--no-color",
"--stdout",
"$FILENAME",
}
end
end,
cwd = util.root_file({
-- https://github.com/akaihola/darker#customizing-darker-black-isort-flynt-and-linter-behavior
"pyproject.toml",
}),
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://dart.dev/tools/dart-format",
description = "Replace the whitespace in your program with formatting that follows Dart guidelines.",
},
command = "dart",
args = { "format" },
}

View File

@ -0,0 +1,25 @@
local extensions = {
javascript = "js",
javascriptreact = "jsx",
json = "json",
jsonc = "jsonc",
markdown = "md",
typescript = "ts",
typescriptreact = "tsx",
}
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://deno.land/manual/tools/formatter",
description = "Use [Deno](https://deno.land/) to format TypeScript, JavaScript/JSON and markdown.",
},
command = "deno",
args = function(self, ctx)
return {
"fmt",
"-",
"--ext",
extensions[vim.bo[ctx.buf].filetype],
}
end,
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/dlang-community/dfmt",
description = "Formatter for D source code.",
},
command = "dfmt",
}

View File

@ -0,0 +1,16 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/Riverside-Healthcare/djLint",
description = "✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang.",
},
command = "djlint",
args = {
"--reformat",
"-",
},
cwd = util.root_file({
".djlintrc",
}),
}

View File

@ -0,0 +1,16 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/dprint/dprint",
description = "Pluggable and configurable code formatting platform written in Rust.",
},
command = "dprint",
args = { "fmt", "--stdin", "$FILENAME" },
cwd = util.root_file({
"dprint.json",
".dprint.json",
"dprint.jsonc",
".dprint.jsonc",
}),
}

View File

@ -0,0 +1,18 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/easy-coding-standard/easy-coding-standard",
description = "ecs - Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer.",
},
command = util.find_executable({
"vendor/bin/ecs",
}, "ecs"),
args = { "check", "$FILENAME", "--fix", "--no-interaction" },
cwd = util.root_file({
"ecs.php",
}),
require_cwd = true,
stdin = false,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/avh4/elm-format",
description = "elm-format formats Elm source code according to a standard set of rules based on the official [Elm Style Guide](https://elm-lang.org/docs/style-guide).",
},
command = "elm-format",
args = { "--stdin" },
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/nebulab/erb-formatter",
description = "Format ERB files with speed and precision.",
},
command = "erb-format",
args = { "--stdin" },
}

View File

@ -0,0 +1,13 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/mantoni/eslint_d.js/",
description = "Like ESLint, but faster.",
},
command = util.from_node_modules("eslint_d"),
args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" },
cwd = util.root_file({
"package.json",
}),
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/fsprojects/fantomas",
description = "F# source code formatter.",
},
command = "fantomas",
args = { "$FILENAME" },
stdin = false,
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://fishshell.com/docs/current/cmds/fish_indent.html",
description = "Indent or otherwise prettify a piece of fish code.",
},
command = "fish_indent",
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/rhysd/fixjson",
description = "JSON Fixer for Humans using (relaxed) JSON5.",
},
command = "fixjson",
}

View File

@ -0,0 +1,9 @@
--@type conform.FileFormatterConfig
return {
meta = {
url = "https://git.sr.ht/~technomancy/fnlfmt",
description = "A formatter for Fennel code.",
},
command = "fnlfmt",
args = { "-" },
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/foundry-rs/foundry",
description = "Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts.",
},
command = "forge",
args = { "fmt", "$FILENAME" },
stdin = false,
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://hackage.haskell.org/package/fourmolu",
description = "A fork of ormolu that uses four space indentation and allows arbitrary configuration.",
},
command = "fourmolu",
args = { "--stdin-input-file", "$FILENAME" },
stdin = true,
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/daixiang0/gci",
description = "GCI, a tool that controls Go package import order and makes it always deterministic.",
},
command = "gci",
args = { "write", "--skip-generated", "--skip-vendor", "$FILENAME" },
stdin = false,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/Scony/godot-gdscript-toolkit",
description = "A formatter for Godot's gdscript.",
},
command = "gdformat",
args = { "-" },
}

View File

@ -0,0 +1,11 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/BlankSpruce/gersemi",
description = "A formatter to make your CMake code the real treasure.",
},
command = "gersemi",
args = { "--quiet", "-" },
cwd = util.root_file({ ".gersemirc" }),
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/gleam-lang/gleam",
description = "⭐️ A friendly language for building type-safe, scalable systems!",
},
command = "gleam",
args = { "format", "--stdin" },
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://gn.googlesource.com/gn/",
description = "gn build system.",
},
command = "gn",
args = { "format", "--stdin" },
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://pkg.go.dev/cmd/gofmt",
description = "Formats go programs.",
},
command = "gofmt",
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/mvdan/gofumpt",
description = "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.",
},
command = "gofumpt",
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/incu6us/goimports-reviser",
description = "Right imports sorting & code formatting tool (goimports alternative).",
},
command = "goimports-reviser",
args = { "-format", "$FILENAME" },
stdin = false,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://pkg.go.dev/golang.org/x/tools/cmd/goimports",
description = "Updates your Go import lines, adding missing ones and removing unreferenced ones.",
},
command = "goimports",
args = { "-srcdir", "$DIRNAME" },
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/segmentio/golines",
description = "A golang formatter that fixes long lines.",
},
command = "golines",
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/google/google-java-format",
description = "Reformats Java source code according to Google Java Style.",
},
command = "google-java-format",
args = { "-" },
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/hashicorp/hcl",
description = "A formatter for HCL files.",
},
command = "hclfmt",
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/threedaymonk/htmlbeautifier",
description = "A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.",
},
command = "htmlbeautifier",
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://www.gnu.org/software/indent/",
description = "GNU Indent.",
},
command = "indent",
stdin = true,
}

View File

@ -0,0 +1,37 @@
local M = {}
local uv = vim.uv or vim.loop
---@private
---This is used for documentation generation
M.list_all_formatters = function()
local ret = {}
for path in vim.gsplit(vim.o.runtimepath, ",", { plain = true }) do
local formatter_path = path .. "/lua/conform/formatters"
local formatter_dir = uv.fs_opendir(formatter_path)
if formatter_dir then
local entries = uv.fs_readdir(formatter_dir)
while entries do
for _, entry in ipairs(entries) do
if entry.name ~= "init.lua" then
local basename = string.match(entry.name, "^(.*)%.lua$")
local module = require("conform.formatters." .. basename)
local module_data = vim.deepcopy(module.meta)
module_data.has_options = module.options ~= nil
ret[basename] = module_data
end
end
entries = uv.fs_readdir(formatter_dir)
end
uv.fs_closedir(formatter_dir)
end
end
return ret
end
-- A little metatable magic to allow accessing formatters like
-- require("conform.formatters").prettier
return setmetatable(M, {
__index = function(_, k)
return require("conform.formatters." .. k)
end,
})

View File

@ -0,0 +1,324 @@
---@param range? conform.Range
---@param start_lnum integer
---@param end_lnum integer
---@return boolean
local function in_range(range, start_lnum, end_lnum)
return not range or (start_lnum <= range["end"][1] and range["start"][1] <= end_lnum)
end
---@param lines string[]
---@param language? string The language of the buffer
---@return string?
local function get_indent(lines, language)
local indent = nil
-- Handle markdown code blocks that are inside blockquotes
-- > ```lua
-- > local x = 1
-- > ```
local pattern = language == "markdown" and "^>?%s*" or "^%s*"
for _, line in ipairs(lines) do
if line ~= "" then
local whitespace = line:match(pattern)
if whitespace == "" then
return nil
elseif not indent or whitespace:len() < indent:len() then
indent = whitespace
end
end
end
return indent
end
---@class (exact) conform.Injected.Surrounding
---@field indent string?
---@field postfix string?
---Remove leading indentation from lines and return the indentation string
---@param lines string[]
---@param language? string The language of the buffer
---@return conform.Injected.Surrounding
local function remove_surrounding(lines, language)
local surrounding = {}
if lines[#lines]:match("^%s*$") then
surrounding.postfix = lines[#lines]
table.remove(lines)
end
local indent = get_indent(lines, language)
if not indent then
return surrounding
end
local sub_start = indent:len() + 1
for i, line in ipairs(lines) do
if line ~= "" then
lines[i] = line:sub(sub_start)
end
end
surrounding.indent = indent
return surrounding
end
---@param lines string[]?
---@param surrounding conform.Injected.Surrounding
local function restore_surrounding(lines, surrounding)
if not lines then
return
end
local indent = surrounding.indent
if indent then
for i, line in ipairs(lines) do
if line ~= "" then
lines[i] = indent .. line
end
end
end
local postfix = surrounding.postfix
if postfix then
table.insert(lines, postfix)
end
end
---@class LangRange
---@field [1] string language
---@field [2] integer start lnum
---@field [3] integer start col
---@field [4] integer end lnum
---@field [5] integer end col
---@param ranges LangRange[]
---@param range LangRange
local function accum_range(ranges, range)
local last_range = ranges[#ranges]
if last_range then
if last_range[1] == range[1] and last_range[4] == range[2] and last_range[5] == range[3] then
last_range[4] = range[4]
last_range[5] = range[5]
return
end
end
table.insert(ranges, range)
end
---@class (exact) conform.InjectedFormatterOptions
---@field ignore_errors boolean
---@field lang_to_ext table<string, string>
---@field lang_to_formatters table<string, conform.FiletypeFormatter>
---@type conform.FileLuaFormatterConfig
return {
meta = {
url = "doc/advanced_topics.md#injected-language-formatting-code-blocks",
description = "Format treesitter injected languages.",
},
options = {
-- Set to true to ignore errors
ignore_errors = false,
-- Map of treesitter language to file extension
-- A temporary file name with this extension will be generated during formatting
-- because some formatters care about the filename.
lang_to_ext = {
bash = "sh",
c_sharp = "cs",
elixir = "exs",
javascript = "js",
julia = "jl",
latex = "tex",
markdown = "md",
python = "py",
ruby = "rb",
rust = "rs",
teal = "tl",
typescript = "ts",
},
-- Map of treesitter language to formatters to use
-- (defaults to the value from formatters_by_ft)
lang_to_formatters = {},
},
condition = function(self, ctx)
local ok, parser = pcall(vim.treesitter.get_parser, ctx.buf)
-- Require Neovim 0.9 because the treesitter API has changed significantly
---@diagnostic disable-next-line: invisible
return ok and parser._injection_query and vim.fn.has("nvim-0.9") == 1
end,
format = function(self, ctx, lines, callback)
local conform = require("conform")
local errors = require("conform.errors")
local log = require("conform.log")
local util = require("conform.util")
-- Need to add a trailing newline; some parsers need this.
-- For example, if a markdown code block ends at the end of the file, a trailing newline is
-- required otherwise the ``` will be grabbed as part of the injected block
local text = table.concat(lines, "\n") .. "\n"
local buf_lang = vim.treesitter.language.get_lang(vim.bo[ctx.buf].filetype)
local ok, parser = pcall(vim.treesitter.get_string_parser, text, buf_lang)
if not ok then
callback("No treesitter parser for buffer")
return
end
---@type conform.InjectedFormatterOptions
local options = self.options
---@param lang string
---@return nil|conform.FiletypeFormatter
local function get_formatters(lang)
return options.lang_to_formatters[lang] or conform.formatters_by_ft[lang]
end
--- Disable diagnostic to pass the typecheck github action
--- This is available on nightly, but not on stable
--- Stable doesn't have any parameters, so it's safe
---@diagnostic disable-next-line: redundant-parameter
parser:parse(true)
local root_lang = parser:lang()
---@type LangRange[]
local regions = {}
for lang, lang_tree in pairs(parser:children()) do
if lang ~= root_lang then
for _, ranges in ipairs(lang_tree:included_regions()) do
for _, region in ipairs(ranges) do
local formatters = get_formatters(lang)
if formatters ~= nil then
-- The types are wrong. included_regions should be Range[][] not integer[][]
---@diagnostic disable-next-line: param-type-mismatch
local start_row, start_col, _, end_row, end_col, _ = unpack(region)
accum_range(regions, { lang, start_row + 1, start_col, end_row + 1, end_col })
end
end
end
end
end
if ctx.range then
regions = vim.tbl_filter(function(region)
return in_range(ctx.range, region[2], region[4])
end, regions)
end
-- Sort from largest start_lnum to smallest
table.sort(regions, function(a, b)
return a[2] > b[2]
end)
log.trace("Injected formatter regions %s", regions)
local replacements = {}
local format_error = nil
local function apply_format_results()
if format_error then
-- Find all of the conform errors in the replacements table and remove them
local i = 1
while i <= #replacements do
if replacements[i].code then
table.remove(replacements, i)
else
i = i + 1
end
end
if options.ignore_errors then
format_error = nil
end
end
local formatted_lines = vim.deepcopy(lines)
for _, replacement in ipairs(replacements) do
local start_lnum, start_col, end_lnum, end_col, new_lines = unpack(replacement)
local prefix = formatted_lines[start_lnum]:sub(1, start_col)
local suffix = formatted_lines[end_lnum]:sub(end_col + 1)
new_lines[1] = prefix .. new_lines[1]
new_lines[#new_lines] = new_lines[#new_lines] .. suffix
for _ = start_lnum, end_lnum do
table.remove(formatted_lines, start_lnum)
end
for i = #new_lines, 1, -1 do
table.insert(formatted_lines, start_lnum, new_lines[i])
end
end
callback(format_error, formatted_lines)
end
local num_format = 0
local tmp_bufs = {}
local formatter_cb = function(err, idx, region, input_lines, new_lines)
if err then
format_error = errors.coalesce(format_error, err)
replacements[idx] = err
else
-- If the original lines started/ended with a newline, preserve that newline.
-- Many formatters will trim them, but they're important for the document structure.
if input_lines[1] == "" and new_lines[1] ~= "" then
table.insert(new_lines, 1, "")
end
if input_lines[#input_lines] == "" and new_lines[#new_lines] ~= "" then
table.insert(new_lines, "")
end
replacements[idx] = { region[2], region[3], region[4], region[5], new_lines }
end
num_format = num_format - 1
if num_format == 0 then
for buf in pairs(tmp_bufs) do
vim.api.nvim_buf_delete(buf, { force = true })
end
apply_format_results()
end
end
local last_start_lnum = #lines + 1
for i, region in ipairs(regions) do
local lang = region[1]
local start_lnum = region[2]
local start_col = region[3]
local end_lnum = region[4]
local end_col = region[5]
-- Ignore regions that overlap (contain) other regions
if end_lnum < last_start_lnum then
num_format = num_format + 1
last_start_lnum = start_lnum
local input_lines = util.tbl_slice(lines, start_lnum, end_lnum)
input_lines[#input_lines] = input_lines[#input_lines]:sub(1, end_col)
if start_col > 0 then
input_lines[1] = input_lines[1]:sub(start_col + 1)
end
local ft_formatters = assert(get_formatters(lang))
---@type string[]
local formatter_names
if type(ft_formatters) == "function" then
formatter_names = ft_formatters(ctx.buf)
else
local formatters = require("conform").resolve_formatters(ft_formatters, ctx.buf, false)
formatter_names = vim.tbl_map(function(f)
return f.name
end, formatters)
end
local idx = num_format
log.debug("Injected format %s:%d:%d: %s", lang, start_lnum, end_lnum, formatter_names)
log.trace("Injected format lines %s", input_lines)
local surrounding = remove_surrounding(input_lines, buf_lang)
-- Create a temporary buffer. This is only needed because some formatters rely on the file
-- extension to determine a run mode (see https://github.com/stevearc/conform.nvim/issues/194)
-- This is using lang_to_ext to map the language name to the file extension, and falls back
-- to using the language name itself.
local extension = options.lang_to_ext[lang] or lang
local buf =
vim.fn.bufadd(string.format("%s.%d.%s", vim.api.nvim_buf_get_name(ctx.buf), i, extension))
-- Actually load the buffer to set the buffer context which is required by some formatters such as `filetype`
vim.fn.bufload(buf)
tmp_bufs[buf] = true
local format_opts = { async = true, bufnr = buf, quiet = true }
conform.format_lines(formatter_names, input_lines, format_opts, function(err, new_lines)
log.trace("Injected %s:%d:%d formatted lines %s", lang, start_lnum, end_lnum, new_lines)
-- Preserve indentation in case the code block is indented
restore_surrounding(new_lines, surrounding)
vim.schedule_wrap(formatter_cb)(err, idx, region, input_lines, new_lines)
end)
end
end
if num_format == 0 then
apply_format_results()
end
end,
-- TODO this is kind of a hack. It's here to ensure all_support_range_formatting is set properly.
-- Should figure out a better way to do this.
range_args = true,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://inko-lang.org/",
description = "A language for building concurrent software with confidence",
},
command = "inko",
args = { "fmt", "-" },
}

View File

@ -0,0 +1,38 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/PyCQA/isort",
description = "Python utility / library to sort imports alphabetically and automatically separate them into sections and by type.",
},
command = "isort",
args = function(self, ctx)
-- isort doesn't do a good job of auto-detecting the line endings.
local line_ending
local file_format = vim.bo[ctx.buf].fileformat
if file_format == "dos" then
line_ending = "\r\n"
elseif file_format == "mac" then
line_ending = "\r"
else
line_ending = "\n"
end
return {
"--stdout",
"--line-ending",
line_ending,
"--filename",
"$FILENAME",
"-",
}
end,
cwd = util.root_file({
-- https://pycqa.github.io/isort/docs/configuration/config_files.html
".isort.cfg",
"pyproject.toml",
"setup.py",
"setup.cfg",
"tox.ini",
".editorconfig",
}),
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/candid82/joker",
description = "Small Clojure interpreter, linter and formatter.",
},
command = "joker",
args = { "--format", "--write", "-" },
}

View File

@ -0,0 +1,8 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/stedolan/jq",
description = "Command-line JSON processor.",
},
command = "jq",
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/google/go-jsonnet/tree/master/cmd/jsonnetfmt",
description = "jsonnetfmt is a command line tool to format jsonnet files.",
},
command = "jsonnetfmt",
args = { "-" },
stdin = true,
}

View File

@ -0,0 +1,9 @@
return {
meta = {
url = "https://github.com/casey/just",
description = "Format Justfile.",
},
command = "just",
args = { "--fmt", "--unstable", "-f", "$FILENAME" },
stdin = false,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/facebook/ktfmt",
description = "Reformats Kotlin source code to comply with the common community standard conventions.",
},
command = "ktfmt",
args = { "-" },
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://ktlint.github.io/",
description = "An anti-bikeshedding Kotlin linter with built-in formatter.",
},
command = "ktlint",
args = { "--format", "--stdin", "--log-level=none" },
}

View File

@ -0,0 +1,10 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/cmhughes/latexindent.pl",
description = "A perl script for formatting LaTeX files that is generally included in major TeX distributions.",
},
command = "latexindent",
args = { "-" },
stdin = true,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/bram209/leptosfmt",
description = "A formatter for the Leptos view! macro.",
},
command = "leptosfmt",
args = { "--stdin" },
}

View File

@ -0,0 +1,11 @@
local util = require("conform.util")
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/savonet/liquidsoap-prettier",
description = "A binary to format Liquidsoap scripts",
},
command = util.from_node_modules("liquidsoap-prettier"),
args = { "-w", "$FILENAME" },
stdin = false,
}

View File

@ -0,0 +1,15 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/jonschlinkert/markdown-toc",
description = "API and CLI for generating a markdown TOC (table of contents) for a README or any markdown files.",
},
command = "markdown-toc",
stdin = false,
args = function(self, ctx)
-- use the indentation set in the current buffer, effectively allowing us to
-- use values from .editorconfig
local indent = vim.bo[ctx.buf].expandtab and (" "):rep(vim.bo[ctx.buf].tabstop) or "\t"
return { "--indent=" .. indent, "-i", "$FILENAME" }
end,
}

View File

@ -0,0 +1,11 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/DavidAnson/markdownlint-cli2",
description = "A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library.",
},
command = "markdownlint-cli2",
args = { "--fix", "$FILENAME" },
exit_codes = { 0, 1 }, -- code 1 is returned when linting/formatter was successful and there were errors
stdin = false,
}

View File

@ -0,0 +1,11 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/DavidAnson/markdownlint",
description = "A Node.js style checker and lint tool for Markdown/CommonMark files.",
},
command = "markdownlint",
args = { "--fix", "$FILENAME" },
exit_codes = { 0, 1 }, -- code 1 is given when trying a file that includes non-autofixable errors
stdin = false,
}

View File

@ -0,0 +1,9 @@
---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/executablebooks/mdformat",
description = "An opinionated Markdown formatter.",
},
command = "mdformat",
args = { "-" },
}

Some files were not shown because too many files have changed in this diff Show More