Improve filetype handling and async execution in buffers - #27
Open
103sbavert wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
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_filetypefromtarget_path:exec()(sync, auto-logs errors) totarget_path:async()(no auto-log) to prevent noisy errors for non-existent/virtual paths. - Keep existing filetype detection logic (plenary +
vim.filetype.matchfallback + temp buffer heuristic) but run it inside an async callback. - Preserve caching and
vim.filetype.addbehavior for future detections.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
force-pushed
the
fix/warning-on-virtual-buffer
branch
from
July 16, 2026 11:45
d0fbef9 to
0c2ef41
Compare
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
force-pushed
the
fix/warning-on-virtual-buffer
branch
from
July 16, 2026 11:47
0c2ef41 to
e3140c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25
Opening a virtual buffer (e.g. neo-tree "X hidden items") threw
chezmoi: stat ... no such file or directoryinside chezmoi source dir because their paths looked as if they were real chezmoi source files.The cause was that
detect_filetypecalledtarget_path:exec()(sync) during file type detection which auto-logs errors on failure (unavoidable for inexistent files). Replacingtarget_path:exec()withtarget_path:async()resolves this because it does not auto-log errors and leaves that to theAlso see #26