Closed GordianDziwis closed 5 days ago
Hmm, interesting idea. This is definitely hacky and could be improved.
However, I tried this out a bit and ran into some issues. Can you see if it works for you on this branch better-handling-of-esc-idea
?
https://github.com/mikavilpas/yazi.nvim/pull/127
I added instructions on how this could be tried out to https://github.com/mikavilpas/yazi.nvim/blob/master/documentation/for-developers/setting-up.md#managing-your-development-code
For me, running nvim -u repro.lua .
(to start neovim with yazi.nvim showing the current directory) doesn't show yazi.nvim after this change. The suggested change might have caused this, and this should be fixed before merging the change in.
```lua
-- You can use this file to reproduce an issue with your configuration.
---@module "yazi"
---@module "lazy"
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify('./.repro', ':p')
-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end
-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
vim.g.mapleader = ' '
-- install the following plugins
---@type LazySpec
local plugins = {
'folke/tokyonight.nvim',
{
'mikavilpas/yazi.nvim',
branch = 'better-handling-of-esc-idea',
dependencies = {
'nvim-lua/plenary.nvim',
},
event = 'VeryLazy',
keys = {
{
-- 👇 choose your own keymapping
'
You have set open_for_directories = false
...
Oops, you're right. My bad. I'll look into it more.
Something seems to conflict in lazyvim:
https://github.com/mikavilpas/yazi.nvim/assets/300791/a50d0da7-d497-4fbe-a455-0e6c905add6e
```lua
-- You can use this file to reproduce an issue with your configuration.
---@module "yazi"
---@module "lazy"
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify('./.repro', ':p')
-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end
-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
vim.g.mapleader = ' '
-- install the following plugins
---@type LazySpec
local plugins = {
'folke/tokyonight.nvim',
{ 'LazyVim/LazyVim', import = 'lazyvim.plugins' },
{
'mikavilpas/yazi.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
},
branch = 'better-handling-of-esc-idea',
event = 'VeryLazy',
keys = {
{
-- 👇 choose your own keymapping
'
I like this idea a lot though. If you can resolve this issue, I would like to merge it.
The issue is: On pressing <esc>
your yazi window leaves the insert mode?
I do not have this issue with your config, but in the video your status line is modified, while mine is vanilla, so I would guess there is a conflict with a plugin.
That's it exactly. Can you reproduce the behaviour with the reproduction script in my previous message?
Nope, works also fine with the updated repro script.
Maybe you are running in this issue again:
-- HACK Sometimes pressing "<esc><esc>" exits insert mode the first time it's pressed.
-- Work around this by starting insert mode after the first time the mode changes.
Maybe try deleting the .repro
directory
Just tried deleting the .repro
directory, but I'm still getting the same behaviour. Did you also try after removing your .repro
directory?
I think it should effectively start over from scratch in that case.
LazyVim has in the Terminal mode a mapping for <esc>
defined:
t <Esc><Esc> * <C-\><C-N>
Enter Normal Mode
Last set from ~/.repro/plugins/LazyVim/lua/lazyvim/util/init.lua line 218
Ooh I see, nice find! I was able to shadow that binding for yazi.nvim only, so that issue goes away as far as I can tell.
Would you have time to review #127? Let me know if you would prefer not being included as the co-author.
Just merged the refactor in. Thanks again for the idea and help!
Neovim captures the first
<esc>
when in a yazi buffer.As a fix I added
vim.keymap.set('t', '<esc>', '<esc>', { buffer = yazi_buffer })
in theset_keymappings_function
.Then this hack is not needed anymore: https://github.com/mikavilpas/yazi.nvim/blob/1efb48847944c4036bfd4114590bd617b274adf9/lua/yazi/window.lua#L93-L100