| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
When given, only that range will be checked for validity rather than the
entire tree. This is used in the highlighter to save CPU cycles since we
only need to parse a certain region at a time anyway.
|
|
|
|
|
|
| |
This means that all work previously done by a `_parse()` iteration will
be kept in future iterations. This prevents it from running indefinitely
in some cases where the file is very large and there are 2+ injections.
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
When running an initial parse, parse() returns an empty table rather
than an actual range. In `languagetree.lua`, we manually check if
a parse was incremental to determine the changed parse region.
Solution:
- Always return a range (in the C side) from parse().
- Simplify the language tree code a bit.
- Logger no longer shows empty ranges on the initial parse.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This simplifies some logic in `languagetree.lua`, removing the need for
`_has_regions`, and removing side effects in `:included_regions()`.
Before:
- Edit is made which sets `_regions = nil`
- Upon the next call to `included_regions()` (usually right after we
marked `_regions` as `nil` due to an `_iter_regions()` call), if
`_regions` is nil, we repopulate the table (as long as the tree
actually has regions)
After:
- Edit is made which resets `_regions` if it exists
- `included_regions()` no longer needs to perform this logic itself, and
also no longer needs to read a `_has_regions` variable
|
| |
|
|
|
|
|
|
|
|
|
| |
Co-authored-by: Dustin S. <dstackmasta27@gmail.com>
Co-authored-by: Ferenc Fejes <fejes@inf.elte.hu>
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Co-authored-by: Yochem van Rosmalen <git@yochem.nl>
Co-authored-by: brianhuster <phambinhanctb2004@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
|
|
|
|
|
| |
Problem: Error occurs if delete buffer in the middle of parsing.
Solution: Check if buffer is valid in parsing.
|
|
|
|
|
|
|
|
|
|
| |
Problem: `TSHighlighter:destroy()` causes double-processing of the modeline
and failure of `b:undo_ftplugin`.
Solution: Disable modeline in `TSHighlighter:destroy()` by setting `modeline=false`
if executing `syntaxset` autocommands for the `FileType` event.
Co-authored-by: Daniel Petrovic <daniel.petrovic@ebcont.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
**Problem:** In the case where the user sets the treesitter foldexpr upon startup in
their `init.lua`, the fold info will be calculated before the parser has
been loaded in, meaning folds will be properly calculated until edits or
`:e`.
**Solution:** Refresh fold information upon `VimEnter` as a sanity check
to ensure that a parser really doesn't exist before always returning
`'0'` in the foldexpr.
|
|
|
|
|
|
|
|
|
|
|
|
| |
**Problem:** Currently, if users want to efficiently disable injections,
they have to delete the injection query files at their runtime path.
This is because we only check for existence of the files before running
the query over the entire buffer.
**Solution:** Check for existence of query files, *and* that those files
actually have captures. This will allow users to just comment out
existing queries (or better yet, just add their own injection query to
`~/.config/nvim` which contains only comments) to disable running the
query over the entire buffer (a potentially slow operation)
|
| |
|
|
|
|
| |
Uses an overload to properly show the different return type based on the
input parameter.
|
| |
|
|
|
|
|
| |
Breaking change: `ts_node_child_containing_descendant()` was removed
Breaking change: tree-sitter 0.25 (HEAD) required
|
| |
|
|
|
|
|
| |
Plugins may want to climb up the LanguageTree.
Also add missing type annotations for other methods.
|
| |
|
|
|
|
|
|
|
|
| |
Problem:
`yx` uses "y" prefix, which shadows a builtin operator.
Solution:
Use `g=` (in the form of `g==` currently), drawing from precedent of
CTRL-= and 'tpope/vim-scriptease'.
|
|\ |
|
| | |
|
| | |
|
|/
|
|
|
|
|
|
|
| |
**Problem:** The treesitter `foldexpr` runs synchronous parses to
calculate fold levels, which eliminates async parsing performance in the
highlighter.
**Solution:** Migrate the `foldexpr` to also calculate and apply fold
levels asynchronously.
|
|
|
|
|
|
|
|
|
|
| |
**Problem:** `vim.treesitter.get_parser()` and `vim.treesitter.start()`
both parse the tree before returning it. This is problematic because if
this is a sync parse, it will stall the editor on large files. If it is
an async parse, the functions return stale trees.
**Solution:** Remove this parsing side effect and leave it to the user
to parse the returned trees, either synchronously or asynchronously.
|
|
|
|
|
|
|
|
|
|
|
|
| |
**Problem:** Parsing can be slow for large files, and it is a blocking
operation which can be disruptive and annoying.
**Solution:** Provide a function for asynchronous parsing, which accepts
a callback to be run after parsing completes.
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Co-authored-by: VanaIgr <vanaigranov@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
**Problem:** Query parsing uses a weak cache which is invalidated
frequently
**Solution:** Make the cache strong, and invalidate it manually when
necessary (that is, when `rtp` is changed or `query.set()` is called)
Co-authored-by: Christian Clason <c.clason@uni-graz.at>
|
|
|
|
|
|
|
|
| |
Problem:
The `vim.treesitter.language.add` function returns
a error message even when it succeeds.
Solution:
Don't return error message on success.
|
| |
|
|
|
|
|
| |
`yxx` in Normal mode over a Lua or Vimscript code block section will execute the code.
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
**Problem:** The treesitter `foldexpr` calls `get_parser()` for each
line in the buffer when calculating folds. This can be incredibly slow
for buffers where a parser cannot be found (because the result is not
cached), and exponentially more so when the user has many
`runtimepath`s.
**Solution:** Only fetch the parser when it is needed; that is, only
when initializing fold data for a buffer.
Co-authored-by: Jongwook Choi <wookayin@gmail.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
|
| |
|
| |
|
| |
|
|
|
|
|
| |
This commit also adds some tests for the existing memoization
functionality.
|
| |
|
|
|
|
|
|
|
|
|
| |
Problem: autocmd to refresh folds always uses the current buffer if the
option type is local. However, the current buffer may not have a parser,
and thus the assert that checks for a parser could fail.
Solution: check if the foldinfo contains the buffer, and only refresh if
so.
|
| |
|
|
|
|
|
|
|
|
|
| |
Problem:
char-wise folding for `#trim!` ranges are improperly calculated for nodes that
end at column 0, due to the way `get_node_text` works.
Solution:
Add the blank line that `get_node_text` removes for for nodes ending at column
0. Also properly set column positions when performing linewise trims.
|
|
|
|
|
|
|
|
|
|
| |
This commit also implements more generic trimming, acting on all
whitespace (charwise) rather than just empty lines.
It will unblock
https://github.com/nvim-treesitter/nvim-treesitter/pull/3442 and allow
for properly concealing markdown bullet markers regardless of indent
width, e.g.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* refactor(shared): extract `vim._list_insert` and `vim._list_remove`
* feat(lsp): add `vim.lsp.foldexpr()`
* docs(lsp): add a todo for state management
* feat(lsp): add `vim.lsp.folding_range.foldclose()`
* feat(lsp): schedule `foldclose()` if the buffer is not up-to-date
* feat(lsp): add `vim.lsp.foldtext()`
* feat(lsp): support multiple folding range providers
* refactor(lsp): expose all folding related functions under `vim.lsp.*`
* perf(lsp): add `lsp.MultiHandler` for do `foldupdate()` only once
|
|
|
|
|
|
|
|
| |
Problem: Not possible to only set a "redraw later" type with
nvim__redraw, which seems to be desired for the
treesitter highlighter.
Solution: Do not update the screen when "flush" is explicitly set to
false and only redraw later types are present. In that case,
do not call ui_flush() either.
|
|
|
|
|
|
|
| |
Problem: nvim__redraw's "range" marks a buffer range for redraw, and subsequently
flushes the UI without updating the windows containing that buffer.
Solution: Implicitly update the screen, unless specified otherwise.
Only update the screen with the last call of the treesitter
on_changedtree() callback.
|
|
|
|
|
|
|
| |
Problem: Treesitter highlighter implements an on_bytes callback that
just re-marks a buffer range for redraw. The edit that
prompted the callback will already have done that.
Solution: Remove redundant on_bytes callback from the treesitter
highlighter module.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
Problem: Long lists of available parsers make it hard to see WASM
status.
Solution: Add separate headings for "treesitter features" (ABI, WASM)
and "treesitter parsers". Also add minimum supported ABI version.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
`vim.validate()` takes two forms when it only needs one.
Solution:
- Teach the fast form all the features of the spec form.
- Deprecate the spec form.
- General optimizations for both forms.
- Add a `message` argument which can be used alongside or in place
of the `optional` argument.
|