aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/glob.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/glob.lua')
-rw-r--r--runtime/lua/vim/glob.lua21
1 files changed, 15 insertions, 6 deletions
diff --git a/runtime/lua/vim/glob.lua b/runtime/lua/vim/glob.lua
index 6de2bc3e94..22073b15c8 100644
--- a/runtime/lua/vim/glob.lua
+++ b/runtime/lua/vim/glob.lua
@@ -1,6 +1,6 @@
local lpeg = vim.lpeg
local P, S, V, R, B = lpeg.P, lpeg.S, lpeg.V, lpeg.R, lpeg.B
-local C, Cc, Ct, Cf = lpeg.C, lpeg.Cc, lpeg.Ct, lpeg.Cf
+local C, Cc, Ct, Cf, Cmt = lpeg.C, lpeg.Cc, lpeg.Ct, lpeg.Cf, lpeg.Cmt
local M = {}
@@ -47,13 +47,22 @@ function M.to_lpeg(pattern)
return (-after * P(1)) ^ 0 * after
end
+ -- luacheck: push ignore s
+ local function cut(s, idx, match)
+ return idx, match
+ end
+ -- luacheck: pop
+
local p = P({
'Pattern',
Pattern = V('Elem') ^ -1 * V('End'),
- Elem = Cf(
- (V('DStar') + V('Star') + V('Ques') + V('Class') + V('CondList') + V('Literal'))
- * (V('Elem') + V('End')),
- mul
+ Elem = Cmt(
+ Cf(
+ (V('DStar') + V('Star') + V('Ques') + V('Class') + V('CondList') + V('Literal'))
+ * (V('Elem') + V('End')),
+ mul
+ ),
+ cut
),
DStar = (B(pathsep) + -B(P(1)))
* P('**')
@@ -72,7 +81,7 @@ function M.to_lpeg(pattern)
-- pattern" which in all other cases is the entire succeeding part of the pattern, but at the end of a {}
-- condition means "everything after the {}" where several other options separated by ',' may
-- exist in between that should not be matched by '*'.
- Cond = Cf((V('Ques') + V('Class') + V('Literal') - S(',}')) ^ 1, mul) + Cc(P(0)),
+ Cond = Cmt(Cf((V('Ques') + V('Class') + V('Literal') - S(',}')) ^ 1, mul), cut) + Cc(P(0)),
Literal = P(1) / P,
End = P(-1) * Cc(P(-1)),
})