diff --git a/autoload/libmodal.vim b/autoload/libmodal.vim index d79b028..18cb085 100644 --- a/autoload/libmodal.vim +++ b/autoload/libmodal.vim @@ -19,7 +19,7 @@ let s:winOpenOpts = { function! libmodal#_inputWith(indicator, completions) function! LibmodalCompletionsProvider(argLead, cmdLine, cursorPos) abort closure return luaeval( - \ 'require("libmodal/src/Prompt/").createCompletionsProvider(_A[1])(_A[2], _A[3], _A[4])', + \ 'require("libmodal/src/Prompt").createCompletionsProvider(_A[1])(_A[2], _A[3], _A[4])', \ [a:completions, a:argLead, a:cmdLine, a:cursorPos] \) endfunction diff --git a/lua/libmodal/src/Prompt.lua b/lua/libmodal/src/Prompt.lua index da71bf8..c9625af 100644 --- a/lua/libmodal/src/Prompt.lua +++ b/lua/libmodal/src/Prompt.lua @@ -138,16 +138,14 @@ function Prompt.createCompletionsProvider(completions) -- replace conjoining characters with spaces. local spacedArgLead = argLead for _, replacement in ipairs(_REPLACEMENTS) do - spacedArgLead, _ = string.gsub(spacedArgLead, replacement, ' ') + spacedArgLead, _ = string.gsub(spacedArgLead, vim.pesc(replacement), ' ') end -- split the spaced version of `argLead`. local splitArgLead = vim.split(spacedArgLead, ' ', true) - print(spacedArgLead) - - -- make sure the user is in a position were this function - -- will provide accurate completions. + --[[ make sure the user is in a position were this function + will provide accurate completions.]] if #splitArgLead > 1 then return nil end @@ -158,13 +156,9 @@ function Prompt.createCompletionsProvider(completions) -- get all matches from the completions list. local matches = {} for _, completion in ipairs(completions) do - print('testing ' .. word .. ' against ' .. string.upper(completion)) -- test if `word` is inside of `completions`:`v`, ignoring case. if string.match(vim.pesc(string.upper(completion)), word) then - print('>>match') matches[#matches + 1] = completion -- preserve case when providing completions. - else - print('>>nomatch') end end return matches