diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | doc/conform.txt | 1 | ||||
-rw-r--r-- | lua/conform/formatters/format-queries.lua | 21 |
3 files changed, 23 insertions, 0 deletions
@@ -225,6 +225,7 @@ You can view this list in vim with `:help conform-formatters` - [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. +- [format-queries](https://github.com/nvim-treesitter/nvim-treesitter/blob/main/CONTRIBUTING.md#formatting) - Tree-sitter query formatter. - [fourmolu](https://hackage.haskell.org/package/fourmolu) - A fork of ormolu that uses four space indentation and allows arbitrary configuration. - [fprettify](https://github.com/fortran-lang/fprettify) - Auto-formatter for modern fortran source code. - [gci](https://github.com/daixiang0/gci) - GCI, a tool that controls Go package import order and makes it always deterministic. diff --git a/doc/conform.txt b/doc/conform.txt index d1ef2b6..8c793fa 100644 --- a/doc/conform.txt +++ b/doc/conform.txt @@ -263,6 +263,7 @@ FORMATTERS *conform-formatter `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. +`format-queries` - Tree-sitter query formatter. `fourmolu` - A fork of ormolu that uses four space indentation and allows arbitrary configuration. `fprettify` - Auto-formatter for modern fortran source code. diff --git a/lua/conform/formatters/format-queries.lua b/lua/conform/formatters/format-queries.lua new file mode 100644 index 0000000..6f7da25 --- /dev/null +++ b/lua/conform/formatters/format-queries.lua @@ -0,0 +1,21 @@ +---@return nil|string +local function get_format_script() + return vim.api.nvim_get_runtime_file("scripts/format-queries.lua", false)[1] +end + +---@type conform.FileFormatterConfig +return { + meta = { + url = "https://github.com/nvim-treesitter/nvim-treesitter/blob/main/CONTRIBUTING.md#formatting", + description = "Tree-sitter query formatter.", + }, + condition = function() + local ok = pcall(vim.treesitter.language.inspect, "query") + return ok and get_format_script() ~= nil + end, + command = "nvim", + args = function() + return { "-l", get_format_script(), "$FILENAME" } + end, + stdin = false, +} |