Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using nvim-cmp, how do I get this gray box to not appear when scrolling through words? #494

Open
NeckBeardPrince opened this issue Feb 9, 2024 · 1 comment

Comments

@NeckBeardPrince
Copy link

I think it's related to tokyonight, if I change the color scheme to default or others it's transparent.

Here is a video since I'm having a hell of a time putting the issue into words, clearly. I'm a bit new to neovim, so I'm sure I'm overlooking something

@adrian5
Copy link
Contributor

adrian5 commented Feb 17, 2024

I don't see that behavior here with nvim-cmp. Parts of the word appearing at the end looks wonky too, so maybe a misconfiguration? Here's my next/prev mapping for nvim-cmp using [Shift] Tab:

Config
local has_words_before = function()
  if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
    return false
  end
  local line, col = unpack(vim.api.nvim_win_get_cursor(0))
  return col ~= 0 and
    vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end

cmp.setup() {
  mapping = {
    ["<Tab>"] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      elseif luasnip.expand_or_jumpable() then
        luasnip.expand_or_jump()
      elseif has_words_before() then -- If tabbing after text in insert mode
        cmp.complete() -- Open cmp menu (normally Tab wouldn't trigger this)
      else
        fallback()
      end
    end, { "i", "s" }),
    ["<S-Tab>"] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_prev_item()
      elseif luasnip.jumpable(-1) then
        luasnip.jump(-1)
      else
        fallback()
      end
    end, { "i", "s" }),
    ["<Cr>"] = cmp.mapping.confirm()
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants