Closed whxcode closed 10 months ago
It would probably work best as a functional mapping. Something like this:
vim.keymap.set('n', 'q', function()
vim.api.nvim_command(#vim.api.nvim_list_bufs() > 1 and 'quit' or 'BufferClose')
end, {})
It would probably work best as a functional mapping. Something like this:
vim.keymap.set('n', 'q', function() vim.api.nvim_command(#vim.api.nvim_list_bufs() > 1 and 'quit' or 'BufferClose') end, {})
Thanks!
Currently there are multiple buffers in nvim. I want to close the operation. When only one buffer is included, exit nvim. But it seems that the following code does not take effect. How should I deal with it?
It will execute the exit nvim operation
if vim.F.if_nil(vim.g.rafi_window_q_mapping, true) then vim.api.nvim_create_autocmd({ 'BufWinEnter', 'VimEnter' }, { group = augroup('quit_mapping'), callback = function(event) if vim.bo.buftype == '' and vim.fn.maparg('q', 'n') == '' then local c =#vim.api.nvim_list_bufs() if c == 1 then --map('n', 'q', 'quit', {})
else
--map('n', 'q', 'BufferClose', {})
end
end
end,
})
end