Skip to content

Commit

Permalink
refactor: replace util with vim.split
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Sep 29, 2023
1 parent 0c7acd7 commit 73a7d54
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lua/dressing/input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 73a7d54

Please sign in to comment.