summaryrefslogtreecommitdiff
path: root/lisp/progmodes/java-ts-mode.el
Commit message (Collapse)AuthorAgeFilesLines
* java-ts-mode: Indentation for opening brace on a separate lineDmitry Gutov2024-02-171-4/+9
| | | | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Support putting the opening brace on a separate line (bug#67556). * test/lisp/progmodes/java-ts-mode-resources/indent.erts: Add a test.
* ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
|
* Add indentation rules for type_argumentsTheodor Thornhill2023-09-171-0/+2
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Indent as opening braces.
* Backport: Fix some tree-sitter :match regexpsBasil L. Contovounesios2023-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This was originally installed on 2023-06-17 in the emacs-29 release branch and later reverted. This backport follows the Emacs 29.1 release (bug#64019). The shy groups were caught by modified versions of the GNU ELPA packages xr and relint: - https://github.com/mattiase/xr/pull/6 - https://github.com/mattiase/relint/pull/14 * lisp/progmodes/ruby-ts-mode.el (ruby-ts--s-p-query): Quote special character in regexp. * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): * lisp/progmodes/js.el (js--plain-method-re): (js--treesit-font-lock-settings): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--font-lock-settings): Replace character alternative [\\d], which matches '\' or 'd', with the most likely intention [0-9]. Fix shy groups mistyped as optional colons. Remove unneeded numbered :match group in rust-ts-mode. (cherry picked from commit cd8d3f3379ec7179fac4bb8e9c40658be15a64f6)
* Revert "Fix some tree-sitter :match regexps"Basil L. Contovounesios2023-06-171-1/+1
| | | | | | | | | | This reverts commit 95091b77f0bbb2ae1aa94ef4a413626e7d434d58 of 2023-06-17, mistakenly pushed to emacs-29. The patch will be installed on master instead, and backported later, after Emacs 29.1 is released (bug#64019). Do not merge to master.
* Fix some tree-sitter :match regexpsBasil L. Contovounesios2023-06-171-1/+1
| | | | | | | | | | | | | | | | | | | The shy groups were caught by modified versions of the GNU ELPA packages xr and relint: - https://github.com/mattiase/xr/pull/6 - https://github.com/mattiase/relint/pull/14 * lisp/progmodes/ruby-ts-mode.el (ruby-ts--s-p-query): Quote special character in regexp. * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): * lisp/progmodes/js.el (js--plain-method-re): (js--treesit-font-lock-settings): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--font-lock-settings): Replace character alternative [\\d], which matches '\' or 'd', with the most likely intention [0-9]. Fix shy groups mistyped as optional colons. Remove unneeded numbered :match group in rust-ts-mode (bug#64019).
* Fix bol/bos anchors in tree-sitter :match regexpsBasil L. Contovounesios2023-06-131-2/+2
| | | | | | | | | | | | | | | | | Further regexp fixes to follow separately (bug#64019#29). * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode--font-lock-settings): * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): * lisp/progmodes/js.el (js--treesit-font-lock-settings): * lisp/progmodes/python.el (python--treesit-settings): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings): * lisp/progmodes/sh-script.el (sh-mode--treesit-settings): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--font-lock-settings): * test/src/treesit-tests.el (treesit-query-api): Anchor :match regexps at beginning/end of string, not line.
* Add compact_constructor_declaration font-locking to java-ts-modeTheodor Thornhill2023-05-301-0/+3
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): New pattern.
* ; * lisp/progmodes/java-ts-mode.el (treesit-query-capture): Declare.Eli Zaretskii2023-03-091-0/+2
|
* java-ts-mode: detect if text_block is supported.Vincenzo Pupillo2023-03-091-2/+11
| | | | | | | | | | | | | | A recent commit in tree-sitter-java (issue #141) removed support for the text_block node type from the grammar. To support the old released version and the new one, a helper function was added on which the string syntax highlighting now depends. (bug#61913) * lisp/progmodes/java-ts-mode.el (java-ts-mode--string-highlight-helper): New helper function that return the right query string (java-ts-mode--font-lock-settings): Use it Copyright-paperwork-exempt: yes
* Change tree-sitter indent anchor 'point-min' to 'column-0'Yuan Fu2023-03-041-10/+10
| | | | | | | | | | | | | | Point-min isn't necessarily at column 0, using line-beginning-position is better. column-0 is also more intuitive. * doc/lispref/modes.texi (Parser-based Indentation): Update manual. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--indent-rules): * lisp/progmodes/typescript-ts-mode.el: (typescript-ts-mode--indent-rules): Change point-min to column-0. * lisp/treesit.el (treesit-simple-indent-presets): Change point-min to column-0.
* Rename the newly added -ref- faces to -use-Dmitry Gutov2023-02-281-3/+3
| | | | | | * lisp/font-lock.el (font-lock-variable-use-face) (font-lock-property-use-face): Rename from font-lock-variable-ref-face and font-lock-property-ref-face. Update all references (bug#61655).
* Add more/finer faces for tree-sitterDmitry Gutov2023-02-251-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/modes.texi (Faces for Font Lock): Update the list of faces (bug#61655). * etc/NEWS: Update the list of new faces. * lisp/cus-theme.el (custom-theme--listed-faces): Update. * lisp/font-lock.el (font-lock-function-call-face) (font-lock-variable-ref-face, font-lock-property-ref-face): New faces. (font-lock-property-name-face): Rename from 'font-lock-property-face'. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Use new faces. More 'enumerator' query to 'definition' feature. (c-ts-mode--fontify-declarator, c-ts-mode--fontify-variable): Use new faces. * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/csharp-mode.el (csharp-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/go-ts-mode.el (go-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/js.el (js--treesit-fontify-assignment-lhs) (js--treesit-font-lock-settings): Use new faces. Highlight variable definitions inside array and object destructuring patterns. * lisp/progmodes/python.el (python--treesit-variable-p): Exclude identifiers in parameters. (python--treesit-settings): Use new faces. Highlight function parameters. Move 'keyword' up to still highlight 'self' as keyword. * lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings): Use new faces. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--font-lock-settings): Use new faces. * lisp/textmodes/css-mode.el (css--treesit-settings): Use font-lock-property-ref-face. * lisp/textmodes/toml-ts-mode.el (toml-ts-mode--font-lock-settings): Use font-lock-property-ref-face. * lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode--font-lock-settings): Same.
* Add super node as a keywordTheodor Thornhill2023-02-151-1/+2
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): Add new node.
* Add lambda_expression to c-ts-common-indent-type-regexp-alistTheodor Thornhill2023-02-121-0/+1
| | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode): Tweak regexp.
* Make java-ts-mode use the c-ts-common-indent-type-regexp-alistYuan Fu2023-02-061-14/+16
| | | | | * lisp/progmodes/java-ts-mode.el: (java-ts-mode): Setup c-ts-common-indent-type-regexp-alist.
* Use c-ts-common-statement-offset in java-ts-mode (bug#61142)Theodor Thornhill2023-02-061-9/+27
| | | | | | | | | | | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new matchers to enable c-ts-common machinery. (java-ts-mode): Add regexps. * lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset): Fix typo in documentation and use the new if statement helpers. (c-ts-common-if-statement-regexp): New defvar. (c-ts-common-nestable-if-statement-p): New defvar. (c-ts-common--fix-nestable-if-statement): New helper. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add test for complicated bracket matching indentation. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Add indent rules for bracketless statements.
* Add array_initializer to java-ts-modeTheodor Thornhill2023-02-061-0/+1
| | | | | | | | | | | | | | | | Indent strings inside arrray_initializer one step: public class Java { void foo() { return new String[]{ "foo", // These "bar" } } } * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): New matcher.
* Fix java class member without access modifier (bug#61115)Theodor Thornhill2023-01-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This ``` public class T { @Autowired String a; } ``` Should be indented as: ``` public class T { @Autowired String a; } ```` * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new rule to match edge case of field_declaration indentation.
* Add new java indent rulesTheodor Thornhill2023-01-251-0/+2
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Check for enum_body_declarations and switch_label.
* Move c-like common utils into own library (bug#60961)Theodor Thornhill2023-01-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/c-ts-common.el: New file. * lisp/progmodes/c-ts-mode.el (treesit-induce-sparse-tree): Remove unused declaration. (c-ts-mode--indent-styles): Refer to the new library. (c-ts-mode--looking-at-star, c-ts-mode--comment-start-after-first-star, c-ts-mode--comment-2nd-line-matcher, c-ts-mode--comment-2nd-line-anchor, c-ts-mode--comment-regexp, c-ts-mode--fill-paragraph, c-ts-mode--fill-block-comment): Move to c-ts-common and expose as public. (c-ts-mode-comment-setup): Move to c-ts-common. * lisp/progmodes/csharp-mode.el (c-ts-common): Require new library. (csharp-ts-mode--indent-rules): Refer to the new symbols. (csharp-ts-mode): Use new function. * lisp/progmodes/java-ts-mode.el (c-ts-common): Require new library. (java-ts-mode--indent-rules): Refer to the new symbols. (java-ts-mode): Use new function. * lisp/progmodes/js.el (c-ts-common): Require new library. (js--treesit-indent-rules): Refer to the new symbols. (js-ts-mode): Use new function. * lisp/progmodes/rust-ts-mode.el (c-ts-common): Require new library. (rust-ts-mode--indent-rules): Refer to the new symbols. (rust-ts-mode): Use new function. * lisp/progmodes/typescript-ts-mode.el (c-ts-common): Require new library. (typescript-ts-mode--indent-rules): Refer to the new symbols. (typescript-ts-base-mode): Use new function.
* Use point-min to anchor top-level constructs (bug#60602)Theodor Thornhill2023-01-201-1/+1
| | | | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New anchor. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): New anchor. * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): New anchor. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--indent-rules): New anchor.
* Make tree-sitter based modes optionalEli Zaretskii2023-01-201-0/+3
| | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/c-ts-mode.el: Update Commentary. Make 'auto-mode-alist' update conditional on the tree-sitter and grammar libraries being available. * lisp/progmodes/cmake-ts-mode.el: * lisp/progmodes/csharp-mode.el: * lisp/progmodes/dockerfile-ts-mode.el: * lisp/progmodes/go-ts-mode.el: * lisp/progmodes/java-ts-mode.el: * lisp/progmodes/js.el: * lisp/progmodes/json-ts-mode.el: * lisp/progmodes/python.el: * lisp/progmodes/ruby-ts-mode.el: * lisp/progmodes/typescript-ts-mode.el: * lisp/textmodes/css-mode.el: * lisp/textmodes/toml-ts-mode.el: * lisp/textmodes/yaml-ts-mode.el: Make 'auto-mode-alist' update for tree-sitter based modes be conditional on the tree-sitter and grammar libraries being available. (Bug#60559)
* Add constructor_declaration as java-ts-mode defunTheodor Thornhill2023-01-141-1/+2
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode): Extend treesit-defun-type-regexp.
* Fix indent and font-lock for annotation_typeTheodor Thornhill2023-01-141-1/+5
| | | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Indent inside body. (java-ts-mode--font-lock-settings): Add rule for name in annotation_type_element_declaration.
* Fix indentation of some declarations and statementsTheodor Thornhill2023-01-141-0/+4
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new rules so that we don't anchor at col 0.
* Add support for annotation_type_declarationTheodor Thornhill2023-01-111-2/+6
| | | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--keywords): Add new keyword. (java-ts-mode--font-lock-settings): Add font-locking to the type feature.
* Improve fontification in java-ts-mode (bug#60492)Theodor Thornhill2023-01-021-1/+3
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): Add expression_statement with only identifier support.
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
|
* ; Avoid treesit-related byte-compiler warningsEli Zaretskii2022-12-281-0/+1
| | | | | | | | | * lisp/progmodes/json-ts-mode.el (treesit-node-child-by-field-name): * lisp/textmodes/toml-ts-mode.el (treesit-node-child-by-field-name): * lisp/progmodes/java-ts-mode.el (treesit-node-child-by-field-name): * lisp/progmodes/csharp-mode.el (treesit-node-child-by-field-name): Avoid byte-compilation warnings about treesit-node-type.
* Fix tree-sitter typosYuan Fu2022-12-281-1/+1
| | | | | | | * doc/lispref/parsing.texi (Tree-sitter major modes): * lisp/progmodes/java-ts-mode.el: * test/src/treesit-tests.el (treesit-defun-navigation-nested-4): Fix typo.
* Update tree-sitter major modes to use the new Imenu facilityYuan Fu2022-12-271-46/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See previous commit for more explanation. * lisp/progmodes/c-ts-mode.el (c-ts-mode--defun-name): Handle more types. (c-ts-mode--imenu-1) (c-ts-mode--imenu): Remove functions. (c-ts-base-mode): Setup Imenu. * lisp/progmodes/csharp-mode.el (csharp-ts-mode--imenu-1) (csharp-ts-mode--imenu): Remove functions. (csharp-ts-mode): Setup Imenu. * lisp/progmodes/java-ts-mode.el (java-ts-mode--imenu-1) (java-ts-mode--imenu): Remove functions. (java-ts-mode): Setup Imenu. * lisp/progmodes/js.el (js--treesit-imenu-1) (js--treesit-imenu): Remove functions. (js--treesit-valid-imenu-entry): New function. (js-ts-mode): Setup Imenu. * lisp/progmodes/json-ts-mode.el (json-ts-mode--defun-name): Trim the quotes. (json-ts-mode--imenu-1) (json-ts-mode--imenu): Remove functions. (json-ts-mode): Setup Imenu. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--imenu) (rust-ts-mode--imenu-1): Remove functions. (rust-ts-mode): Setup Imenu. * lisp/progmodes/typescript-ts-mode.el: (typescript-ts-base-mode): Remove treesit-defun-prefer-top-level, it's not used anymore. Setup Imenu. Setup treesit-defun-name-function. * lisp/textmodes/css-mode.el (css--treesit-imenu-1) (css--treesit-imenu): Remove functions. (css-ts-mode): Setup Imenu. * lisp/textmodes/toml-ts-mode.el (toml-ts-mode--defun-name): Fix it and add a fallback. (toml-ts-mode--imenu-1) (toml-ts-mode--imenu): Remove functions. (toml-ts-mode): Setup Imenu.
* Add comment indent and filling to other tree-sitter major modesYuan Fu2022-12-261-11/+5
| | | | | | | | | | | | | | | | | | | | | | | | Extract the setup into a function, and use it in other major modes. * lisp/progmodes/c-ts-mode.el (c-ts-mode-comment-setup): New function. (c-ts-base-mode): Extract out. (c-ts-mode) (c++-ts-mode): Remove old setup. * lisp/progmodes/csharp-mode.el (csharp-ts-mode--indent-rules): New indent rules. (csharp-ts-mode): Use new setup function. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): New indent rules. (java-ts-mode): Use new setup function. * lisp/progmodes/js.el (js--treesit-indent-rules): New indent rules. (js-ts-mode): Use new setup function. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--indent-rules): New indent rules. (rust-ts-mode): Use new setup function. * lisp/progmodes/typescript-ts-mode.el: (typescript-ts-mode--indent-rules): New indent rules. (typescript-ts-base-mode): Use new setup function.
* Support treesit-defun-name in tree-sitter major modesYuan Fu2022-12-241-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/csharp-mode.el (csharp-ts-mode--defun-name): New function. (csharp-ts-mode--imenu-1): Extract into new function. (csharp-ts-mode): Setup treesit-defun-name-function. * lisp/progmodes/java-ts-mode.el (java-ts-mode--defun-name): New function. (java-ts-mode--imenu-1): Extract into new function. (java-ts-mode): Setup treesit-defun-name-function. * lisp/progmodes/js.el (js-treesit-current-defun): Remove function. This function is not used (for a while already). (js--treesit-defun-name): New function. (js--treesit-imenu-1): Extract into new function. (js-ts-mode): Setup treesit-defun-name-function. * lisp/progmodes/json-ts-mode.el (json-ts-mode--defun-name): New function. (json-ts-mode--imenu-1): Extract into new function. (json-ts-mode): Setup treesit-defun-name-function. * lisp/progmodes/python.el (python--treesit-defun-name): New function. (python--imenu-treesit-create-index-1): Extract into new function. (python-ts-mode): Setup treesit-defun-name-function. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--defun-name): New function. (rust-ts-mode--imenu-1): Extract into new function. (rust-ts-mode): Setup treesit-defun-name-function. * lisp/textmodes/css-mode.el (css--treesit-defun-name): New function. (css--treesit-imenu-1): Extract into new function. (css-ts-mode): Setup treesit-defun-name-function. * lisp/textmodes/toml-ts-mode.el (toml-ts-mode--get-table-name): Remove function. (toml-ts-mode--defun-name): New function. (toml-ts-mode--imenu-1): Extract into new function. (toml-ts-mode): Setup treesit-defun-name-function.
* Add lambda_expression-rule to java-ts-mode (bug#60091)Theodor Thornhill2022-12-151-0/+1
| | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): New rule.
* Add "this" keyword to java-ts-mode (bug#60086)Theodor Thornhill2022-12-151-3/+4
| | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): Add the node to the keyword feature.
* Tweak various ts-mode's indent and fontification (bug#59931)Theodor Thornhill2022-12-121-1/+3
| | | | | | | | | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw string literal font-locking. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add text_block indent rule. (java-ts-mode--font-lock-settings): Add text_block font-locking. * lisp/progmodes/js.el (js-ts-mode): Prefer top-level navigation. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add comment feature. (json-ts-mode): Use comment feature. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Prefer top-level navigation.
* Make more granular defun-type-regexp (bug#59873)Theodor Thornhill2022-12-091-1/+9
| | | | | | | | | We don't want to match local_variable_declaration and others to hit on beginning-of-defun. The fix is just to make the regexp a bit more granular. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Use regexp-opt to distinguish more granularly.
* ; Normalize GPLv3 license statements in new filesStefan Kangas2022-12-091-3/+3
|
* ; lisp/progmodes/java-ts-mode.el: Fix more typos.Stefan Kangas2022-12-081-3/+2
|
* ; * lisp/progmodes/java-ts-mode.el (java-ts-mode--keywords): Fix typo.Eli Zaretskii2022-12-081-1/+1
|
* Fix syntax-table for tree-sitter modesTheodor Thornhill2022-12-071-0/+5
| | | | | | | | | | | | | | | | | | When adapting the 'c-populate-syntax-table' for tree-sitter, I misread the code, and thus some crucial entries were missing. For the relevant modes we use the same table as specified in the non-tree-sitter major mode. * lisp/progmodes/c-ts-mode.el (c-ts-mode--syntax-table): Add new entries. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add new entries. * lisp/progmodes/java-ts-mode.el (java-ts-mode--syntax-table): Add new entries. * lisp/progmodes/json-ts-mode.el (json-ts-mode--syntax-table): Add new entries. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--syntax-table): Add new entries. * lisp/textmodes/css-mode.el (css-ts-mode): Add new entries.
* Fix comment-start-skip in tree-sitter modes (bug#59690)Yuan Fu2022-12-031-1/+2
| | | | | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode) (c++-ts-mode) * lisp/progmodes/csharp-mode.el (csharp-ts-mode) * lisp/progmodes/java-ts-mode.el (java-ts-mode) * lisp/progmodes/js.el (js-ts-mode) * lisp/progmodes/typescript-ts-mode.el (tsx-ts-mode): Remove the group from the regexp.
* Remove treesit-comment-start/end and use comment-start/end-skipYuan Fu2022-11-271-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | treesit-comment-start/end is unnecessary because of comment-start/end-skip, so they should be removed. Cleanup and set comment-start/end-skip for tree-sitter C-like major modes. I replaced the [ \t]* part in comment-start-skip with (syntax whitespace), which is what comment-end-skip uses. I also added grouping in comment-start-skip to match that of comment-end-skip. * lisp/progmodes/c-ts-mode.el (c-ts-mode) (c++-ts-mode) * lisp/progmodes/csharp-mode.el (csharp-ts-mode) * lisp/progmodes/java-ts-mode.el (java-ts-mode) * lisp/progmodes/js.el (js-ts-mode) * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode): Setup comment-start/end-skip. * lisp/treesit.el (treesit-comment-start) (treesit-comment-end): Remove variables. (treesit-simple-indent-presets): Use comment-start/end-skip instead.
* Reorganize treesit-font-lock-feaure-list's to the new level schemeYuan Fu2022-11-261-3/+4
| | | | | | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode--base-mode) * lisp/progmodes/csharp-mode.el (csharp-ts-mode) * lisp/progmodes/java-ts-mode.el (java-ts-mode) * lisp/progmodes/js.el (js-ts-mode) * lisp/progmodes/python.el (python-ts-mode) * lisp/progmodes/sh-script.el (bash-ts-mode) * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode): Reorganized treesit-font-lock-feature-list.
* Utilize new font-lock faces for more tree-sitter modes (Bug#59397)Randy Taylor2022-11-221-6/+9
| | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): Use font-lock-number-face. (java-ts-mode): Alphabetize features. * lisp/progmodes/js.el (js--treesit-operators): Define operators. (js--treesit-font-lock-settings): Use bracket, delimiter, escape-sequence, property, number, and operator font-lock faces. (js-ts-mode): Add them to the feature list and alphabetize. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Use bracket, delimiter, escape-sequence, and number faces. Remove unused features. (json-ts-mode): Add them to the feature list and alphabetize. * lisp/progmodes/sh-script.el (sh-mode--treesit-settings): Use bracket, delimiter, number, misc-punctuation, and operator font-lock faces. (sh-mode--treesit-operators): Remove ; and ;; from list. (bash-ts-mode): Add them to the feature list and alphabetize. * lisp/progmodes/ts-mode.el (ts-mode--operators): Define operators. (ts-mode--font-lock-settings): Use escape-sequence, number, and operator font-lock faces. (ts-mode): Add them to the feature list and alphabetize.
* Tweak faces in Java and TypeScriptTheodor Thornhill2022-11-221-39/+46
| | | | | | | | | | | | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--operators): Remove @ as an operator. (java-ts-mode--font-lock-settings): Use constant-face for @ to match rest of the annotation. Add bracket, delimiter and use some of the new faces. (java-ts-mode--imenu): Clean up the implementation a little. (java-ts-mode): Refer to the new features. * lisp/progmodes/ts-mode.el (ts-mode--font-lock-settings, ts-mode): Add in bracket and delimiter'.
* ; Silence byte-compiler warningsEli Zaretskii2022-11-211-0/+5
| | | | | | | | | | * lisp/textmodes/css-mode.el: * lisp/progmodes/python.el: * lisp/progmodes/json-ts-mode.el: * lisp/progmodes/js.el: * lisp/progmodes/java-ts-mode.el: * lisp/progmodes/c-ts-mode.el: Add declarations of tree-sitter functions.
* Limit recursion level for tree-sitter imenu functionsYuan Fu2022-11-201-5/+5
| | | | | | | | | | | | | | Generating imenu index doesn't require going down to the bottom of the tree (defun's are usually top-level). Add limit so we don't go too far down on very large buffers. * lisp/progmodes/c-ts-mode.el (c-ts-mode--imenu) * lisp/progmodes/java-ts-mode.el (java-ts-mode--imenu) * lisp/progmodes/js.el (js--treesit-imenu) * lisp/progmodes/json-ts-mode.el (json-ts-mode--imenu) * lisp/progmodes/python.el (python-imenu-treesit-create-index) * lisp/textmodes/css-mode.el (css--treesit-imenu): Add limit to treesit-induce-sparse-tree.
* Fix uses of treesit-ready-pYuan Fu2022-11-191-1/+1
| | | | | | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode) (c++-ts-mode) * lisp/progmodes/java-ts-mode.el (java-ts-mode) * lisp/progmodes/js.el (js-ts-mode) * lisp/progmodes/json-ts-mode.el (json-ts-mode) * lisp/progmodes/python.el (python-ts-mode) * lisp/progmodes/sh-script.el (sh-mode) * lisp/progmodes/ts-mode.el (ts-mode): Remove the MODE argument.