chore(Prompt): remove unused function

pull/14/head
Iron-E 2 years ago
parent 1933c1d6dc
commit dfcc57dd49
No known key found for this signature in database
GPG Key ID: 19B71B7B7B021D22

@ -123,57 +123,6 @@ end
*/
--]]
------------------------------------------------------
--[[ SUMMARY:
* Provide completions for a `libmodal.prompt`.
]]
--[[ PARAMS:
* `completions` => the list of completions.
]]
--[[ RETURNS:
* A function that accepts:
* `argLead` => the current line being edited, stops at the cursor.
* `cmdLine` => the current line being edited
* `cursorPos` => the position of the cursor
* Used for `input()` VimL.
]]
------------------------------------------------------
function Prompt.createCompletionsProvider(completions)
return function(argLead, cmdLine, _)
if string.len(cmdLine) < 1 then return completions
end
-- replace conjoining characters with spaces.
local spacedArgLead = argLead
for _, replacement in ipairs(_REPLACEMENTS) do
-- _REPLACEMENTS are already `vim.pesc`aped
spacedArgLead, _ = string.gsub(spacedArgLead, replacement, ' ')
end
-- split the spaced version of `argLead`.
local splitArgLead = vim.split(spacedArgLead, ' ', true)
--[[ make sure the user is in a position were this function
will provide accurate completions.]]
if #splitArgLead > 1 then return nil
end
-- get the word selected by the user. (don't compare case)
local word = string.upper(splitArgLead[1])
-- get all matches from the completions list.
local matches = {}
for _, completion in ipairs(completions) do
-- test if `word` is inside of `completions`:`v`, ignoring case.
local escapedCompletion, _ = vim.pesc(string.upper(completion))
if string.match(escapedCompletion, word) then
matches[#matches + 1] = completion -- preserve case when providing completions.
end
end
return matches
end
end
-------------------------------------------
--[[ SUMMARY:
* Enter a prompt.

Loading…
Cancel
Save