codesnap.nvim/lua/codesnap/utils/string.lua

38 lines
686 B
Lua
Raw Permalink Normal View History

2024-02-13 06:05:36 +00:00
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
[Release] v1.0.0 (#43) * [Update] apply template * [Feat] update assets files (#35) * [Update] README add packer install config * [Feat] take snapshot via skia engine * [Feat] title component * [Feat] add watermark * [Feat] update padding of code panel * [Remove] pack ci script * [Release] v1.0.0 * [Update] apply template * [Chore] remove unused code * [Update] readme * [Release] v1.0.1 * [Update] apply template * [Update] readme * Update README.md * [Feat] compile nvim-0.9 FFI * [Release] v1.0.2 * [Update] apply template * [Update] README.md * [Feat] add multi platform support * [Feat] add workflow for build target binary package * [Update] files based on generated files by template generator * [Update] files based on generated files by template generator * [Update] files based on generated files by template generator * [Update] files based on generated files by template generator * [Update] files based on generated files by template generator * [Update] files based on generated files by template generator * [Update] files based on generated files by template generator * [Feat] build plugin after released * [Delete] build.yml * [Update] README * [Release] v1.0.3 * [Update] README * [Refactor] editor frame size calculation logic * [Refactor] update margin of watermark * [Feat] preset font family * [Refactor] update component interface * [Update] change theme to onedark * [Refactor] redefine render_error and throw it to lua scope * [Perf] build script * [Refactor] abstract component concept & implement it for all widgets * [Update] README.md --------- Co-authored-by: mistricky <mistricky@users.noreply.github.com>
2024-03-16 17:07:12 +00:00
function string_util.is_str_empty(target)
return target == nil or target == ""
end
function string_util.convert_empty_to_nil(target)
if target == "" then
return nil
else
return target
end
end
2024-04-27 11:07:41 +00:00
function string_util.split(str, delimiter)
local result = {}
for token in string.gmatch(str, "[^" .. delimiter .. "]+") do
table.insert(result, token)
end
return result
end
2024-02-13 06:05:36 +00:00
return string_util