Skip to content

fix(snacks): set preview buffer modifiable before writing#72

Open
xavier7179 wants to merge 1 commit into
nosduco:mainfrom
xavier7179:fix/snacks-preview-modifiable
Open

fix(snacks): set preview buffer modifiable before writing#72
xavier7179 wants to merge 1 commit into
nosduco:mainfrom
xavier7179:fix/snacks-preview-modifiable

Conversation

@xavier7179
Copy link
Copy Markdown

The snacks.nvim picker through an error due to the preview buffer not being modifiable. This is a workaround to make the buffer modifiable, allowing the picker to function correctly.

Copilot AI review requested due to automatic review settings May 12, 2026 08:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an error in the Snacks.nvim picker preview rendering by ensuring the preview buffer is set to modifiable before calling nvim_buf_set_lines, allowing preview content to be written successfully.

Changes:

  • Set vim.bo[ctx.buf].modifiable = true before writing preview content in the Snacks “connect” picker.
  • Set vim.bo[ctx.buf].modifiable = true before writing preview content in the Snacks “edit ssh config” picker.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 94 to 97
local lines = build_host_preview(hosts, ctx.item.name)
vim.bo[ctx.buf].modifiable = true -- avoid Snacks.nvim tossing an error due to the buffer being readonly
vim.api.nvim_buf_set_lines(ctx.buf, 0, -1, false, lines)
vim.bo[ctx.buf].filetype = "sshconfig"
Comment on lines +142 to 144
vim.bo[ctx.buf].modifiable = true -- avoid Snacks.nvim tossing an error due to the buffer being readonly
vim.api.nvim_buf_set_lines(ctx.buf, 0, -1, false, lines)
vim.bo[ctx.buf].filetype = "sshconfig"
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

Successfully merging this pull request may close these issues.

2 participants