diff options
| author | Mike Vink <mike1994vink@gmail.com> | 2022-10-29 16:26:38 +0200 |
|---|---|---|
| committer | Mike Vink <mike1994vink@gmail.com> | 2022-10-29 16:26:38 +0200 |
| commit | 18a37da86840c9e111172f5f24ceebe227ca56ed (patch) | |
| tree | 42bd007c928fb5a32c309985b17c03147390cf23 /neovim/lua/vimrc/utils.lua | |
| parent | a39a1c7cb6a81764bb5c05155243c16c2ddfb7f6 (diff) | |
add neovim lua files
Diffstat (limited to 'neovim/lua/vimrc/utils.lua')
| -rw-r--r-- | neovim/lua/vimrc/utils.lua | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/neovim/lua/vimrc/utils.lua b/neovim/lua/vimrc/utils.lua new file mode 100644 index 0000000..386efd2 --- /dev/null +++ b/neovim/lua/vimrc/utils.lua @@ -0,0 +1,70 @@ +local vim = vim +local cmd = vim.cmd +local M = {} + +-- paths {{{ +-- }}} +-- +-- logging {{{ +function M.log_error(msg, source, persist) + if source then + msg = "[" .. source .. "] " .. msg + end + cmd [[echohl ErrorMsg]] + if persist then + cmd("echomsg '" .. msg .. "'") + else + cmd("echo '" .. msg .. "'") + end + cmd [[echohl Normal]] +end + +function M.log_warning(msg, source, persist) + if source then + msg = "[" .. source .. "]" .. msg + end + msg = string.gsub(msg, "'", '"') + cmd [[echohl WarningMsg]] + if persist then + cmd("echomsg '" .. msg .. "'") + else + cmd("echo '" .. msg .. "'") + end + cmd [[echohl Normal]] +end +-- }}} + +-- tables {{{ +function table.filter() + print"hi" +end + +function table.keys(tbl) + local k = {} + for key, val in pairs(tbl) do + table.insert(k, key) + end + return k +end + +-- }}} + +-- string {{{ +function string.join(str, join_token) + local j = "" + local join = join_token or "" + if #str == 1 then + return str[1] + end + for i, token in ipairs(str) do + if i > 1 then + j = j .. join .. token + else + j = j .. token + end + end + return j +end +-- }}} +return M +-- vim: fdm=marker |
