Comments (21)
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.
@lucasvianav
added it on the dev branch
you can try
keys_before_delete = true,
in the setttings
from better-escape.nvim.
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 jk
and 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.
okay it's actually simple
pumvisible()
returns 0 if there is no popupmenu
0 is evaluated as true in lua
from better-escape.nvim.
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.
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.
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.
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.
Yeah, when mapping jk
directly the pum is still visible when the expression is evaluated. Look at the gifs below.
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.
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.
Wouldn't it be possible to expose the option of running the function either before or after?
from better-escape.nvim.
I think it would be. I'll look at it next week.
from better-escape.nvim.
I think it would be. I'll look at it next week.
Alright, thanks :)
from better-escape.nvim.
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.
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.
from better-escape.nvim.
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.
For me it doesn't, unfortunately. Are you using coq?
from better-escape.nvim.
no
nvim-cmp
what happens when you don't use a function then?
from better-escape.nvim.
In the gif you sent
do you use a function there or just the default settings?
@lucasvianav
from better-escape.nvim.
hey @max397574, sorry for the delay. for that particular gif I don't remember, but here's one with keys = '<Esc>'
:
from better-escape.nvim.
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.
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)
- If I enter insert mode, then type jk immediately, it shouldn't mark the buffer as modified HOT 5
- Auto-completion popup window edge case HOT 10
- Is it possible to map different mappings with different keys? HOT 4
- Is it possible to use this with normal mode? HOT 1
- Interference with completion plugin HOT 1
- General API for custom escapes HOT 3
- Better escape key
- Insert Mode HOT 1
- will give error if set to `opt = true` in packer.nvim HOT 5
- Escape sequences jk & jj delete character before cursor on first use of sequence HOT 1
- `i_ctrl-a` not working
- Disable within certain filetypes?
- Not working in Command mode, Visual mode, Operator-pending mode HOT 12
- Save after escape HOT 1
- Document incompatibility with macros in readme.md HOT 1
- `autoindent` option doesn't work HOT 1
- [request] version for fish shell HOT 1
- Adding a FOSS license HOT 2
- Better move cursor HOT 1
- Repeat last change '.' places the cursor 2 chars back from the end of the change
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from better-escape.nvim.