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

Question: Close Buffer with <esc> #15

Closed
harrisoncramer opened this issue Oct 4, 2022 · 3 comments
Closed

Question: Close Buffer with <esc> #15

harrisoncramer opened this issue Oct 4, 2022 · 3 comments

Comments

@harrisoncramer
Copy link

Hello! Thanks so much for building this.

Would it be possible to name the messages buffer, or provide some sort of identifying information?

I'd love to be able to hit <esc> to close it, but I'm not seeing it in the :buffers call and not sure how to target it with a lua function. Apologies if this isn't in scope. Thanks!

@hehelego
Copy link

hehelego commented Oct 6, 2022

Change the prepare_buffer function in your messages.nvim config:

prepare_buffer = function(opts)
  local buf = vim.api.nvim_create_buf(false, true)
  vim.keymap.set('n', '<Esc>', '<cmd>close<cr>', {buffer = buf})
  return vim.api.nvim_open_win(buf, true, opts)
end,

You also may want to try this patch #14 , it allows you specify buffer options (filetype, number column, syntax highlinghting, etc.).

The following lua code maps q to :close<cr> for messages.nvim message capture buffers.

vim.api.nvim_create_autocmd("FileType", {
	pattern = { "messages" },
	callback = function(args)
		vim.keymap.set("n", "q", "<cmd>close<cr>",
          { silent = false, noremap = true, buffer = args.buf, }
        )
	end,
})

@harrisoncramer
Copy link
Author

First route worked like a charm, thank you!

@AckslD
Copy link
Owner

AckslD commented Oct 10, 2022

Thanks @hehelego and glad to hear it works now @harrisoncramer

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

3 participants