Giter Site home page Giter Site logo

Comments (21)

max397574 avatar max397574 commented on June 14, 2024 1

It's not possible to run the function before. Because the function could be something that should be done after jk are deleted. I guess you could just use <ESC>and not a function and it should work for you.

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024 1

@lucasvianav
added it on the dev branch

you can try
keys_before_delete = true,
in the setttings

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

I think ik what happens but not why

						*i_CTRL-E*
CTRL-E		Insert the character which is below the cursor.

if you type jk you no longer get completion propositions so there is no completition menu so c-e does it's default thing (see above)
that's where the [n] comes from

that pumvisible()'s output is 0 doesn't make sense to me. (what completion plugin do you use)
I could imagine that it has sth todo with that you don't get completions after deleting chars but only after entering
because you enter jkand then they get deleted
I just don't know why <c-e><ESC>gets executed and not <ESC>only
I'll look at it next week

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

okay it's actually simple

pumvisible()returns 0 if there is no popupmenu

0 is evaluated as true in lua

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

pumvisible()returns 0 if there is no popupmenu

wow, I totally forgot to == 0 it. thanks :)

if you type jk you no longer get completion propositions so there is no completition menu so c-e does it's default thing (see above)

what do you mean? what I'm trying to solve is that when I have a completion option selected, if I just pres jk it'll confirm the completion before escaping insert mode.

see this gif

If i do ino <silent><expr> jk pumvisible() ? "\<C-e><Esc>" : "\<Esc>" it works --- just escapes insert mode without confirming the completion.

I'm using coq_nvim btw

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

I've added the == 0 now. Sometimes pumvisible() will return 1, other times 0, regardless if the pum is actually visible or not. I tried changing my config to:

keys = function()
    local selected = vim.fn.complete_info({ 'selected' }).selected
    return selected ~= -1 and '<C-e><Esc>' or '<Esc>'
end

But selected is always -1, even when I do have a completion option enabled

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

Actually the plugin (with the first config you sent) checks whether there is a pum after deleting the j and k

so it's the same like when you slowly type jk
can you check if there is a pum then?

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

Yeah, when mapping jk directly the pum is still visible when the expression is evaluated. Look at the gifs below.

Peek 2021-09-27 10-51

Peek 2021-09-27 10-59

Here's the function I've used:

function! Test() abort
    echom complete_info()
    return pumvisible() ? "\<C-e>\<Esc>" : "\<Esc>"
endfunction

" ino <silent><expr> jk pumvisible() ? "\<C-e><Esc>" : "\<Esc>"
ino <expr> jk Test()

Would it be bad to run the keys function before deleting jk? Or maybe expose an option for the user to choose.

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

This would be possible
But I have to try if it doesn't break anything first
I'll ping you as soon as it's on the dev branch so you can test

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

Wouldn't it be possible to expose the option of running the function either before or after?

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

I think it would be. I'll look at it next week.

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

I think it would be. I'll look at it next week.

Alright, thanks :)

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

thanks @max397574! I was about to test it, but I think there's a typo

Error detected while processing InsertCharPre Autocommands for "*":
E5108: Error executing lua ...pack/packer/opt/better-escape.nvim/lua/better_escape.lua:53: attempt to index global 'settigns' (a nil value)
Press ENTER or type command to continue

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

I fixed the typo and tried it, but feeding <BS><BS> after exiting to normal mode goes back 2 chars (even sending me some lines up if I'm at the start of line). I'm not able to record a GIF right now tho

I also tried running a function both before and after jk is deleted (see below) -- the idea was to feed <C-e> before if needed and only leave insert mode after deleting jk. But it also doesn't work, for some reason the function isn't always able to detect that the pum is visible nor that there's an option selected, I couldn't figure out why.

image
image

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

doesn't this work if you just use no function?
for me it does

Screen.Recording.2021-10-15.at.18.02.10.mov

executing the function before the deletion is a thing I could perhaps do in the future

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

For me it doesn't, unfortunately. Are you using coq?

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

no
nvim-cmp
what happens when you don't use a function then?

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

In the gif you sent

see this gif

do you use a function there or just the default settings?
@lucasvianav

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

hey @max397574, sorry for the delay. for that particular gif I don't remember, but here's one with keys = '<Esc>':
esse

from better-escape.nvim.

max397574 avatar max397574 commented on June 14, 2024

so it basically expands some time, some times it deletes a character

imo this can't be an error from better-escape.nvim because it does only feed
and this shouldn't expand or anything

from better-escape.nvim.

lucasvianav avatar lucasvianav commented on June 14, 2024

yeah, I'm with you on this, I don't think it's a better-escape.nvim problem. 

it's just a coq_nvim particularity that when escaping with a completion option selected, you have to feed <C-e> before <Esc>, and it'd be nice if better-escape could support it. unfortunately I don't think it's possible, although I don't know exactly what the incompatibility is

regardless, thanks for all the help and the nice plugin :)

from better-escape.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.