Pham Huy Hoang
753f8bcaab
fix: make InspectTree handle nested injection
...
fixup: Use `TSNode:byte_length` instead
(cherry picked from commit 757bcdda30
)
2023-11-29 14:17:14 +00:00
Christian Clason
c5edfb16f9
fix(treesitter): foldexpr tweaks
...
(cherry-picked from 26cc946226
)
Co-authored-by: rafikdraoui
2023-10-14 17:07:36 +02:00
L Lllvvuu
f0898d438e
[Backport release-0.9] fix(treesitter): language.add - only register parser if it exists
...
Backport of #25151 .
Fixes : #24531
2023-09-15 10:10:37 +02:00
Lewis Russell
f0b1e46f91
fix(treesitter): fixup for InspectTree
...
Fixes #25120
(cherry picked from commit 040cba1faa
)
2023-09-12 14:56:07 +00:00
Lewis Russell
5f8676c268
fix(treesitter): remove more double recursion
...
Do not call `for_each_child` in functions that are already recursive.
(cherry picked from commit e76ae3d232
)
2023-09-12 11:23:31 +00:00
L Lllvvuu
64160bac5b
[Backport release-0.9] fix(languagetree): remove double recursion in LanguageTree:parse
...
`LanguageTree:parse` is recursive, and calls
`LanguageTree:for_each_child`, which is also recursive.
That means that, starting from the third level (child of child of root),
nodes will be parsed twice.
Which then means that if the tree is N layers deep, there will be ~2^N
parses even if the branching factor is 1.
Fixes : #25104
2023-09-12 00:22:30 -07:00
Lewis Russell
ac2dff64a5
fix(treesitter): make sure injections don't return empty ranges ( #24595 )
...
When an injection has not set include children, make sure not to add
the injection if no ranges are determined.
This could happen when there is an injection with a child that has the
same range as itself. e.g. consider this Makefile snippet
```make
foo:
$(VAR)
```
Line 2 has an injection for bash and a make variable reference. If
include-children isn't set (default), then there is no range on line 2
to inject since the variable reference needs to be excluded.
This caused the language tree to return an empty range, which the parser
now interprets to mean the full buffer. This caused makefiles to have
completely broken highlighting.
2023-08-10 18:08:54 +02:00
Christian Clason
c8d6d14f71
[Backport release-0.9] fix(treesitter): allow foldexpr without highlights ( #23673 )
...
fix(treesitter): allow foldexpr without highlights (#23672 )
Ref nvim-treesitter/nvim-treesitter#4748
Co-authored-by: Lewis Russell <lewis6991@gmail.com >
2023-05-21 11:36:18 +02:00
github-actions[bot]
fe261706a2
[Backport release-0.9] perf(treesitter): insert/remove items efficiently ( #23504 )
...
perf(treesitter): insert/remove items efficiently
(cherry picked from commit c8fdc57b88
)
Co-authored-by: Lewis Russell <lewis6991@gmail.com >
2023-05-06 12:10:35 +02:00
github-actions[bot]
1b09bcef52
[Backport release-0.9] fix(treesitter): redraw added/removed injections properly ( #23408 )
...
fix(treesitter): redraw added/removed injections properly
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
(cherry picked from commit b68157834a
)
Co-authored-by: Lewis Russell <lewis6991@gmail.com >
2023-05-06 11:55:51 +02:00
github-actions[bot]
76dd0f81b0
[Backport release-0.9] fix(treesitter): do not calc folds on unloaded buffers ( #23440 )
...
fix(treesitter): do not calc folds on unloaded buffers
Fixes #23423
(cherry picked from commit 2e08228a16
)
Co-authored-by: Lewis Russell <lewis6991@gmail.com >
2023-05-02 11:23:45 +01:00
github-actions[bot]
ef7513c87f
[Backport release-0.9] fix(treesitter playground): fix the wrong range of a node displayed i… ( #23220 )
...
fix(treesitter playground): wrong range of a node displayed in playground
The call parameters order of the function `get_range_str` is flipped for the last two arguments compared to the declaration.
(cherry picked from commit 8613ba118c
)
Co-authored-by: William <50717946+BIKA-C@users.noreply.github.com >
2023-04-20 18:30:56 +02:00
github-actions[bot]
702621f058
[Backport release-0.9] fix(treesitter): Use the correct replacement args for #gsub! directive ( #23018 )
...
fix(treesitter): use the correct replacement args for #gsub! directive
(cherry picked from commit 07db1f7432
)
Co-authored-by: scottming <therealscottming@gmail.com >
2023-04-11 10:40:43 +02:00
Lewis Russell
e29bc03c04
fix(treesitter): do not track ranges of the root tree ( #22912 )
...
Fixes #22911
2023-04-06 15:16:44 +01:00
Lewis Russell
34ac75b329
refactor: rename local API alias from a to api
...
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.
2023-04-05 17:19:53 +01:00
dundargoc
e826d09c18
fix(windows): consistent normalization in fs.find
...
vim.fs.find(".luacheckrc")
```
c:\\projects\\neovim/.luacheckrc # before
c:/projects/neovim/.luacheckrc # after
```
Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com >
2023-04-04 23:37:46 +02:00
Lewis Russell
b1de4820b7
refactor(treesitter): move inspect_tree impl
2023-04-04 20:47:15 +01:00
dundargoc
a5c572bd44
docs: fix typos
...
Co-authored-by: Gregory Anders <greg@gpanders.com >
Co-authored-by: Raphael <glephunter@gmail.com >
Co-authored-by: C.D. MacEachern <craig.daniel.maceachern@gmail.com >
Co-authored-by: himanoa <matsunoappy@gmail.com >
2023-04-04 19:07:33 +02:00
Lewis Russell
090ade4af6
refactor(treesitter): delegate region calculation to treesitter ( #22576 )
2023-04-04 13:58:16 +02:00
danilax999
469e6bfc56
fix(treesitter): use capture metadata range if exists
...
use `treesitter.get_range` instead of inline expression
2023-04-04 12:26:21 +01:00
Sizhe Zhao
6a4ebf894f
fix(health): stop using deprecated ts.language.inspect_language() ( #22850 )
2023-04-01 15:47:20 +02:00
Christian Clason
d7f7450017
refactor(treesitter)!: rename help parser to vimdoc
2023-04-01 15:07:16 +02:00
Lewis Russell
61e54f2636
feat: add vim.treesitter.language.get_filetypes()
( #22643 )
2023-03-30 10:26:28 +01:00
Lewis Russell
ac7397f4a0
fix(treesitter): add missing deprecate
2023-03-24 16:31:30 +00:00
Lewis Russell
cbbf8bd666
feat(treesitter)!: deprecate top level indexes to modules ( #22761 )
...
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()
2023-03-24 14:43:14 +00:00
Lewis Russell
4e4203f71b
fix(treesitter): annotations
...
- Begin using `@package` in place of `@private` for functions
that are accessed internally but outside their defined class.
- Rename Node -> TSP.Node
2023-03-23 11:23:51 +00:00
Lewis Russell
35799a6629
fix(treesitter): foldexpr ( #22652 )
...
The ranges passed to foldinfo.remove_range were in the wrong order.
2023-03-13 10:44:43 +00:00
Lewis Russell
b55b8ddf81
Merge pull request #22613 from lewis6991/feat/tsqueryutil
2023-03-11 17:13:20 +00:00
Lewis Russell
58bbc2ea0b
refactor(treesitter): add Range type aliase for Range4|Range6
2023-03-11 16:38:18 +00:00
Lewis Russell
9d70fe062c
feat(treesitter)!: consolidate query util functions
...
- And address more type errors.
- Removed the `concat` option from `get_node_text` since it was applied
inconsistently and made typing awkward.
2023-03-10 16:35:06 +00:00
Lewis Russell
762a06c6bc
feat!(treesitter): do not return changes from LanguageTree:parse()
...
Never return the changes an only notify them using the `on_changedtree`
callback.
It is not guaranteed for a plugin that it'll be the first one to call
`tree:parse()` and thus get the changes.
Closes #19915
2023-03-10 16:16:49 +00:00
Lewis Russell
46b73bf22c
perf(treesitter): more efficient foldexpr
2023-03-10 11:51:33 +00:00
Lewis Russell
adfa9de8eb
fix(treesitter): do not error on empty filetype
...
Ignore instead
2023-03-10 10:41:19 +00:00
Lewis Russell
ae263aff95
refactor(treesitter): use byte ranges from treesitter ( #22589 )
2023-03-09 16:09:39 +00:00
Lewis Russell
b9f19d3e28
Revert "refactor(treesitter): delegate region calculation to treesitter" ( #22575 )
...
Revert "refactor(treesitter): delegate region calculation to treesitter (#22553 )"
This reverts commit 276b647fdb
.
2023-03-08 17:59:45 +00:00
Lewis Russell
276b647fdb
refactor(treesitter): delegate region calculation to treesitter ( #22553 )
2023-03-08 17:22:28 +00:00
Lewis Russell
ddd257f753
feat(treesitter): use upstream format for injection queries
2023-03-08 11:03:11 +00:00
Lewis Russell
f9a46391ab
refactor(treesitter): simplify some range functions
2023-03-06 10:57:14 +00:00
Justin M. Keyes
533d671271
docs: module-level docstrings (@defgroup) #22498
...
Problem:
gen_vimdoc.py / lua2dox.lua does not support @defgroup or \defgroup
except for "api-foo" modules.
Solution:
Modify `gen_vimdoc.py` to look for section names based on `helptag_fmt`.
TODO:
- Support @module ?
https://github.com/LuaLS/lua-language-server/wiki/Annotations#module
2023-03-05 15:15:29 -08:00
Jaehwang Jung
128b82103b
docs(treesitter): number → integer ( #22513 )
2023-03-04 13:04:05 +00:00
Justin M. Keyes
8414cfe7f4
docs: fix vim.treesitter tags
...
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.
2023-03-03 15:07:23 +01:00
Christian Clason
74c9c413e7
Merge pull request #22484 from gpanders/inspect-tree-fix-cursor
...
fix(treesitter): maintain cursor position when toggling anonymous nodes
2023-03-03 14:19:09 +01:00
Jaehwang Jung
f0a2ffab29
fix(treesitter): typos in _range.lua
...
fix(treesitter): typos _range.lua
2023-03-03 11:05:59 +00:00
Lewis Russell
6d4f481821
fix(treesitter): disallow empty filetypes
...
Fixes #22473
2023-03-03 09:44:02 +00:00
Gregory Anders
86ff239240
refactor(treesitter): use string.format to create lines
2023-03-02 14:15:18 -07:00
Lewis Russell
f64098a2df
fix(treesitter): fixup for health
2023-02-27 15:33:18 +00:00
Lewis Russell
5aa37e20e0
fix(treesitter): ipairs -> pairs
...
Fixes: https://github.com/nvim-treesitter/nvim-treesitter/issues/4349
2023-02-27 15:01:09 +00:00
Lewis Russell
da56f06037
fix(treesitter): remove virtual text from playground
...
Implement the range and lang annotations as comments instead
2023-02-27 10:49:19 +00:00
Lewis Russell
774e59f3f9
feat(treesitter): expand the API
2023-02-26 16:53:33 +00:00
Lewis Russell
c57af5d41c
feat(treesitter)!: remove silent option from language.add()
...
Simply use `pcall` if you want to silence an error.
2023-02-24 09:50:59 +00:00