From 6151b3c0e21c2ec65861927037892ae548190f08 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 8 Aug 2022 13:58:47 -0400 Subject: [PATCH] feat: check and uncheck checkboxes --- init.lua | 1 + lua/toggle-checkbox.lua | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 init.lua create mode 100644 lua/toggle-checkbox.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..128359f --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("toggle-checkbox") diff --git a/lua/toggle-checkbox.lua b/lua/toggle-checkbox.lua new file mode 100644 index 0000000..3536cbe --- /dev/null +++ b/lua/toggle-checkbox.lua @@ -0,0 +1,13 @@ +local checked_character = "x" + +local M = {} + +M.check = function(line) + return line:gsub("%[ %]", "[" .. checked_character .. "]") +end + +M.uncheck = function(line) + return line:gsub("%[" .. checked_character .. "%]", "[]") +end + +return M