max397574 / better-escape.nvim

Map keys without delay when typing
GNU General Public License v3.0
629 stars 19 forks source link

refactor: rewrite to use mappings (for most modes) #59

Closed Sam-programs closed 3 months ago

Sam-programs commented 7 months ago

Operator-pending mode still doesn't work, because i am not sure how it's supposed to work. I added comments starting with WIP: for things that still need discussion. Fix: #58 Fix: #46 Fix: #49

max397574 commented 7 months ago

I'm also currently rewriting this on a branch here in the repo I don't currently have time to work on it nor to review this pr properly so for now I wouldn't spend too much time working on this because perhaps I'll rather use my implementation

max397574 commented 4 months ago

@Sam-programs I added some changes to this pr would it be okay to merge this from your side?

Sam-programs commented 4 months ago

@Sam-programs I added some changes to this pr would it be okay to merge this from your side?

Your changes LGTM.

In the commit above, I swapped expr-mappings to feedkeys calls to allow functions to change the buffer because functions needed to vim.schedule code that modifies the buffer. e.g:

        vim.schedule(function()
            vim.api.nvim_set_current_line("")
        end

EDIT: This might also remove the need for the defer here. I can't check because I don't use luasnip

            -- Defer execution to avoid side-effects
            vim.defer_fn(function()
                -- set undo point
                vim.o.ul = vim.o.ul
                require("luasnip").expand_or_jump()
            end, 1)
max397574 commented 4 months ago

the defer is still needed didn't test the other case but sounds good 👍 thank you very much for the contribution

I'll merge this in the next few days

max397574 commented 4 months ago

closes https://github.com/max397574/better-escape.nvim/issues/23

max397574 commented 3 months ago

Thank you very much for this contribution