From 6e4b27a95d146a73142695ac9089e614be2616a8 Mon Sep 17 00:00:00 2001 From: BarrOff <58253563+BarrOff@users.noreply.github.com> Date: Sun, 21 Jan 2024 17:29:38 +0100 Subject: [PATCH] feat(builtins): add vfmt as a formatting builtin --- doc/BUILTINS.md | 17 +++++++++++++++++ lua/null-ls/builtins/formatting/vfmt.lua | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 lua/null-ls/builtins/formatting/vfmt.lua diff --git a/doc/BUILTINS.md b/doc/BUILTINS.md index a9e33fbe..7148b669 100644 --- a/doc/BUILTINS.md +++ b/doc/BUILTINS.md @@ -5114,6 +5114,23 @@ local sources = { null_ls.builtins.formatting.usort } - Command: `usort` - Args: `{ "format", "-" }` +### [vfmt](https://github.com/vlang/v) + +Reformat Vlang source into canonical form. + +#### Usage + +```lua +local sources = { null_ls.builtins.formatting.vfmt } +``` + +#### Defaults + +- Filetypes: `{ "vlang" }` +- Method: `formatting` +- Command: `v` +- Args: `{ "fmt", "-w", "$FILENAME" }` + ### [verible_verilog_format](https://github.com/chipsalliance/verible) The verible-verilog-format formatter manages whitespace in accordance with a particular style. The main goal is to relieve humans of having to manually manage whitespace, wrapping, and indentation, and to provide a tool that can be integrated into any editor to enable editor-independent consistency. diff --git a/lua/null-ls/builtins/formatting/vfmt.lua b/lua/null-ls/builtins/formatting/vfmt.lua new file mode 100644 index 00000000..9726eedf --- /dev/null +++ b/lua/null-ls/builtins/formatting/vfmt.lua @@ -0,0 +1,20 @@ +local h = require("null-ls.helpers") +local methods = require("null-ls.methods") + +local FORMATTING = methods.internal.FORMATTING + +return h.make_builtin({ + name = "vfmt", + meta = { + url = "https://github.com/vlang/v", + description = "Reformat Vlang source into canonical form.", + }, + method = FORMATTING, + filetypes = { "vlang" }, + generator_opts = { + command = "v", + args = { "fmt", "-w", "$FILENAME" }, + to_temp_file = true, + }, + factory = h.formatter_factory, +})