diff options
author | Bubbet <brett1057228@gmail.com> | 2024-08-08 12:31:36 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 11:31:36 -0700 |
commit | 0f4f299dfea09d2adfd7a1da05149a0844ac8eee (patch) | |
tree | bcd33b2e1c54fceaba6ab927aaded8c9f06c3254 | |
parent | c636af8fb69caea0938e029d161d80a72c15f175 (diff) |
feat: add variable for args to insert the file extension (#510)
* Add support to extensions to arguments.
* Fix formatting errors
* simplify regex
---------
Co-authored-by: Bubbet <bubbet@bubbet.dev>
-rw-r--r-- | lua/conform/runner.lua | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lua/conform/runner.lua b/lua/conform/runner.lua index 2724cd6..3aef5fc 100644 --- a/lua/conform/runner.lua +++ b/lua/conform/runner.lua @@ -48,6 +48,7 @@ M.build_cmd = function(formatter_name, ctx, config) :gsub("$FILENAME", ctx.filename) :gsub("$DIRNAME", ctx.dirname) :gsub("$RELATIVE_FILEPATH", compute_relative_filepath) + :gsub("$EXTENSION", ctx.filename:match(".*(%..*)$") or "") return command .. " " .. interpolated else local cmd = { command } @@ -59,6 +60,8 @@ M.build_cmd = function(formatter_name, ctx, config) v = ctx.dirname elseif v == "$RELATIVE_FILEPATH" then v = compute_relative_filepath() + elseif v == "$EXTENSION" then + v = ctx.filename:match(".*(%..*)$") or "" end table.insert(cmd, v) end |