Fix delete-pair and list navigation for delimiters#29
Merged
Conversation
632b828 to
9575314
Compare
Add a `list' thing to `treesit-thing-settings' covering all OCaml container/delimited node types. On Emacs 31+ this enables native support for `forward-list', `up-list', `down-list', and correct `forward-sexp' behavior on delimiters via `treesit-forward-sexp-list'. For Emacs 29-30, introduce `neocaml--forward-sexp-hybrid' which falls back to syntax-table-based `scan-sexps' when point is on a delimiter character, so that commands like `delete-pair' find the correct matching paren instead of jumping to an unrelated tree-sitter node.
9575314 to
7888359
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 #28.
delete-pairwas deleting the wrong closing delimiter becauseforward-sexpused tree-sitter node navigation instead ofsyntax-table paren matching when point was on a delimiter character.
Two changes here:
Added a
listthing totreesit-thing-settingscovering OCaml'scontainer/delimited node types. On Emacs 31+ this gives us native
forward-list,up-list,down-listand the hybridtreesit-forward-sexp-listfor free.For Emacs 29-30 (where the
listthing isn't wired up bytreesit-major-mode-setup), addedneocaml--forward-sexp-hybridthat falls back to
scan-sexpswhen point is on a delimiter.This follows the same approach Emacs 31 takes internally.