m4xshen / autoclose.nvim

A minimalist Neovim plugin that auto pairs & closes brackets
MIT License
517 stars 14 forks source link

`<CR>` keybind is enabled in command mode by default #35

Closed NiklasKappel closed 1 year ago

NiklasKappel commented 1 year ago

From this line https://github.com/m4xshen/autoclose.nvim/blob/main/lua/autoclose.lua#L23, I infer that the autoclose.nvim functionality should not be enabled for <CR> in command mode by default. However, it is, which messes with my config.

I am not an expert in lua, but I guess the error may be in this line https://github.com/m4xshen/autoclose.nvim/blob/main/lua/autoclose.lua#L150. Should it not read if not info.disable_command_mode then, because the disable option is set per key and not in the keys table?

m4xshen commented 1 year ago

Thanks for the feedback! I want to know how the original functionality messes with your config. Could you explain a little bit?

NiklasKappel commented 1 year ago

I have the following in my init.lua:

-- fish-like command line completion
vim.opt.wildignorecase = true
vim.opt.wildmode = "longest:full,full"
vim.keymap.set("c", "<cr>", function()
    if vim.fn.pumvisible() == 1 then
        return "<c-y>"
    end
    return "<cr>"
end, { expr = true })

This makes command mode completion behave exactly the same as command line completion in fish, which I also use (enter adds the highlighted entry of the completion menu to the command and closes the menu, but does not execute the command). Thus simply, if any plugin rebinds <CR> in command mode, I notice because my muscle memory messes up command completion.

Now everything works as expected again, thanks a lot for your quick reply and this nice plugin. :)