From 5f432d997e397790cea39d9bb8826c1d4ca14afb Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:30:17 +0300 Subject: [PATCH] fix(autocmds): change mapping for `lazyvim_close_with_q` (#4638) ## Description Currently `checkhealth` buffers stay visible on `bufferline` when you close them with `q`. Use `:bd` instead to delete the buffer from bufferlist. `vim.schedule` is needed because `LspInfo` adds its own mapping to close the window (see [here](https://github.com/neovim/nvim-lspconfig/blob/edd9591199d1c78c0cb20514231f7f936f9412a2/lua/lspconfig/health.lua#L328)), so we need to overwrite it. ## Related Issue(s) None ## Screenshots ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- lua/lazyvim/config/autocmds.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index 7839950b..bc52c876 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -72,11 +72,13 @@ vim.api.nvim_create_autocmd("FileType", { }, callback = function(event) vim.bo[event.buf].buflisted = false - vim.keymap.set("n", "q", "close", { - buffer = event.buf, - silent = true, - desc = "Quit buffer", - }) + vim.schedule(function() + vim.keymap.set("n", "q", ":bd", { + buffer = event.buf, + silent = true, + desc = "Quit buffer", + }) + end) end, })