Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't close floating window by pressing q or Esc #415

Closed
Logarithmus opened this issue Jan 17, 2022 · 5 comments
Closed

Can't close floating window by pressing q or Esc #415

Logarithmus opened this issue Jan 17, 2022 · 5 comments

Comments

@Logarithmus
Copy link

Logarithmus commented Jan 17, 2022

Steps to Reproduce

  1. Start debugging session
  2. Put the cursor over a variable
  3. :lua require("dap.ui.widgets").hover()

Expected Result

Packer's, Trouble.nvim's, Telescope's windows & splits can be close by pressing either q or Esc.
I'm using LunarVim, maybe it affects this behavior somehow?

Actual Result

The only way to close the floating window is :q, because q & Esc don't work.

nvim-dap_bugs.mp4
@mfussenegger
Copy link
Owner

mfussenegger commented Jan 19, 2022

This is expected. nvim-dap is rather unopinionated and sticks to neovim defaults if they exist. The default mapping to close a window in neovim is <C-W q>.

I could set a dap-float filetype to make it easier to define custom mappings.

@jarviliam
Copy link

@mfussenegger Thanks for adding the filetype! 👍
@Logarithmus After updating nvim-dap you should be able to add the mapping via an autocmd now like autocmd FileType dap-float nnoremap <buffer><silent> q <cmd>close!<CR>

@Logarithmus
Copy link
Author

@jarviliam cool!

@kraxli
Copy link

kraxli commented Jan 20, 2022

very nice! Thanks a lot for this and the whole plug-in!

akriese added a commit to akriese/dotfiles that referenced this issue May 25, 2022
BPagoaga added a commit to BPagoaga/lazyvim that referenced this issue Feb 9, 2024
@sakalys
Copy link

sakalys commented Jul 16, 2024

Here's a lua counterpart to what @jarviliam suggested, if anyone needs this:

vim.api.nvim_create_autocmd("FileType", {
    pattern = "dap-float",
    callback = function()
        vim.api.nvim_buf_set_keymap(0, "n", "q", "<cmd>close!<CR>", { noremap = true, silent = true })
    end
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants