feat: native Rust file watcher (auto-reload open buffers) + gotmpl build fix - #64
Open
parisni wants to merge 2 commits into
Open
feat: native Rust file watcher (auto-reload open buffers) + gotmpl build fix#64parisni wants to merge 2 commits into
parisni wants to merge 2 commits into
Conversation
The gotmpl tree-sitter grammar pointed to github.com/dannylongeuay/tree-sitter-go-template, which no longer exists (404 / "Repository not found"). The grammar build script is all-or-nothing, so this single dead source broke every build. Repoint it to github.com/ngalaiko/tree-sitter-go-template at the same rev helix-editor/helix now uses (aa71f63), keeping helm/gotmpl highlighting and staying aligned with upstream to avoid future merge conflicts.
Reimplement the Steel helix-file-watcher plugin in pure Rust so the native hx binary auto-reloads buffers when their file changes on disk, without loading any Scheme. Design goals (minimize upstream merge conflicts): - All logic lives in a new file, helix-term/src/file_watcher.rs. Upstream wiring is only three tiny anchors: a pub mod in lib.rs, a register() call in events.rs, and notify = "8" in Cargo.toml. - notify watches the *parent directory* (not the file inode), so watches survive atomic saves (helix's own :w rename+create, and external editors that save atomically). A per-file set filters directory events down to open buffers; a per-directory refcount drops the watch when the last file closes. - Reload is unconditional and recorded in the undo history, so external changes always refresh the view and in-session local edits stay recoverable via undo. This avoids silently leaving a buffer out of sync with disk. - FS events are debounced via AsyncHook; the reload runs on the main thread through job::dispatch_blocking, so application.rs is untouched. - (Re)watch is driven by the DocumentDidOpen / DocumentDidClose hooks.
Owner
|
I'm thinking it is better to wait master. Otherwise, we would have to undo this custom feature once they merge their file watcher PR. Still, I might end up using this PR locally as it's easier to merge. I'm still not sure yet if adding non-Vim features is a good idea. I can't merge their PR independently here as well. There should be a git repo that provide diff files for Vim features only. |
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.
Reimplements the auto-reload idea from the Steel
helix-file-watcherplugin, but in native Rust — so the plain
hxbinary reloads open bufferson external changes without loading any Scheme.
notify, so it's lightweight and fast (debounced, reload runs onthe main thread; the editor is untouched while idle).
working when the file is renamed/replaced (atomic saves from
:wor externaleditors).
helix-term/src/file_watcher.rs; the only wiring is apub modinlib.rs,a
register()call inevents.rs, andnotifyinCargo.toml.Also includes a one-line build fix: the
gotmplgrammar pointed to a dead repo(404), which broke the all-or-nothing grammar build. Repointed to the live
ngalaikofork (same rev helix upstream uses).