Skip to content

Improve filetype handling and async execution in buffers - #27

Open
103sbavert wants to merge 5 commits into
andre-kotake:mainfrom
103sbavert:fix/warning-on-virtual-buffer
Open

Improve filetype handling and async execution in buffers#27
103sbavert wants to merge 5 commits into
andre-kotake:mainfrom
103sbavert:fix/warning-on-virtual-buffer

Conversation

@103sbavert

@103sbavert 103sbavert commented Jul 16, 2026

Copy link
Copy Markdown

Fixes #25

Opening a virtual buffer (e.g. neo-tree "X hidden items") threw chezmoi: stat ... no such file or directory inside chezmoi source dir because their paths looked as if they were real chezmoi source files.

The cause was that detect_filetype called target_path:exec() (sync) during file type detection which auto-logs errors on failure (unavoidable for inexistent files). Replacing target_path:exec() with target_path:async() resolves this because it does not auto-log errors and leaves that to the

Also see #26

Copilot AI review requested due to automatic review settings July 16, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown

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/warning that occurs when opening “virtual” buffers (e.g., neo-tree hidden-items buffers) while Neovim’s CWD is inside the chezmoi source dir, by avoiding synchronous chezmoi calls during filetype detection.

Changes:

  • Switch detect_filetype from target_path:exec() (sync, auto-logs errors) to target_path:async() (no auto-log) to prevent noisy errors for non-existent/virtual paths.
  • Keep existing filetype detection logic (plenary + vim.filetype.match fallback + temp buffer heuristic) but run it inside an async callback.
  • Preserve caching and vim.filetype.add behavior for future detections.

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

Comment thread lua/nvim-chezmoi/chezmoi/commands/edit.lua
103sbavert added a commit to 103sbavert/nvim-chezmoi that referenced this pull request Jul 16, 2026
chezmoiCommand:async already uses vim.schedule to invoke the callback. This
issue was reported in andre-kotake#27
discussion_r3594777151.
@103sbavert
103sbavert requested a review from Copilot July 16, 2026 11:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@103sbavert
103sbavert force-pushed the fix/warning-on-virtual-buffer branch from d0fbef9 to 0c2ef41 Compare July 16, 2026 11:45
removes the early return guard when `b_ftype` is missing or empty, as it
does not necessarily mean the file is invalid.
chezmoiCommand:async already uses vim.schedule to invoke the callback. This
issue was reported in andre-kotake#27
discussion_r3594777151.
@103sbavert
103sbavert force-pushed the fix/warning-on-virtual-buffer branch from 0c2ef41 to e3140c6 Compare July 16, 2026 11: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.

The plugin throws a Warning/Error message when opening a virtual buffer (no file type)

2 participants