mirror of
https://github.com/opdavies/toggle-checkbox.nvim.git
synced 2025-01-22 20:07:32 +00:00
refactor: use the variables in more places
This commit is contained in:
parent
acf32d44b0
commit
a3fabd8fa4
|
@ -1,21 +1,21 @@
|
|||
local checked_character = "x"
|
||||
|
||||
local checked_checkbox = "[" .. checked_character .. "]"
|
||||
local checked_checkbox = "%[" .. checked_character .. "%]"
|
||||
local unchecked_checkbox = "%[ %]"
|
||||
|
||||
local line_contains_an_unchecked_checkbox = function(line)
|
||||
return string.find(line, unchecked_checkbox)
|
||||
end
|
||||
|
||||
local checkbox = {}
|
||||
local checkbox = {
|
||||
check = function(line)
|
||||
return line:gsub(unchecked_checkbox, checked_checkbox)
|
||||
end,
|
||||
|
||||
checkbox.check = function(line)
|
||||
return line:gsub("%[ %]", checked_checkbox)
|
||||
end
|
||||
|
||||
checkbox.uncheck = function(line)
|
||||
return line:gsub("%[" .. checked_character .. "%]", unchecked_checkbox)
|
||||
end
|
||||
uncheck = function(line)
|
||||
return line:gsub(checked_checkbox, unchecked_checkbox)
|
||||
end,
|
||||
}
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue