| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem
---
If a highlighter query returns a significant number of predicate
non-matches, the highlighter will scan well past the end of the window.
Solution
---
In the iterator returned from `iter_captures`, accept an optional
parameter `end_line`. If no parameter provided, the behavior is
unchanged, hence this is a non-invasive tweak.
Fixes: #25113 nvim-treesitter/nvim-treesitter#5057
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
* The guessed botline might be smaller than the actual botline e.g. when
there are folds and the user is typing in insert mode. This may result
in incorrect treesitter highlights for injections.
* botline can be larger than the last line number of the buffer, which
results in errors when placing extmarks.
Solution:
* Take a more conservative approximation. I am not sure if it is
sufficient to guarantee correctness, but it seems to be good enough
for the case mentioned above.
* Clamp it to the last line number.
Co-authored-by: Lewis Russell <me@lewisr.dev>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
| |
Problem: Treesitter highlighting base priority cannot be customized.
Solution: Use `vim.highlight.priorities.treesitter` instead of hard-coded value.
|
|
|
|
|
|
| |
When injections are added or removed make sure to:
- invoke 'changedtree' callbacks for when new trees are added.
- invoke 'changedtree' callbacks for when trees are invalidated
- redraw regions when languagetree children are removed
|
|
|
|
|
|
|
|
| |
Problem:
Codebase inconsistently binds vim.api onto a or api.
Solution:
Use api everywhere. a as an identifier is too short to have at the
module level.
|
|
|
| |
use `treesitter.get_range` instead of inline expression
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following top level Treesitter functions have been moved:
- vim.treesitter.inspect_language() -> vim.treesitter.language.inspect()
- vim.treesitter.get_query_files() -> vim.treesitter.query.get_files()
- vim.treesitter.set_query() -> vim.treesitter.query.set()
- vim.treesitter.query.set_query() -> vim.treesitter.query.set()
- vim.treesitter.get_query() -> vim.treesitter.query.get()
- vim.treesitter.query.get_query() -> vim.treesitter.query.get()
- vim.treesitter.parse_query() -> vim.treesitter.query.parse()
- vim.treesitter.query.parse_query() -> vim.treesitter.query.parse()
- vim.treesitter.add_predicate() -> vim.treesitter.query.add_predicate()
- vim.treesitter.add_directive() -> vim.treesitter.query.add_directive()
- vim.treesitter.list_predicates() -> vim.treesitter.query.list_predicates()
- vim.treesitter.list_directives() -> vim.treesitter.query.list_directives()
- vim.treesitter.query.get_range() -> vim.treesitter.get_range()
- vim.treesitter.query.get_node_text() -> vim.treesitter.get_node_text()
|
|
|
|
|
|
| |
- Begin using `@package` in place of `@private` for functions
that are accessed internally but outside their defined class.
- Rename Node -> TSP.Node
|
|
|
|
|
|
|
|
|
| |
Problem:
Help tags like vim.treesitter.language.add() are confusing because
`vim.treesitter.language` is (thankfully) not a user-facing module.
Solution:
Ignore the "fstem" when generating "treesitter" tags.
|
| |
|
|
|
|
|
| |
- also unset b:ts_highlight on stop()
Fixes: #21836
|
|
|
|
|
|
|
| |
fix(treesitter): check buffer is loaded when restoring options
Also restore spelloptions
Fixes #21416
|
| |
|
| |
|
|
|
|
|
| |
* add type annotations to code
* clean up and expand static documentation
* consistent use of tags for static and generated docs
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Added 'spell' option to extmarks:
Extmarks with this set will have the region spellchecked.
- Added 'noplainbuffer' option to 'spelloptions':
This is used to tell Neovim not to spellcheck the buffer. The old
behaviour was to spell check the whole buffer unless :syntax was set.
- Added spelling support to the treesitter highlighter:
@spell captures in highlights.scm are used to define regions which
should be spell checked.
- Added support for navigating spell errors for extmarks:
Works for both ephemeral and static extmarks
- Added '_on_spell_nav' callback for decoration providers:
Since ephemeral callbacks are only drawn for the visible screen,
providers must implement this callback to instruct Neovim which
regions in the buffer need can be spell checked.
The callback takes a start position and an end position.
Note: this callback is subject to change hence the _ prefix.
- Added spell captures for built-in support languages
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Co-authored-by: Björn Linse <bjorn.linse@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This removes the support for defining links via
vim.treesitter.highlighter.hl_map (never documented, but plugins did
anyway), or the uppercase-only `@FooGroup.Bar` to `FooGroup` rule.
The fallback is now strictly `@foo.bar.lang` to `@foo.bar` to `@foo`,
and casing is irrelevant (as it already was outside of treesitter)
For compatibility, define default links to builting syntax groups
as defined by pre-existing color schemes
|
|
|
| |
Signed-off-by: Raphael <glephunter@gmail.com>
|
|
|
|
| |
* reformat Lua runtime to make lint CI pass
* reduce max line length to 100
|
| |
|
| |
|
|
|
| |
This covers some default groups listed in :h group-name.
|
|
|
|
|
|
| |
Unlike syntax conceal, change highlight of concealed char
Can be used in tree-sitter using "conceal" metadata.
|
|
|
|
|
|
|
|
|
| |
This allows falling back to `@definition` when we have no mapping
`@definition.fancy-specialization`.
This behavior is described in tree-sitter's documentation
(https://tree-sitter.github.io/tree-sitter/syntax-highlighting#theme).
Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/738
|
|
|
|
|
|
|
|
|
|
|
|
| |
The official developer documentation in in :h dev-lua-doc specifies to
use "--@" for special/magic tokens. However, this format is not
consistent with EmmyLua notation (used by some Lua language servers) nor
with the C version of the magic docstring tokens which use three comment
characters.
Further, the code base is currently split between usage of "--@",
"---@", and "--- @". In an effort to remain consistent, change all Lua
magic tokens to use "---@" and update the developer documentation
accordingly.
|
|
|
|
|
| |
These numbers are guaranteed to be stable even if you do "highlight
clear" (all attributes disappear, but not the id to name mapping itself)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This changes the behavior of the hl_cache to the old one.
- when the capture exists as a hlgroup -> use it
- when hl_map contains a mapping -> use it
- else do nothing (before: map capture to non-existing capture)
Before also captures `@foo.bar` would intend to use the hlgroup `foo.bar`
which results in a confusing error since hlgroups can't contain dots.
|
| |
|
|
|
|
|
|
|
|
|
| |
* doc & fixes: Generate treesitter docs
* fixup to treesitter-core
* docs(treesitter): fix docs for most functions
Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
|
|\
| |
| | |
fix(treesitter): check highlight queries exist
|
| | |
|
|/ |
|
| |
|
|
|
|
|
| |
Base priority is 0x1000, in order to stay kinda backward compatible.
Also set tree-sitter default highlight to 100 (middle-ish value)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Implement the LanguageTree structure to enable language injection.
This is done be removing the old Parser metatable and replacing by the
new structure, with the same API (almost).
Some noticeable differences :
- `parser:parse()` now returns a table of trees
- There is no incremental parsing for child (injected) languages
Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Also allow to get parser ranges.
This will be useful for language injection, allowing us to tweak the
parser's ranges on the fly.
Update runtime/lua/vim/treesitter.lua
Co-authored-by: Paul Burlumi <paul@burlumi.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Runtime queries just work like ftplugins, that is:
- Queries in the `after` directory are sourced _after_ the "base" query
- Otherwise, the last define query takes precedence.
Queries can be found in the `queries` directory.
Update runtime/lua/vim/treesitter/query.lua
Co-authored-by: Paul Burlumi <paul@burlumi.com>
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This will significantly reduce the parsing work
needed e.g. when rehighlighting after every keypress
in insert mode.
Also add safety check for tree-sitter trying to read
past the end of a line. This can happen after we sent
an incorrect buffer update.
|
| |
|
| |
|