stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.69k stars 32 forks source link

fix(map_util): insert bindings for <Plug>, <Cmd> and :Cmd work #124

Closed Akeboshiwind closed 7 months ago

Akeboshiwind commented 8 months ago

Fix the map_util.create_maps_to_plug function to work with <Plug>, <Cmd> and :Cmd. A future change could also insert <CR> after <Cmd> and :Cmd.

Context

I shamelessly stole the map_util.lua file for a project of my own (I'll figure out licensing if I release it). But I noticed that for insert mode bindings it would insert <Plug>NameOf:Command into the buffer instead of executing it.

Demo: https://github.com/stevearc/dressing.nvim/assets/8889986/f435229d-0aac-4b35-8ba6-1d2feb09b704

Description

I was able to fix the bug by just putting a <C-o> in front of the command in insert mode.

Demo: https://github.com/stevearc/dressing.nvim/assets/8889986/dc6ad2de-8e5d-45d1-bb87-700f020646c3
Akeboshiwind commented 8 months ago

It turns out that <CR> binding was needed. It was causing some mysterious lag 😅

stevearc commented 7 months ago

I appreciate the PR, but I've actually moved on from using this utility for keymaps. For all of my newer plugins I use a pattern like this https://github.com/stevearc/oil.nvim/blob/master/lua/oil/keymap_util.lua, which avoids any weirdness with <Plug> mappings and is more customizable. If anything, I would rewrite dressing.nvim to use that style.