summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/treesitter
AgeCommit message (Collapse)AuthorFiles
2026-04-22feat(treesitter): expand selection to sibling node #38938altermo1
Problem: Can't expand treesitter-incremental-selection to the next and previous sibling nodes. Solution: Pressing `]N` in visual mode will expand the selection to the next sibling node, and `[N` will do the same with the previous node.
2026-04-16fix(treesitter): TSNode:id() with NUL byte causes unreliable select() #39134altermo1
Problem: `TSNode:id()` returns the underlying c pointer as a string, which may include NUL bytes. In PUC Lua, `('%s'):format('\0a\0')` returns `''` and not `'\0a\0'` (i.e. treats the string as a c-string (which terminates at the NUL byte)). This resulted in two different nodes being able to have the same id. Solution: Use concatenation `..` instead of `string.format()`.
2026-04-08feat(api): rename buffer to buf #35330Jordan3
Problem: `:help dev-name-common` states that "buf" should be used instead of "buffer" but there are cases where buffer is mentioned in the lua API. Solution: - Rename occurrences of "buffer" to "buf" for consistency with the documentation. - Support (but deprecate) "buffer" for backwards compatibility. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-04-02fix(treesitter): select reset to "v" visualmode()altermo1
2026-03-31fix(treesitter): select with node ending with unicode char (#38557)altermo1
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2026-03-30docs: fix syntax errors in examples #38606skewb1k1
2026-03-25fix(treesitter): ignore stale fold refresh callbacksLewis Russell1
Problem: The fold refresh path for foldminlines/foldnestmax creates a new FoldInfo and starts an async parse. If FileType or BufUnload re-enters before that callback returns, foldinfos[bufnr] can be cleared or replaced. The callback then indexes a stale slot and raises an "attempt to index a nil value" error. Solution: Capture the FoldInfo created for the refresh and carry that object through the async callback. Before calling foldupdate(), verify that the buffer still points at the same FoldInfo generation; otherwise ignore the stale callback. AI-assisted: Codex Fixes #38461
2026-03-25refactor(treesitter): use same visual-select as lsp #38475altermo1
Problem treesitter select over-complicates visual selection. Solution make it use same visual selection logic as lsp.
2026-03-23refactor(treesitter)!: remove "all" option of Query:iter_matches #33070Gregory Anders1
This option was introduced to help with transitioning to the new behavior during the 0.11 release cycle with the intention of removing in 0.12.
2026-03-20docs: miscJustin M. Keyes1
2026-03-14refactor(treesitter): move range related functionsaltermo2
2026-03-13refactor(treesitter)!: get_parser return nil on error #37276nikolightsaber4
2026-03-13refactor: rename _ensure_integer => _assert_integerJustin M. Keyes1
2026-03-12refactor: integer functions, optimize asserts #34112Lewis Russell2
refactor(lua): add integer coercion helpers Add vim._tointeger() and vim._ensure_integer(), including optional base support, and switch integer-only tonumber()/assert call sites in the Lua runtime to use them. This also cleans up related integer parsing in LSP, health, loader, URI, tohtml, and Treesitter code. supported by AI
2026-03-11docs: api, messages, lsp, trustJustin M. Keyes1
gen_vimdoc.lua: In prepare for the upcoming release, comment-out the "Experimental" warning for prerelease features.
2026-03-08feat(treesitter): incremental selectionaltermo1
Co-authored-by: György Andorka <gyorgy.andorka@protonmail.com>
2026-03-07refactor(lua): adapt to Stylua 2.4.0Christian Clason1
2026-03-07fix(treesitter): escape hyphen in lua patternStefan VanBuren1
Ref: https://github.com/neovim/neovim/pull/38140#discussion_r2897235978
2026-03-04fix(treesitter): normalize language aliasesStefan VanBuren1
Hyphenated language names are silently dropped when used as injections (see #38132). This combines the normalization of language aliases into `resolve_lang`, and also adds the normalization of hyphens to underscores, which allows for handling of injected language tags with hyphens in their names. Fixes #38132.
2026-02-24fix(treesitter): InspectTree only show the largest injection #37906phanium1
Problem: :InspectTree don't show luadoc injection lua file. Since luadoc share the same "root" with comment in their common primary (lua) tree. Current logic simply show the largest (comment injection) and ignore all smaller one (luadoc injection). Solution: Handle different lang injections separately. Then sort them by byte_length to ensure the draw tree consistent.
2026-02-19fix(treesitter): :InspectTree wrong title for non-relative path #37965zeertzjq1
Problem: :InspectTree sets wrong title for file with non-relative path. Solution: Use full path if relpath() returns nil.
2026-02-12fix(treesitter): highlight group for EditQuery captures #36265Michele Campeotto2
fix(treesitter): more distinctive highlight for EditQuery captures Problem: EditQuery shows captures in the source buffer using the Title highlight group, which could be too similar to Normal. Solution: Use a virtual text diagnostic highlight group: they are displayed in a similar manner to the query captures so we can assume that the color scheme should have appropriate styling applied to make them visible.
2026-01-28refactor(lua): use vim.fs instead of fnamemodifyYochem van Rosmalen3
Although powerful -- especially with chained modifiers --, the readability (and therefore maintainability) of `fnamemodify()` and its modifiers is often worse than a function name, giving less context and having to rely on `:h filename-modifiers`. However, it is used plenty in the Lua stdlib: - 16x for the basename: `fnamemodify(path, ':t')` - 7x for the parents: `fnamemodify(path, ':h')` - 7x for the stem (filename w/o extension): `fnamemodify(path, ':r')` - 6x for the absolute path: `fnamemodify(path, ':p')` - 2x for the suffix: `fnamemodify(path, ':e')` - 2x relative to the home directory: `fnamemodify(path, ':~')` - 1x relative to the cwd: `fnamemodify(path, ':.')` The `fs` module in the stdlib provides a cleaner interface for most of these path operations: `vim.fs.basename` instead of `':t'`, `vim.fs.dirname` instead of `':h'`, `vim.fs.abspath` instead of `':p'`. This commit refactors the runtime to use these instead of fnamemodify. Not all fnamemodify calls are removed; some have intrinsic differences in behavior with the `vim.fs` replacement or do not yet have a replacement in the Lua module, i.e. `:~`, `:.`, `:e` and `:r`.
2026-01-15fix(treesitter): fix spell navigation on first line (#37361)ashab-k1
Problem: Spell navigation skips words on the first line because _on_spell_nav passes an empty range (0,0) to the highlighter. Solution: Use math.max(erow, srow + 1) to ensure a valid search window. Signed-off-by: ashab-k <ashabkhan2000@gmail.com>
2025-12-30fix(treesitter): use metadata in :EditQuery captures #37116Peter Cardenas1
Problem: When the `#offset!` directive is used with `:EditQuery`, the query does not take the offset into consideration when creating the extmark to preview the capture. Solution: Use the capture metadata to modify the node range before creating the extmark.
2025-12-21fix(treesitter.foldexpr): duplicate callbacks #37048Jaehwang Jung1
Problem: VimEnter clears foldinfo, so register_cbs is called again after VimEnter. The duplicate parser callbacks break incremental fold computation. Solution: Check if the callbacks are already registered.
2025-12-20feat(health): show available queries for `treesitter` (#37005)Harsh Kapse1
Problem: Outdated query files in `runtimepath` can trigger errors which are hard to diagnose. Solution: Add section to `:check treesitter` that lists all query files in `runtimepath`, sorted by language and query type. Files are listed in `runtimepath` order so that the first of multiple entry is typically the one that is used. Note: Unlike the `nvim-treesitter` health check, this does not try to parse the queries so will not flag incompatible ones (which would be much more expensive).
2025-12-15Revert "refactor(treesitter): use scratch buffer for string parser" #36964Riley Bruins2
This reverts commit 2a7cb32959b4c616bd2c76ae1933f8e068e391ad.
2025-12-14fix(treesitter): no injection highlighting on last line #36951Jaehwang Jung1
Problem: If the last visible line in a window is not fully displayed, this line may not get injection highlighting. This happens because line('w$') actually means the last *completely displayed* line. Solution: Use line('w$') + 1 for the botline. This reverts 4244a967746a1476831d990153d4de85450e54d4 "test: fix failing lsp/utils_spec #36609", which changed the test based on the wrong behavior.
2025-12-02fix(treesitter): missing `nowait` for :InspectTree keymaps #36804Chris Grieser1
2025-11-18perf(treesitter): parse multiple ranges in languagetree, eliminate ↵Riley Bruins2
flickering #36503 **Problem:** Whenever `LanguageTree:parse()` is called, injection trees from previously parsed ranges are dropped. **Solution:** Allow the function to accept a list of ranges, so it can return injection trees for all the given ranges. Co-authored-by: Jaehwang Jung <tomtomjhj@gmail.com>
2025-11-06fix(treesitter): reset next_col when performing intermediate highlightsRiley Bruins1
The iterator is meant to be fully reset in this code path, but only the `next_row` state was being reset. This would only cause highlight artifacts for very brief periods of time, though.
2025-10-24fix(outline): use 2-space indent instead of 1-spaceJustin M. Keyes1
2 spaces is more visually distinct at very little cost.
2025-10-02refactor(treesitter): use scratch buffer for string parser #35988Riley Bruins2
This commit changes `languagetree.lua` so that it creates a scratch buffer under the hood when dealing with string parsers. This will make it much easier to just use extmarks whenever we need to track injection trees in `languagetree.lua`. This also allows us to remove the `treesitter.c` code for parsing a string directly. Note that the string parser's scratch buffer has `set noeol nofixeol` so that the parsed source exactly matches the passed in string.
2025-09-26fix(highlight): ensure extmark range is within buffer bounds #35928skewb1k1
Adds an additional check for the case when end_col = 0, addressing https://github.com/neovim/neovim/issues/35814#issuecomment-3340709532. Validation is now localized to the highlighter without affecting the C API.
2025-09-09fix(treesitter): use subpriorities for tree orderingbfredl1
This partially reverts 0b8a72b73934d33a05e20c255298e88cd921df32, that is unreverts 15e77a56b711102fdc123e15b3f37d49bc0b1df1 "priority" is an internal neovim concept which does not occur in shared queries. Ideally a single priority space should eventually be enough for our needs. But as we don't want to poke at the usages of priorities right now in the wider ecosystem, introduce the "subpriorities" so that treesitter code can distinguish highlights of the same priorities with different tree nesting depth. This mainly affects `injection.combined` as parent-tree nodes might appear in the middle of child-tree nodes which otherwise is not possible.
2025-09-09perf(highlight): allow decoration providers to skip ranges without databfredl1
Continuing the work of #31400 That PR allowed the provider to be invoked multiple times per line. We want only to do that when there actually is more data later on the line. Additionally, we want to skip over lines which contain no new highlight items. The TS query cursor already tells us what the next position with more data is, so there is no need to reinvoke the range callback before that. NB: this removes the double buffering introduced in #32619 which is funtamentally incompatible with this (nvim core is supposed to keep track of long ranges by itself, without requiring a callback reinvoke blitz). Need to adjust the priorities some other way to fix the same issue.
2025-09-01docs(treesitter): fix language-injection url #35592Yochem van Rosmalen1
2025-08-28perf: add on_range in treesitter highlightingvanaigr3
2025-08-28refactor(lua): consistent use of local aliasesChristian Clason3
2025-08-19fix(treesitter): run FileType autocmds in the context of `<abuf>`Sean Dewar1
Problem: many FileType autocommands assume curbuf is the same as the target buffer; this can cause &syntax to be restored for the wrong buffer in some cases when TSHighlighter:destroy is called. Solution: run nvim_exec_autocmds in the context of the target buffer via nvim_buf_call.
2025-08-14fix(checkhealth): wrong ABI version for treesitter parsers #35327Jalil David Salamé Messina1
Don't print ABI version of duplicated parsers that are later in the runtime path (see [#35326]). Change the sorting from `name > path` to `name > rtpath_index`, this ensures the first (loaded) parser is first in the list and any subsequent parsers can be considered "not loaded". This is fuzzy at best since `vim.treesitter.language.add` can take a path to a parser and change the load order. The correct solution is for `vim.treesitter.language.inspect` to return the parser path so we can compare against it and/or for it to also be able to take a path to a parser so we can inspect it without loading it first.
2025-08-12fix(treesitter): set local values of window optionsJaehwang Jung1
2025-07-28docs: lsp, ui events, dev guidance, osc7Justin M. Keyes1
fix #34981
2025-07-19fix(treesitter): ":EditQuery [lang]" with injected languages #34914Peter Cardenas3
Problem: `:EditQuery` command accepts a language argument, but it doesn't highlight properly for injected languages. Solution: - Fully parse with the root language and then filter the query on the child trees that are of the language requested. - Also support completion (`EditQuery <tab>`).
2025-07-08docs: tag of `:EditQuery` #34844Phạm Bình An1
Problem: - Running `:h :EditQuery` throws error `E149: Sorry, no help for :EditQuery` - vim_diff.txt miss an entry for `:EditQuery` Solution: - Make tag `[:EditQuery]()` right-aligned, similar to command `:Open` - Update vim_diff.txt
2025-07-08fix(health): floating window closes when opening TOC (gO) #34794glepnir1
Problem: Health check floating window gets closed when pressing 'gO' to show TOC because LSP floating preview system auto-closes on BufEnter events triggered by :lopen. Solution: Temporarily disable BufEnter event for the current window during TOC operations and adjust window layout to prevent overlap.
2025-07-06fix(treesitter): inconsistent highlight of multiline combined injection #32619Artem1
Problem: Combined injections not entirely highlighted. Solution: Reapply layer highlights on each line.
2025-07-04fix(diagnostic): fix flaky errorLewis Russell1
2025-07-02fix(treesitter): ensure TSLuaTree is always immutableRodrigodd2
Problem: The previous fix in #34314 relies on copying the tree in `tree_root` to ensure the `TSNode`'s tree cannot be mutated. But that causes the problem where two calls to `tree_root` return nodes from different copies of a tree, which do not compare as equal. This has broken at least one plugin. Solution: Make all `TSTree`s on the Lua side always immutable, avoiding the need to copy the tree in `tree_root`, and make the only mutation point, `tree_edit`, copy the tree instead.