Skip to content
Discussion options

You must be logged in to vote

Ok, I've got time sooner than I thought.

Try this snippet:

local safe_getcharstr = function(msg)
  vim.cmd('echon ' .. vim.inspect(msg))

  -- Allow `<C-c>` to end input
  local ok, res = pcall(vim.fn.getcharstr)

  -- Clean command line
  vim.cmd([[echo '' | redraw]])

  -- Treat `<Esc>` or `<CR>` as cancel
  if not ok or (res == '\27' or res == '\r') then return nil end

  return res
end

local make_ignorecase_pattern = function(word)
  local parts = {}
  for i = 1, word:len() do
    local char = word:sub(i, i)

    if char:find('^%a$') then
      -- Convert letter to a match both lower and upper case
      char = '[' .. char:lower() .. char:upper() .. ']'
    else
      -- Escape non-l…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@justEstif
Comment options

Comment options

You must be logged in to vote
1 reply
@justEstif
Comment options

Answer selected by justEstif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants