Skip to content

Fallback should use <Tab> instead of tab character when accept_fallback is nil #330

@Jonkimi

Description

@Jonkimi

Problem

In lua/codeium/virtual_text.lua

local default = config.options.virtual_text.accept_fallback or (vim.fn.pumvisible() == 1 and "<C-N>" or "\t")
, when config.options.virtual_text.accept_fallback is nil and there is no completion menu (pumvisible() == 0), the current fallback behavior inserts a tab character ("\t"). This is usually not the expected Vim behavior, since users typically expect <Tab> to trigger mappings or plugin logic, not insert a literal tab character. This can lead to unexpected editing outcomes and breaks common insert mode workflows, especially when <Tab> is remapped for completion or snippet expansion.

How to Reproduce

  1. In your Neovim config, explicitly disable windsurf/codeium with:
    -- disable codeium by default
    require("codeium").disable()
  2. Open any file for editing.
  3. Enter insert mode and press Tab.

Result:
You will encounter the error described in #294:

E5108: Error executing lua: ...local/share/nvim2/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:273: "replace_keycodes" requires "expr"

This happens because the fallback returns a tab character ("\t") rather than properly simulating a <Tab> key event, breaking expected plugin and mapping logic.

Proposed Solution

Change the fallback logic so that when accept_fallback is nil, and the completion menu is not visible, fallback returns "<Tab>" instead of "\t". This ensures the correct Vim key event is triggered, supporting user mappings and plugin behaviors as intended.

Relevant Code

local default = config.options.virtual_text.accept_fallback or (vim.fn.pumvisible() == 1 and "<C-N>" or "\t")

Should be updated to:

local default = config.options.virtual_text.accept_fallback or (vim.fn.pumvisible() == 1 and "<C-N>" or "<Tab>")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions