Skip to content

Add tree-sitter "programming modes" supported by Hyperbole - #576

Merged
matsl merged 2 commits into
masterfrom
add-tree-sitter-modes
Aug 18, 2024
Merged

matsl merged 2 commits into
masterfrom
add-tree-sitter-modes

Conversation

@matsl

@matsl matsl commented Aug 16, 2024

Copy link
Copy Markdown
Collaborator

What

Add tree-sitter based modes for the programming modes currently
supported by Hyperbole.

Why

Hyperbole uses buffers current major mode for checking if some
functionality shall be available in the buffer. With tree-sitter comes
modes for many programming languages and those can be used instead of
the old programming modes. These new modes are not recognized by
Hyperbole and if they are used the programming language specific
buttons are not recognized.

Note

Was looking into tree-sitter and to use the c++-ts-mode in a c++
file only to realize that Hyperbole smart-c++ was not available in
that case because we don't understand what c++-ts-mode is.

This just blindly adds the tree-sitter modes to the program language
checks. There are no automatic tests that this works for all cases. On
the other hand we have no tests that it works for all the old modes
either.

It seems some old modes and tree sitter modes use the same base
mode. It could be possible to use that in Hyperbole to check for the
base mode instead to limit the modes to check for. This is not a
general pattern though so can only be applied after checking for each
programming language.

No analysis have been done if there are tree-sitter features that
Hyperbole utilized. This PR only allows the programming language to
derived by looking at the tree-sitter modes.

@matsl
matsl requested a review from rswgnu August 16, 2024 22:11

@rswgnu rswgnu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Fix the comments and then it will be good. -- rsw

Comment thread hui-mouse.el Outdated
. ((smart-java) . (smart-java nil 'next-tag)))
;;
((and (memq major-mode '(js2-mode js-mode js3-mode javascript-mode html-mode web-mode))
((and (memq major-mode '(js2-mode js-mode js3-mode javascript-mode html-mode web-mode js-ts-mode))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Keep these mode names in alphabetical order.

Comment thread hui-select.el Outdated
(defcustom hui-select-brace-modes
'(c++-mode c-mode java-mode objc-mode perl-mode tcl-mode)
'(c++-mode c-mode java-mode objc-mode perl-mode tcl-mode
c++-ts-mode c-ts-mode java-ts-mode)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Same comment as above. Check the whole PR for this ordering issue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same comment as above. Check the whole PR for this ordering issue.

The mode lists should now be sorted.

@matsl
matsl force-pushed the add-tree-sitter-modes branch from af51c45 to 070fdff Compare August 18, 2024 07:46
@matsl
matsl requested a review from rswgnu August 18, 2024 07:48
@matsl
matsl merged commit 12c4a31 into master Aug 18, 2024
@matsl
matsl deleted the add-tree-sitter-modes branch August 18, 2024 17:40
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.

2 participants