aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/dev.lua
Commit message (Collapse)AuthorAge
* feat(treesitter): show which nodes are missing in InspectTreeRiley Bruins2025-02-05
| | | | | | | | Now `:InspectTree` will show missing nodes as e.g. `(MISSING identifier)` or `(MISSING ";")` rather than just `(identifier)` or `";"`. This is doable because the `MISSING` keyword is now valid query syntax. Co-authored-by: Christian Clason <c.clason@uni-graz.at>
* fix: resolve all remaining LuaLS diagnosticsLewis Russell2025-01-27
|
* refactor: use nvim.foo.bar format for autocommand groupsMaria José Solano2025-01-14
|
* refactor: use nvim.foo.bar format for namespacesMaria José Solano2025-01-14
|
* fix(treesitter): keep treeview open if source window is still open #31198Hyker2024-11-14
| | | | | | | | | | | | Problem: When there is a tree view opened by :InspectTree and the source buffer is open in multiple windows, closing one of the source windows will lead to the tree view being closed as well. Regression by #31181. Solution: Check how many source windows are open when trying to quit one. If there are more than one, keep the tree view(s) open. If the only source window is closed, also close the tree view(s). fix #31196
* fix(treesitter): add 'QuitPre' event to autocommands in inspect_treehykerr2024-11-12
| | | | | | | | | Problem: Quitting source buffer for ```:InspectTree``` command raises ```E855``` when source buffer and tree views are the only open buffers. Solution: Add ```QuitPre``` event to autocmd handling closing/hiding the source buffer to close all open tree views. This allows nvim to quit when source and tree buffers are the only open windows.
* fix(treesitter): close InspectTree/EditQuery window on BufUnload (#31036)zeertzjq2024-11-03
| | | | | | Problem: The window opened :InspectTree or :EditQuery isn't closed when the source buffer is unloaded, even though it is closed when the buffer is hidden. Solution: Also close the window on BufUnload.
* perf(validate): use lighter versionLewis Russell2024-10-17
| | | | | - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number.
* fix(treesitter): indent size for inspect_tree #28727Jongwook Choi2024-10-01
| | | | | | | | | | | Problem: For :InspectTree, indent size (`&shiftwidth`) for the tree viewer may be incorrect. This is because the tree viewer buffer with the filetype `query` does not explicitly configures the tab size, which can mismatch with the default indent size (2) assumed by TSTreeView's implementation. Solution: Set shiftwidth to be the same as TSTreeViewOpts specifies, which defaults to 2.
* fix(treesitter): specify success status in edit_query return valueRiley Bruins2024-09-28
|
* fix(treesitter): suppress get_parser warnings via opts.errorRiley Bruins2024-09-28
|
* fix(treesitter): EditQuery shows swapfile ATTENTION #30536Justin M. Keyes2024-09-27
| | | | | | | | Problem: EditQuery shows swapfile ATTENTION, but this buffer is not intended for preservation (and the dialog breaks the UX). Solution: Set 'noswapfile' on the buffer before renaming it.
* feat(treesitter): start moving get_parser to return nil #30313Riley Bruins2024-09-13
| | | | | | | | | | | | | | | | | | | **Problem:** `vim.treesitter.get_parser` will throw an error if no parser can be found. - This means the caller is responsible for wrapping it in a `pcall`, which is easy to forget - It also makes it slightly harder to potentially memoize `get_parser` in the future - It's a bit unintuitive since many other `get_*` style functions conventionally return `nil` if no object is found (e.g. `get_node`, `get_lang`, `query.get`, etc.) **Solution:** Return `nil` if no parser can be found or created - This requires a function signature change, and some new assertions in places where the parser will always (or should always) be found. - This commit starts by making this change internally, since it is breaking. Eventually it will be rolled out to the public API.
* fix(treesitter): highlight anonymous nodes in inspect_treeRiley Bruins2024-07-29
| | | | | | | | | | **Problem:** With anonymous nodes toggled in the inspect tree, only named nodes will be highlighted when moving the cursor in the source code buffer. **Solution:** Retrieve the anonymous node at the cursor (when toggled on in the inspect tree) and highlight them when appropriate, for better clarity/specificity.
* fix(treesitter): display fields for anonymous nodes in :InspectTreeRiley Bruins2024-07-05
|
* refactor(lua): use tuple syntax everywhere #29111Ilia Choly2024-06-04
|
* fix(treesitter): find buffer in multiple windows #28922Guilherme Soares2024-05-27
| | | | | | | | | | | | | Problem: 1. When interacting with multiple :InspectTree and the source buffer windows there is a high chance of errors due to the window ids not being updated and validated. 2. Not all InspectTree windows were closed when the source buffer was closed. Solution: 1. Update InspectTree window id on `CursorMoved` event and validate source buffer window id before trying to navigate to it. 2. Close all InspectTree windows
* fix(treesitter): escape "\" in :InspectTree #28613Riley Bruins2024-05-03
| | | Some parsers for, e.g., LaTeX or PHP have anonymous nodes like `"\"` or `"\text"` that behave wonkily (especially the first example) in the `InspectTree` window, so this PR escapes them by adding another backslash in front of them
* docs: improve/add documentation of Lua typesLewis Russell2024-03-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added `@inlinedoc` so single use Lua types can be inlined into the functions docs. E.g. ```lua --- @class myopts --- @inlinedoc --- --- Documentation for some field --- @field somefield integer --- @param opts myOpts function foo(opts) end ``` Will be rendered as ``` foo(opts) Parameters: - {opts} (table) Object with the fields: - somefield (integer) Documentation for some field ``` - Marked many classes with with `@nodoc` or `(private)`. We can eventually introduce these when we want to.
* feat(treesitter): add folding for `InspectTree` (#27518)再生花2024-02-22
| | | | As the InspectTree buffer is now a valid tree-sitter query tree, we can use the bundled fold queries to have folding for the tree.
* feat(treesitter): show root nodes in :InspectTree (#26944)altermo2024-02-06
| | | | Co-authored-by: altermo <> Co-authored-by: Jongwook Choi <wookayin@gmail.com>
* feat(treesitter): use 0-based indexing to show ranges in `:InspectTree`Jongwook Choi2024-02-05
| | | | | | | | | | | | | | | | | | Problem: - `:InspectTree` was showing node ranges in 1-based indexing, i.e., in vim cursor position (lnum, col). However, treesitter API adopts 0-based indexing to represent ranges (Range4). This can often be confusing for developers and plugin authors when debugging code written with treesiter APIs. Solution: - Change to 0-based indexing from 1-based indexing to show node ranges in `:InspectTree`. - Note: To make things not complicated, we do not provide an option or keymap to configure which indexing mode to use.
* fix(treesitter): inspect-tree remember opts on buf changealtermo2024-02-04
|
* docs: enforce "treesitter" spelling #27110Jongwook Choi2024-01-28
| | | It's the "tree-sitter" project, but "treesitter" in our code and docs.
* docs(treesitter): improve 'no parser' error message for InspectTreeJongwook Choi2024-01-08
| | | | | | | | | | | | | Improve error messages for `:InspectTree`, when no parsers are available for the current buffer and filetype. We can show more informative and helpful error message for users (e.g., which lang was searched for): ``` ... No parser available for the given buffer: +... no parser for 'custom_ft' language, see :help treesitter-parsers ``` Also improve the relevant docs for *treesitter-parsers*.
* fix: Remove nested for_each_tree in TSTreeView (#26328)Pham Huy Hoang2023-11-30
| | | | | | | | | | | Problem: `LanguageTree:for_each_tree` calls itself for child nodes, so when we calls `for_each_tree` inside `for_each_tree`, this quickly leads to exponential tree calls. Solution: Use `pairs(child:trees())` directly in this case, as we don't need the extra callback for each children, this is already handled from the outer `for_each_tree` call
* fix(treesitter): fix parens stacking in inspector display (#26304)Gregory Anders2023-11-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When first opened, the tree-sitter inspector traverses all of the nodes in the buffer to calculate an array of nodes. This traversal is done only once, and _all_ nodes (both named and anonymous) are included. Toggling anonymous nodes in the inspector only changes how the tree is drawn in the buffer, but does not affect the underlying data structure at all. When the buffer is traversed and the list of nodes is calculated, we don't know whether or not anonymous nodes will be displayed in the inspector or not. Thus, we cannot determine during traversal where to put closing parentheses. Instead, this must be done when drawing. When we draw, the tree structure has been flatted into a single array, so we lose parent-child relationships that would otherwise make determining the number of closing parentheses straightforward. However, we can instead rely on the fact that a delta between the depth of a node and the depth of the successive node _must_ mean that more closing parentheses are required: (foo (bar) (baz) ↑ │ └ (bar) and (baz) have different depths, so (bar) must have an extra closing parenthesis This does not depend on whether or not anonymous nodes are displayed and so works in both cases.
* fix(treesitter): adjust indentation in inspector highlights (#26302)Gregory Anders2023-11-29
|
* docs: document TSNode:byte_length() (#26287)Gregory Anders2023-11-29
| | | | Also update the type annotation of TSNode:id(), which returns a string, not an integer.
* fix(treesitter): make InspectTree correctly handle nested injections (#26085)Pham Huy Hoang2023-11-29
| | | | | | | Problem: Only injections under the top level tree are found. Solution: Iterate through all trees to find injections. When two injections are contained within the same node in the parent tree, prefer the injection with the larger byte length.
* fix(treesitter): use proper query syntax for inspector (#26274)Gregory Anders2023-11-29
|
* fix(treesitter): set cursor position when opening inspectorMaria José Solano2023-10-19
|
* fix(treesitter): check that buf is loaded in autocommands (#25679)Maria José Solano2023-10-17
|
* docs: fix type warningsMaria José Solano2023-09-23
|
* docs: misc #24561Justin M. Keyes2023-09-20
| | | | fix #24699 fix #25253
* feat(treesitter): add lang parameter to the query editor (#25181)Maria José Solano2023-09-16
|
* refactor(treesitter): rename "preview" => "edit" #25161Maria José Solano2023-09-15
| | | | | | "Edit" more closely describes the generic application than "Preview", though the buffer contents don't (yet) map to an actual file on disk. https://github.com/neovim/neovim/pull/24703#discussion_r1321719133
* fix(treesitter): fixup for InspectTreeLewis Russell2023-09-12
| | | | Fixes #25120
* fix(treesitter): remove more double recursionLewis Russell2023-09-12
| | | | Do not call `for_each_child` in functions that are already recursive.
* fix(treesitter): validate window before updating preview highlightsMaria José Solano2023-08-27
|
* feat(treesitter): add a query editor (#24703)Maria José Solano2023-08-25
|
* feat(treesitter)!: incremental injection parsingLewis Russell2023-08-12
| | | | | | | | | | | | | | | | | | | | | Problem: Treesitter highlighting is slow for large files with lots of injections. Solution: Only parse injections we are going to render during a redraw cycle. --- - `LanguageTree:parse()` will no longer parse injections by default and now requires an explicit range argument to be passed. - `TSHighlighter` now parses injections incrementally during on_win callbacks for the line range being rendered. - Plugins which require certain injections to be parsed must run `parser:parse({ start_row, end_row })` before using the tree.
* fix(treesitter): escape quotes in :InspectTree view #24582ObserverOfTime2023-08-07
| | | | Problem: Anonymous nodes containing double quotes break the highlighting. Solution: Escape double quotes in anonymous nodes.
* docs(lua): more improvements (#24387)Lewis Russell2023-07-18
| | | | | | | | | | | | | | | | | * docs(lua): teach lua2dox how to table * docs(lua): teach gen_vimdoc.py about local functions No more need to mark local functions with @private * docs(lua): mention @nodoc and @meta in dev-lua-doc * fixup! Co-authored-by: Justin M. Keyes <justinkz@gmail.com> --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* refactor!: rename "playground" => "dev" #23919Justin M. Keyes2023-06-06
Problem: "playground" is new jargon that overlaps with existing concepts: "dev" (`:help dev`) and "view" (also "scratch" `:help scratch-buffer`) . Solution: We should consistently use "dev" as the namespace for where "developer tools" live. For purposes of a "throwaway sandbox object", we can use the name "view". - Rename `TSPlayground` => `TSView` - Rename `playground.lua` => `dev.lua`