presser.nvim/lua/presser/utils.lua
TheOnePath 6e3e7f9d2d
Moved presser/ -> lua/presser/
Created new director lua/ and moved presser/ into the subdirectory.
This is to align with other standard developments of Neovim extensions.
2023-01-13 16:40:43 +00:00

40 lines
749 B
Lua

local M = {}
M.iter_table_dump = function ( arr )
for k, v in pairs(arr) do
print("Table:", k, v)
end
end
local escape_chars = function ( text )
return string.gsub(text, "[%(|%)|\\|%[|%]|%-|%{%}|%?|%+|%*|%^|%$|%.]", {
["\\"] = "\\\\",
["-"] = "\\-",
["("] = "\\(",
[")"] = "\\)",
["["] = "\\[",
["]"] = "\\]",
["{"] = "\\{",
["}"] = "\\}",
["?"] = "\\?",
["+"] = "\\+",
["*"] = "\\*",
["^"] = "\\^",
["$"] = "\\$",
["."] = "\\.",
})
end
-- :@dev: clean the text once it has been fetched from buffer
M.clean_buf = function ( text )
if not type(text) == "string" or text == nil then
return ""
end
return escape_chars( text )
:match( "^%s*(.-)%s*$" )
end
return M