hrsh7th / nvim-insx

Flexible key mapping manager.
178 stars 8 forks source link

abbrev is not working when we setup for `<space>` #37

Closed ryoppippi closed 6 months ago

ryoppippi commented 6 months ago

Description

Hi! Thank you for creating and maintaining this amazing plugin!

I found that when we set up insx for <space> key, the abbrev feature does not work.

Here is a minimal configuration.

local tmp_dir = "/tmp"
local commit_hash = "c1d9efb592787f3f8c6d99db6ed5f51dd9475d4f"

-- fectch insx if not exists {{
local insx_path = tmp_dir .. "/insx"
if not (vim.uv or vim.loop).fs_stat(insx_path) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "--single-branch",
        "https://github.com/hrsh7th/nvim-insx.git",
        insx_path,
    })
end

-- checkout commit_hash
vim.fn.system({
    "git",
    "-C",
    insx_path,
    "checkout",
    commit_hash,
})

vim.opt.runtimepath:prepend(insx_path)
-- }}

-- setup insx
require("insx").add("<Space>", {
    enabled = function()
        return false
    end,
    action = function(ctx) end,
})

-- define abbreviations
if (vim.fn.has("nvim-0.10")) ~= 0 then
    vim.keymap.set("ia", "fu", "fuhahahaha")
    vim.keymap.set("ca", "sa", "sasumatu")
else
    vim.cmd([[iabbrev <buffer> fu fuhahahaha]])
    vim.cmd([[cabbrev <buffer> sa sasumatu]])
end

How to reproduce

  1. Create some lua file(like init.lua) and yank-paste the above code to the file.
  2. Open Neovim with the file described earlier (ex. NVIM_APPNAME=insx_abbr nvim -u init.lua)
  3. Go to insert mode, then type fu<space> to the buffer (and you can see that abbr does not work)
  4. Go to command mode, then type sa<space> (and you can see that ca works)

I tested on neovim@v0.9.5 and neovim@v0.10.0-dev-3026+ga41546d4a, and the OS is macOS 14.

Thanks