如何修复此 nvim 键盘映射?它几乎可以工作,但是当 cmp 不可见时 <Tab> 返回额外的反斜杠字符

问题描述 投票:0回答:1
vim.keymap.set("i", "<tab>", function()
    local cmp = require("cmp")
    if cmp.visible() then
        cmp.confirm()
    else
        return '\\<tab>'
    end
end, { desc = "Confirm", expr = true, noremap = true })

要返回什么或在 else 块中运行什么命令才能获得默认行为?

neovim vim-plugin
1个回答
0
投票

尝试使用/t

vim.keymap.set("i", "<tab>", function()
    local cmp = require("cmp")
    if cmp.visible() then
        cmp.confirm()
    else
        return '\t'
    end   
    end, { desc = "Confirm", expr = true, noremap = true })

更改此代码后如有任何问题请回复。

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.