diff --git a/.gitignore b/.gitignore index 547a6d7..876b9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ # Lua /luarocks -/lua /lua_modules /.luarocks # OS -.DS_Store \ No newline at end of file +.DS_Store diff --git a/lua/plugin-name/init.lua b/lua/plugin-name/init.lua new file mode 100644 index 0000000..1fa11d1 --- /dev/null +++ b/lua/plugin-name/init.lua @@ -0,0 +1,9 @@ +local table_utils = require("utils.table") +local static = require("plugin-name.static") +local main = {} + +function main.setup(config) + static.config = table_utils.merge(static.config, config) +end + +return main diff --git a/lua/plugin-name/static.lua b/lua/plugin-name/static.lua new file mode 100644 index 0000000..ef6f882 --- /dev/null +++ b/lua/plugin-name/static.lua @@ -0,0 +1,3 @@ +return { + config = {}, +} diff --git a/lua/plugin-name/utils/command.lua b/lua/plugin-name/utils/command.lua new file mode 100644 index 0000000..4dc8f28 --- /dev/null +++ b/lua/plugin-name/utils/command.lua @@ -0,0 +1,12 @@ +local command_util = {} + +function command_util.exec_command(command, mode) + local handle = assert(io.popen(command, mode)) + local origin = assert(handle:read("*a")) + + handle:close() + + return origin +end + +return command_util diff --git a/lua/plugin-name/utils/list.lua b/lua/plugin-name/utils/list.lua new file mode 100644 index 0000000..ee2d2de --- /dev/null +++ b/lua/plugin-name/utils/list.lua @@ -0,0 +1,23 @@ +local list_utils = {} + +function list_utils.find(list, predicate) + for _, value in ipairs(list) do + if predicate(value) then + return value + end + end + + return nil +end + +function list_utils.some(list, predicate) + return list_utils.find(list, predicate) ~= nil +end + +function list_utils.includes(list, value) + return list_utils.find(list, function(item) + return item == value + end) ~= nil +end + +return list_utils diff --git a/lua/plugin-name/utils/string.lua b/lua/plugin-name/utils/string.lua new file mode 100644 index 0000000..d15cac2 --- /dev/null +++ b/lua/plugin-name/utils/string.lua @@ -0,0 +1,15 @@ +local string_util = {} + +function string_util.trim(str) + return str:gsub("%s+", "") +end + +function string_util.escape(str) + return str:gsub("[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%1") +end + +function string_util.ends_with(str, suffix) + return str:sub(-#suffix) == suffix +end + +return string_util diff --git a/lua/plugin-name/utils/table.lua b/lua/plugin-name/utils/table.lua new file mode 100644 index 0000000..a139369 --- /dev/null +++ b/lua/plugin-name/utils/table.lua @@ -0,0 +1,17 @@ +local table_utils = {} + +function table_utils.assign(t, props) + for k, v in pairs(props) do + t[k] = v + end +end + +function table_utils.merge(t1, t2) + for k, v in pairs(t2) do + t1[k] = v + end + + return t1 +end + +return table_utils