File: treesit.el.html
This file is the Lisp counterpart of treesit.c. Together they provide tree-sitter integration for Emacs. This file contains convenient functions that are more idiomatic and flexible than the exposed C API of tree-sitter. It also contains frameworks for integrating tree-sitter with font-lock, indentation, activating and deactivating tree-sitter, debugging tree-sitter, etc.
Some conventions:
1. Whenever it makes sense, a function that takes a tree-sitter node
as an argument should also accept nil (and return nil in that case).
This is to help with function chaining.
2. In most cases, a function shouldn't implicitly create a parser.
All parsers should be created explicitly by user. Use
(car (treesit-parser-list nil LANG))
to get a parser for a certain language.
Initially in Emacs 29, the world is simple and each language has one parser in the buffer. So if we need a parser for a language, we can just create it if it doesn't exist. But now we have local parsers, so there will be more than one parser for each language in a buffer. We can also have local parser of the same language as the host parser. All of which means we can't equalize language and parser, and create parser for a language willy-nilly anymore. Major mode will manage their parsers.
Defined variables (55)
treesit--explorer-buffer | Buffer used to display the syntax tree. |
treesit--explorer-highlight-overlay | Overlay used to highlight in syntax tree and source buffer. |
treesit--explorer-last-node | Last top-level node used to generate syntax tree. |
treesit--explorer-parser | The language used in the playground. |
treesit--explorer-refresh-timer | Timer for refreshing the syntax tree buffer. |
treesit--explorer-source-buffer | Source buffer corresponding to the playground buffer. |
treesit--explorer-tree-mode-abbrev-table | Abbrev table for ‘treesit--explorer-tree-mode’. |
treesit--explorer-tree-mode-hook | Hook run after entering ‘treesit--explorer-tree-mode’. |
treesit--explorer-tree-mode-map | Keymap for the treesit tree explorer. |
treesit--explorer-tree-mode-syntax-table | Syntax table for ‘treesit--explorer-tree-mode’. |
treesit--font-lock-fast-mode | If this variable is t, change the way we query so it’s faster. |
treesit--font-lock-query-expand-range | The amount to expand the start and end of the region when fontifying. |
treesit--font-lock-verbose | If non-nil, print debug messages when fontifying. |
treesit--indent-region-batch-size | How many lines of indent value do we precompute. |
treesit--indent-verbose | If non-nil, log progress when indenting. |
treesit--inspect-name | Used by ‘treesit-inspect-mode’ to show node name in mode-line. |
treesit--install-language-grammar-blobless | If non-nil, create a blobless clone when cloning git repos. |
treesit--install-language-grammar-full-clone | If non-nil, do a full clone when cloning git repos. |
treesit--install-language-grammar-out-dir-history | History for OUT-DIR for ‘treesit-install-language-grammar’. |
treesit--parser-overlay-offset | Defines at which position to get the parser overlay. |
treesit--pre-redisplay-tick | The last ‘buffer-chars-modified-tick’ that we’ve processed. |
treesit--query-cache | Cache of compiled queries for font-lock/indentation. |
treesit--syntax-propertize-start | If non-nil, next ‘syntax-propertize’ should start at this position. |
treesit-add-log-defun-delimiter | The delimiter used to connect several defun names. |
treesit-aggregated-outline-predicate | Settings that configure ‘treesit-outline-search’ for multi-language modes. |
treesit-aggregated-simple-imenu-settings | Settings that configure ‘treesit-simple-imenu’ for multi-language modes. |
treesit-auto-install-grammar | Whether to install tree-sitter language grammar libraries when needed. |
treesit-defun-name-function | A function that is called with a node and returns its defun name or nil. |
treesit-defun-skipper | A function called after tree-sitter navigation moved a step. |
treesit-defun-tactic | Determines how Emacs treats nested defuns. |
treesit-defun-type-regexp | A regexp that matches the node type of defun nodes. |
treesit-enabled-modes | Specify which tree-sitter based major modes to enable by default. |
treesit-explore-mode | Non-nil if Treesit-Explore mode is enabled. |
treesit-explore-mode-hook | Hook run after entering or leaving ‘treesit-explore-mode’. |
treesit-font-lock-feature-list | A list of lists of feature symbols. |
treesit-font-lock-level | Decoration level to be used by tree-sitter fontifications. |
treesit-font-lock-settings | A list of SETTINGs for treesit-based fontification. |
treesit-indent-function | Function used by ‘treesit-indent’ to do some of the work. |
treesit-inspect-mode | Non-nil if Treesit-Inspect mode is enabled. |
treesit-inspect-mode-hook | Hook run after entering or leaving ‘treesit-inspect-mode’. |
treesit-language-at-point-function | A function that returns the language at point. |
treesit-language-display-name-alist | An alist mapping language symbols to their display names. |
treesit-language-source-alist | Configuration for downloading and installing tree-sitter language grammars. |
treesit-max-buffer-size | Maximum buffer size (in bytes) for enabling tree-sitter parsing. |
treesit-outline-predicate | Predicate used to find outline headings in the syntax tree. |
treesit-primary-parser | The primary parser for this buffer. |
treesit-range-settings | A list of range settings. |
treesit-sexp-thing | A thing that matches the sexp nodes for ‘forward-sexp’. |
treesit-sexp-thing-down-list | A thing that matches the sexp nodes for ‘down-list’. |
treesit-sexp-thing-up-list | A thing that matches the sexp nodes for ‘up-list’. |
treesit-simple-imenu-settings | Settings that configure ‘treesit-simple-imenu’. |
treesit-simple-indent-override-rules | Extra simple indent rules for customizing indentation. |
treesit-simple-indent-presets | A list of indent rule presets. |
treesit-simple-indent-rules | A list of indent rule settings. |
treesit-simple-indent-standalone-predicate | Function used to determine if a node is "standalone". |
Defined functions (153)
Defined faces (2)
treesit-explorer-anonymous-node | Face for anonymous nodes in tree-sitter explorer. |
treesit-explorer-field-name | Face for field names in tree-sitter explorer. |