aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/shared.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-06 18:16:57 -0700
committerGitHub <noreply@github.com>2019-09-06 18:16:57 -0700
commit158b78062e9daa65203b4591dae733dd6c11ad2c (patch)
treee6988da22f16062b57d50daeda084bcc489a6a1d /runtime/lua/vim/shared.lua
parent638f2b6dee7439de303bea12dec80240617e8034 (diff)
parent7e1c9598617a140e40a0a22676c0631294617246 (diff)
downloadrneovim-158b78062e9daa65203b4591dae733dd6c11ad2c.tar.gz
rneovim-158b78062e9daa65203b4591dae733dd6c11ad2c.tar.bz2
rneovim-158b78062e9daa65203b4591dae733dd6c11ad2c.zip
Merge #10932 'test: Eliminate expect_err'
Diffstat (limited to 'runtime/lua/vim/shared.lua')
-rw-r--r--runtime/lua/vim/shared.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 75d4a6eee6..cd6f8a04d8 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -178,9 +178,20 @@ local function trim(s)
return s:match('^%s*(.*%S)') or ''
end
+--- Escapes magic chars in a Lua pattern string.
+---
+--@see https://github.com/rxi/lume
+--@param s String to escape
+--@returns %-escaped pattern string
+local function pesc(s)
+ assert(type(s) == 'string')
+ return s:gsub('[%(%)%.%%%+%-%*%?%[%]%^%$]', '%%%1')
+end
+
local module = {
deepcopy = deepcopy,
gsplit = gsplit,
+ pesc = pesc,
split = split,
tbl_contains = tbl_contains,
tbl_extend = tbl_extend,