aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/highlighter.lua
Commit message (Collapse)AuthorAge
* perf(treesitter): do not scan past given line for predicate matchL Lllvvuu2023-09-16
| | | | | | | | | | | | | | | 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
* fix(decorations): better approximation of botline #24794Jaehwang Jung2023-09-11
| | | | | | | | | | | | | | | | 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>
* 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.
* 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>
* fix(treesitter): use vim.highlight.priorities instead of hardcoded 100 (#24052)Santos Gallegos2023-06-18
| | | | | Problem: Treesitter highlighting base priority cannot be customized. Solution: Use `vim.highlight.priorities.treesitter` instead of hard-coded value.
* fix(treesitter): redraw added/removed injections properly (#23287)Lewis Russell2023-04-30
| | | | | | 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
* refactor: rename local API alias from a to apiLewis Russell2023-04-05
| | | | | | | | 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.
* fix(treesitter): use capture metadata range if exists danilax9992023-04-04
| | | use `treesitter.get_range` instead of inline expression
* feat(treesitter)!: deprecate top level indexes to modules (#22761)Lewis Russell2023-03-24
| | | | | | | | | | | | | | | | | 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()
* fix(treesitter): annotationsLewis Russell2023-03-23
| | | | | | - Begin using `@package` in place of `@private` for functions that are accessed internally but outside their defined class. - Rename Node -> TSP.Node
* docs: fix vim.treesitter tagsJustin M. Keyes2023-03-03
| | | | | | | | | 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.
* fix(treesitter): fix most diagnosticsLewis Russell2023-02-04
|
* fix(treesitter): really restore syntaxLewis Russell2023-01-17
| | | | | - also unset b:ts_highlight on stop() Fixes: #21836
* fix(ts): check buffer is loaded when restoring options (#21419)Lewis Russell2022-12-14
| | | | | | | fix(treesitter): check buffer is loaded when restoring options Also restore spelloptions Fixes #21416
* fix(treesitter): properly restore `'syntax'` (#21358)Lewis Russell2022-12-14
|
* feat(spell): support nospell in treesitter queriesLewis Russell2022-11-12
|
* docs(treesitter): clean up and update treesitter.txt (#20142)Christian Clason2022-09-14
| | | | | * add type annotations to code * clean up and expand static documentation * consistent use of tags for static and generated docs
* fix(ts): do not clobber spelloptions (#20095)Lewis Russell2022-09-06
|
* feat(extmarks,ts,spell): full support for spellingThomas Vigouroux2022-09-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* feat(treesitter)!: use @foo.bar style highlight groupsbfredl2022-08-26
| | | | | | | | | | | | 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
* refactor(lua): replace vim.cmd use with API calls (#19283)Raphael2022-07-09
| | | Signed-off-by: Raphael <glephunter@gmail.com>
* refactor(lua): reformat with stylua 0.14.0 (#19264)Christian Clason2022-07-07
| | | | * reformat Lua runtime to make lint CI pass * reduce max line length to 100
* fix(treesitter): new iter if foldedkevinhwang912022-06-16
|
* chore: format runtime with styluaChristian Clason2022-05-09
|
* feat(treesitter): add more default groups to highlight map (#17835)Gregory Anders2022-03-30
| | | This covers some default groups listed in :h group-name.
* feat(ui): allow conceal to be defined in decorationsbfredl2022-03-20
| | | | | | Unlike syntax conceal, change highlight of concealed char Can be used in tree-sitter using "conceal" metadata.
* feat(tree-sitter): allow Atom-style capture fallbacks (#14196)Stephan Seitz2022-02-16
| | | | | | | | | 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
* docs: make Lua docstrings consistent #15255Gregory Anders2021-08-22
| | | | | | | | | | | | 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.
* perf(treesitter): avoid string lookup of highlight name in hot loopBjörn Linse2021-08-19
| | | | | These numbers are guaranteed to be stable even if you do "highlight clear" (all attributes disappear, but not the id to name mapping itself)
* chore: remove reference to nvim-treesitter in commentStephan Seitz2021-08-06
|
* fix(treesitter): do not map hl_group when no mapping is setStephan Seitz2021-08-06
| | | | | | | | | | | 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.
* feat(treesitter): allow to set highlight priority for queriesStephan Seitz2021-07-22
|
* docs: Treesitter (#13260)TJ DeVries2021-05-01
| | | | | | | | | * doc & fixes: Generate treesitter docs * fixup to treesitter-core * docs(treesitter): fix docs for most functions Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
* Merge pull request #14218 from steelsojka/bugfix/check-queries-existThomas Vigouroux2021-04-02
|\ | | | | fix(treesitter): check highlight queries exist
| * fix(treesitter): check highlight queries existSteven Sojka2021-03-26
| |
* | ts: Add per-language highlight linksTJ DeVries2021-03-31
|/
* treesitter: propagate on_detach event properlyBjörn Linse2021-02-10
|
* feat(luahl): add priority mechanismThomas Vigouroux2020-11-25
| | | | | Base priority is 0x1000, in order to stay kinda backward compatible. Also set tree-sitter default highlight to 100 (middle-ish value)
* feat(treesitter): add language treeSteven Sojka2020-11-23
| | | | | | | | | | | | | 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>
* treesitter: add node:id()Björn Linse2020-11-01
|
* treesitter: allow multiple highlighters per bufferThomas Vigouroux2020-10-12
|
* treesitter: allow custom parser for highlighterThomas Vigouroux2020-10-12
| | | | | | | | | | | 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>
* treesitter: runtime queriesThomas Vigouroux2020-10-11
| | | | | | | | | | | | | 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>
* api: multiple decoration providers at onceBjörn Linse2020-10-10
|
* luahl: global the luahlBjörn Linse2020-09-13
|
* fix: use luahl in treesitterThomas Vigouroux2020-09-13
|
* wip trying to fix the highlighterThomas Vigouroux2020-09-09
|
* treesitter: use new on_bytes interfaceBjörn Linse2020-09-09
| | | | | | | | | | 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.
* treesitter: revert wrong optimization in highlightsThomas Vigouroux2020-09-09
|
* apply bfredl suggestionkiyan422020-09-06
|