From 73a7d54b5289000108c7f52402a36cf380fced67 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Fri, 29 Sep 2023 09:31:10 -0700 Subject: [PATCH] refactor: replace util with vim.split --- lua/dressing/input.lua | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lua/dressing/input.lua b/lua/dressing/input.lua index 14cdde8..66c2314 100644 --- a/lua/dressing/input.lua +++ b/lua/dressing/input.lua @@ -190,23 +190,15 @@ local function apply_highlight() end end -local function split(string, pattern) - local ret = {} - for token in string.gmatch(string, "[^" .. pattern .. "]+") do - table.insert(ret, token) - end - return ret -end - M.completefunc = function(findstart, base) - if not context.opts or not context.opts.completion then + local completion = context.opts and context.opts.completion + if not completion then return findstart == 1 and 0 or {} end if findstart == 1 then return 0 else - local completion = context.opts.completion - local pieces = split(completion, ",") + local pieces = vim.split(completion, ",", { plain = true }) if pieces[1] == "custom" or pieces[1] == "customlist" then local vimfunc = pieces[2] local ret @@ -224,7 +216,7 @@ M.completefunc = function(findstart, base) ret = vim.fn[vimfunc](base, base, vim.fn.strlen(base)) end if pieces[1] == "custom" then - ret = split(ret, "\n") + ret = vim.split(ret, "\n", { plain = true }) end return ret else