Skip to content

fix(file): detach LSP clients and disable auto-format on diffview:// buffers#79

Merged
dlyongemallo merged 1 commit intomainfrom
fix_diffview_buffer_lsps_formatters
Mar 31, 2026
Merged

fix(file): detach LSP clients and disable auto-format on diffview:// buffers#79
dlyongemallo merged 1 commit intomainfrom
fix_diffview_buffer_lsps_formatters

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

@dlyongemallo dlyongemallo commented Mar 31, 2026

Fixes #72 and #73.

Copilot AI review requested due to automatic review settings March 31, 2026 10:41
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 prevents Neovim LSP clients from remaining attached to diffview:// buffers and disables common auto-format hooks for those buffers, to avoid incorrect language features and unintended formatting on historical/staged content.

Changes:

  • Add a buffer-local LspAttach autocmd for diffview:// buffers that detaches any LSP client that attaches.
  • Set vim.b[bufnr].autoformat = false for diffview:// buffers to discourage formatter auto-runs.
  • Add functional tests asserting the autoformat flag and LspAttach autocmd registration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lua/diffview/vcs/file.lua Adds LSP-detach guard and disables common autoformat behavior on diffview:// buffers during buffer creation.
lua/diffview/tests/functional/file_spec.lua Adds functional tests verifying the new buffer guards are applied.

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

Comment thread lua/diffview/vcs/file.lua
Comment thread lua/diffview/tests/functional/file_spec.lua
@dlyongemallo dlyongemallo force-pushed the fix_diffview_buffer_lsps_formatters branch from 9f7cd2d to eecb75a Compare March 31, 2026 10:51
@dlyongemallo dlyongemallo force-pushed the fix_diffview_buffer_lsps_formatters branch from eecb75a to 8bec925 Compare March 31, 2026 12:31
@dlyongemallo dlyongemallo merged commit 3d8deb1 into main Mar 31, 2026
2 checks passed
@dlyongemallo dlyongemallo deleted the fix_diffview_buffer_lsps_formatters branch March 31, 2026 12:47
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.

[Bug] Auto-formatters are allowed on diffview buffers and break things

2 participants