Files
nvim-cmp/lua/cmp/utils/pattern.lua
hituzi no sippo a58712bf16 fix StyLua command (#190)
* style: fix StyLua glob pattern

* style: fix style with StyLua

run './utils/stylua --config-path stylua.toml --glob 'lua/**/*.lua' -- lua'
2021-09-11 20:18:44 +09:00

29 lines
493 B
Lua

local pattern = {}
pattern._regexes = {}
pattern.regex = function(p)
if not pattern._regexes[p] then
pattern._regexes[p] = vim.regex(p)
end
return pattern._regexes[p]
end
pattern.offset = function(p, text)
local s, e = pattern.regex(p):match_str(text)
if s then
return s + 1, e + 1
end
return nil, nil
end
pattern.matchstr = function(p, text)
local s, e = pattern.offset(p, text)
if s then
return string.sub(text, s, e)
end
return nil
end
return pattern