aboutsummaryrefslogtreecommitdiffstats
path: root/admin/tree-sitter (follow)
Commit message (Collapse)AuthorAgeFilesLines
* * lisp/treesit-x.el (treesit-generic-mode-font-lock-map): Extend.Juri Linkov2025-08-291-1/+1
| | | | Add more font-lock mappings based on existing settings in ts-modes.
* 'php-ts-mode' depends on 'mhtml-ts-mode' instead of JS,CSS and HTMLVincenzo Pupillo2025-08-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The direct dependence on 'js-ts-mode', 'css-ts-mode' and html-ts-mode has now been replaced by 'mhtml-ts-mode'. Additional benefits are: 1. Imenu now exposes symbols for all of all languages, 2. navigation now works correctly for all languages, 3. outline works for all languages. Additional new features are: 1. indentation of PHP in mixed buffers with HTML now works much better and allows three different behaviors, an option allows you to choose the behavior. 2. a new feature shows where PHP ini files are both locally and remotely, if the buffer is associated with a remote PHP file. * etc/NEWS: Mention the rationale for those changes, the new command, and the new options. * admin/tree-sitter/treesit-admin.el (treesit-admin--builtin-modes): Added 'mhtml-ts-mode'. (treesit-admin--builtin-features): Added 'mhtml-ts-mode'. * lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-mode--range-settings): New variable that store range settings. (mhtml-ts-mode--treesit-aggregated-outline-predicate): New variable that stores outline predicates. (mhtml-ts-mode): Use those two new variables. * lisp/progmodes/php-ts-mode.el: Update doc string. Removed old dependecies. (php-ts-mode--language-source-alist): Updated parsers version. (php-ts-mode-install-parsers): Removed old dependencies, now relies on mhtml-ts-mode-install-parsers'. Update doc string. (php-ts-mode-js-css-indent-offset): Update doc string. (php-ts-mode-css-fontify-colors): Removed option, now relies on 'php-ts-mode-css-fontify-colors'. (php-ts-mode-html-indent-offset): New user option. (php-ts-mode-html-relative-indent): New user option. (php-ts-mode-php-default-executable): Assume "php" instead of "/usr/bin/php" if 'executable-find' fails. (php-ts-mode-php-config): Fix tag. (php-ts-mode-find-sibling-rules): New user option with the rules for finding siblings of a file. (php-ts-mode-phpdoc-highlight-errors): New user option, if non-nil highlight unkown PHPDOC nodes. (php-ts-mode--indent-style-setter): Indentation fix. (php-ts-mode-indent-style): Indentation fix. (php-ts-mode-flymake-php): Indentation fix. (php-ts-mode--executable): Indentation fix. (php-ts-mode-show-ini): New command that show the locations of PHP ini files. (php-ts-mode--get-indent-style): Indentation fix. (php-ts-mode--set-indent-property): Indentation fix. (php-ts-mode-set-style): Indentation fix. (php-ts-mode--get-parser-ranges): Indentation fix. (php-ts-mode--possibly-braceless-keyword-re): Removed no longer used constant. (php-ts-mode--open-statement-group-heuristic): Removed no longer used function. (php-ts-mode--else-heuristic): Indentation fix. (php-ts-mode--first-sibling): Indentation fix. (php-ts-mode--js-css-tag-bol): Function removed, now using 'mhtml-ts-mode--js-css-tag-bol'. (php-ts-mode--parent-html-bol): Removed no longer used function. (php-ts-mode--parent-html-heuristic): Now more reliably handles the mixed indentation of PHP and HTML. The new option 'php-ts-mode-html-relative-indent' changes the behavior of the function. When 'php-ts-mode-html-relative-indent' is 't' the new option 'php-ts-mode-html-indent-offset' controls the offset of PHP code relative to HTML tags. (php-ts-mode--array-element-heuristic): Indentation fix. (php-ts-mode--anchor-prev-sibling): Indentation fix.. (php-ts-mode--indent-styles): The indentation rules for 'program' and text_interpolation' are now common to all indentation styles, thanks to the new version of 'php-ts-mode-arent-html-heuristic'. New rules for 'namespace_use_clause', 'use_declaration', 'use_list', 'attribute_group' and 'string_content'. (php-ts-mode--prettify-symbols-alist): New variable to support 'prettify-symbols-alist'. (php-ts-mode--test-visibility-modifier-operation-clause-p): Rename ... (php-ts-mode--test-visibility-modifier-operation-p): ... to this more correct name. (php-ts-mode--test-property-hook-clause-p): Rename ... (php-ts-mode--test-property-hook-p): ... to this more correct name. (php-ts-mode--test-relative-name-p): New function to test if 'relative_name' is supported by the PHP parser. (php-ts-mode--font-lock-settings): Use the new function for highlight 'relative_name'. Highlight 'error_suppression_expression'. Refactoring using the renamed functions. Indentation fix. (php-ts-mode--custom-html-font-lock-settings): Replace the rules with 'mhtml-ts-mode--treesit-font-lock-settings'. Fix docs string. (php-ts-mode--phpdoc-font-lock-settings): Added support for "array" and "list" array_type. New "phpdoc-error" feature to highlight unknown nodes via new 'php-ts-mode--phpdoc-fontify-error' function. (php-ts-mode--colorize-css-value): Removed function no longer used, now highlighting is handled directly by 'mhtml-ts-mode'. (php-ts-mode--phpdoc-fontify-error): New function used by 'php-ts-mode--phpdoc-font-lock-settings'. (php-ts-mode--parent-object): Indentation fix. (php-ts-mode--defun-name-separator): Indentation fix. (php-ts-mode--defun-object-name): Indentation fix. (php-ts-mode--defun-name): The function now also returns the defun name of 'mhtml-ts-mode'. (php-ts-mode--treesit-defun-type-regexp): New regexp for 'treesit-defun-type-regexp' support. (php-ts-mode--indent-defun): Indentation fix. (php-ts-mode--defun-valid-p): Fix indentation (php-ts-mode--comment-indent-new-line): Indentation fix. (php-ts-mode--comment-current-plist): New local variable that stores the state of the PHP comment style. (php-ts-mode--comment-setup): The function now handles changing, for different languages, comment styles, using "php-ts-mode--comment-current-plist" to store and retrieve the comment style for the PHP language. (php-ts-mode-comment-setup): Now store the PHP comment style in 'php-ts-mode--comment-current-plist'. (php-ts-mode-menu): Indentation fix. (php-ts-mode): Replace dependency from JS, CSS and HTML width 'mhtml-ts-mode'. Navigation, Imenu and Outline now support PHP, HTML, Javascript and CSS. Added support for 'prettify-symbol-mode'. Added support for 'electric-layout-rules'. (php-ts-mode-run-php-webserver, php-ts-mode--webserver-read-args) (php-ts-mode--webserver-read-args, inferior-php-ts-mode, run-php) (inferior-php-ts-mode-startup, php-ts-mode-inferior--write-history) (php-ts-mode-send-region): Indentation fixes. * lisp/treesit.el (treesit-range-rules): Check if treesit is available before compiling a query. (treesit-ensure-installed): Check if treesit is available before trying to ensure if a grammar library is installed. (Bug#78994)
* Link to Tree-sitter parser sources from compatibility reportPeter Oliver2025-06-231-2/+3
| | | | | | * admin/tree-sitter/treesit-admin.el (treesit-admin--generate-compatibility-report): Add a link to the source URL (bug#78848).
* Show also tagged versions on Tree-sitter compatibility reportPeter Oliver2025-06-232-102/+142
| | | | | | | | | | | * admin/tree-sitter/compat-template.html: Accommodate two tables. * admin/tree-sitter/treesit-admin.el (treesit-admin--find-latest-compatible-revision): Pass through new arg REVISION-TYPE. (treesit-admin--last-compatible-grammar-for-modes): Optionally iterate over tagged rather than all commits. (treesit-admin--generate-compatibility-report): Generate a second table, showing only tagged commits (bug#78848).
* Use keyword :commit with full hashes for treesit-language-source-alist.Juri Linkov2025-06-201-7/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/treesit.el (treesit-language-source-alist): Document the format that uses keywords. (treesit--install-language-grammar-1): Remove args 'revision', 'source-dir', 'cc', 'c++', 'commit'. Use 'args' to process the keywords, and use the remaining list as the previous list of arguments. (treesit--install-language-grammar-1): Let-bind 'treesit--install-language-grammar-full-clone' and 'treesit--install-language-grammar-blobless' to t when 'commit' is non-nil (bug#78542). * lisp/progmodes/c-ts-mode.el: * lisp/progmodes/cmake-ts-mode.el: * lisp/progmodes/csharp-mode.el: * lisp/progmodes/dockerfile-ts-mode.el: * lisp/progmodes/elixir-ts-mode.el: * lisp/progmodes/go-ts-mode.el: * lisp/progmodes/heex-ts-mode.el: * lisp/progmodes/java-ts-mode.el: * lisp/progmodes/js.el: * lisp/progmodes/json-ts-mode.el: * lisp/progmodes/php-ts-mode.el: * lisp/progmodes/python.el: * lisp/progmodes/ruby-ts-mode.el: * lisp/progmodes/rust-ts-mode.el: * lisp/progmodes/sh-script.el: * lisp/progmodes/typescript-ts-mode.el: * lisp/textmodes/css-mode.el: * lisp/textmodes/html-ts-mode.el: * lisp/textmodes/markdown-ts-mode.el: * lisp/textmodes/toml-ts-mode.el: * lisp/textmodes/yaml-ts-mode.el: Use the keyword :commit with full hashes instead of tags in 'treesit-language-source-alist'. * lisp/treesit-x.el (define-treesit-generic-mode): Simplify the keyword :copy-queries. (gitattributes-generic-ts-mode, liquid-generic-ts-mode): Add keywords :commit and :copy-queries to :source. * admin/tree-sitter/treesit-admin.el (treesit-admin--unversioned-treesit-language-source-alist): Handle :revision and :commit as well. (treesit-admin--find-latest-compatible-revision): Process the keywords in the recipe.
* Eliminate redundant variable treesit-admin--builtin-language-sourcesPeter Oliver2025-06-191-38/+71
| | | | | | | | | | | | | | | | | | | | | | | | Nowadays, each mode populates treesit-language-source-alist when the mode is required; we do not need to duplicate the information. * admin/tree-sitter/treesit-admin.el (treesit-admin--builtin-language-sources) (treesit-admin-verify-major-mode-queries) (treesit-admin--generate-compatibility-report): Eliminate variable treesit-admin--builtin-language-sources. (treesit-admin--generate-compatibility-report): bash-ts-mode is “clever” and switches back to sh-mode if it thinks the current buffer does not contain a Bash script (bug#78747). (treesit-admin--builtin-modes): Add missing modes. (treesit-admin--builtin-features): New variable, telling us which features to require to populate treesit-language-source-alist. (treesit-admin--populated-treesit-language-source-alist): New function, to add everything we know to treesit-language-source-alist. (treesit-admin--unversioned-treesit-language-source-alist): Return a copy of treesit-language-source-alist with the version requirements removed. * test/infra/Dockerfile.emba: Make use of treesit-admin--populated-treesit-language-source-alist (bug#78748).
* Replace some 'treesit-query-compile' with 'treesit-query-valid-p'.Juri Linkov2025-04-221-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * admin/tree-sitter/treesit-admin.el (treesit-admin--verify-major-mode-queries) (treesit-admin--validate-mode-lang): * lisp/progmodes/csharp-mode.el (csharp-ts-mode--test-this-expression) (csharp-ts-mode--test-interpolated-string-text) (csharp-ts-mode--test-string-content) (csharp-ts-mode--test-type-constraint) (csharp-ts-mode--test-type-of-expression) (csharp-ts-mode--test-typeof-expression) (csharp-ts-mode--test-name-equals) (csharp-ts-mode--test-if-directive) (csharp-ts-mode--test-method-declaration-type-field): * lisp/progmodes/php-ts-mode.el (php-ts-mode--test-namespace-name-as-prefix-p) (php-ts-mode--test-namespace-aliasing-clause-p) (php-ts-mode--test-namespace-use-group-clause-p) (php-ts-mode--test-visibility-modifier-operation-clause-p) (php-ts-mode--test-property-hook-clause-p): * lisp/progmodes/typescript-ts-mode.el (tsx-ts-mode--font-lock-compatibility-bb1f97b): Use the newer equivalent 'treesit-query-valid-p' instead of 'treesit-query-compile' with 'ignore-errors'.
* Lock tree-sitter language grammars to verified versions.Juri Linkov2025-04-181-21/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * admin/notes/tree-sitter/build-module/build.sh: Update org for toml/yaml. * admin/tree-sitter/treesit-admin.el (treesit-admin--builtin-language-sources): Add verified versions. * lisp/progmodes/c-ts-mode.el: Append language source to treesit-language-source-alist. (c-ts-mode, c++-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/cmake-ts-mode.el: Append language source to treesit-language-source-alist. (cmake-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/csharp-mode.el: Append language source to treesit-language-source-alist. (csharp-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/dockerfile-ts-mode.el: Append language source to treesit-language-source-alist. (dockerfile-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/elixir-ts-mode.el: Append language source to treesit-language-source-alist. (elixir-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/go-ts-mode.el: Append language source to treesit-language-source-alist. (go-ts-mode, go-mod-ts-mode, go-work-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/heex-ts-mode.el: Append language source to treesit-language-source-alist. (heex-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/java-ts-mode.el: Append language source to treesit-language-source-alist. (java-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/js.el: Append language source to treesit-language-source-alist. (js-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/json-ts-mode.el: Append language source to treesit-language-source-alist. (json-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/lua-ts-mode.el: Append language source to treesit-language-source-alist. (lua-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/php-ts-mode.el (php-ts-mode--language-source-alist): Update versions from comments in ts-modes. Append to treesit-language-source-alist. (php-ts-mode-install-parsers): Use treesit-language-source-alist directly. (php-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/ruby-ts-mode.el: Append language source to treesit-language-source-alist. (ruby-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/rust-ts-mode.el: Append language source to treesit-language-source-alist. (rust-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/sh-script.el: Append language source to treesit-language-source-alist. (bash-ts-mode): Use treesit-ensure-installed. * lisp/progmodes/typescript-ts-mode.el: Append language source to treesit-language-source-alist. (typescript-ts-mode, tsx-ts-mode): Use treesit-ensure-installed. * lisp/textmodes/css-mode.el: Append language source to treesit-language-source-alist. (css-ts-mode): Use treesit-ensure-installed. * lisp/textmodes/html-ts-mode.el: Append language source to treesit-language-source-alist. (html-ts-mode): Use treesit-ensure-installed. * lisp/textmodes/markdown-ts-mode.el: Append language source to treesit-language-source-alist. (markdown-ts-mode): Use treesit-ensure-installed. * lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-mode--language-source-alist): Append to treesit-language-source-alist. (mhtml-ts-mode-install-parsers): Use treesit-language-source-alist directly. (mhtml-ts-mode): Use treesit-ensure-installed. * lisp/textmodes/toml-ts-mode.el: Append language source to treesit-language-source-alist. (toml-ts-mode): Use treesit-ensure-installed. * lisp/textmodes/yaml-ts-mode.el: Append language source to treesit-language-source-alist. (yaml-ts-mode): Use treesit-ensure-installed. * test/infra/Dockerfile.emba: Add verified versions to treesit-language-source-alist.
* ; Fix typosStefan Kangas2025-02-221-4/+4
|
* ; Minor change in treesit-admin--generate-compatibility-reportYuan Fu2025-01-031-1/+1
| | | | | | * admin/tree-sitter/treesit-admin.el: (treesit-admin--generate-compatibility-report): Use th for languages.
* ; Minor rephrasing in treesit-admin--verify-major-mode-queriesYuan Fu2025-01-031-2/+2
| | | | | * admin/tree-sitter/treesit-admin.el: (treesit-admin--verify-major-mode-queries): Minor rephrase.
* Update copyright year to 2025Paul Eggert2025-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Generate compatibility report for multiple Emacs versionsYuan Fu2024-12-302-75/+139
| | | | | | | | | | | | | | | | | | | * admin/tree-sitter/compat-template.html: Update template. * admin/tree-sitter/treesit-admin.el: (treesit-admin--builtin-language-sources): Add sources. (treesit-admin--builtin-modes): New variable. (treesit-admin--verify-major-mode-queries): Don't need to pass LANGS argument anymore. (treesit-admin-verify-major-mode-queries): Move, and use treesit-admin--builtin-modes. (treesit-admin--mode-languages): Set some variables so it gets all the languages. (treesit-admin--find-latest-compatible-revision): Also return commit timestamp. (treesit-admin--generate-compatibility-report): New parameter EMACS-EXECUTABLES. Support generating report for multiple Emacs versions. * lisp/treesit.el (treesit--language-git-timestamp): New function.
* Add treesit-admin-generate-compatibility-reportYuan Fu2024-12-302-15/+85
| | | | | | | | | | | | | This function can generate a HTML report on latest compatible grammar versions for each major mode. * admin/tree-sitter/compat-template.html: Update. * admin/tree-sitter/treesit-admin.el: (treesit-admin--validate-mode-lang): Change so that emacs 30 can also run it. (treesit-admin--find-latest-compatible-revision): Support running checks with a different Emacs executable. (treesit-admin--generate-compatibility-report): New function.
* ; Move treesit-admin into tree-sitter directoryYuan Fu2024-12-302-0/+358
* admin/tree-sitter/compat-template.html: New file. * admin/tree-sitter/treesit-admin.el: Move.