aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/treesitter.c
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2024-12-18 10:48:33 -0800
committerRiley Bruins <ribru17@hotmail.com>2025-01-12 08:10:47 -0800
commit45e606b1fddbfeee8fe28385b5371ca6f2fba71b (patch)
tree16c8099e39b6eb7daae6334274e0deb3b02c3c9d /src/nvim/lua/treesitter.c
parent3fdc4302415972eb5d98ba832372236be3d22572 (diff)
downloadrneovim-45e606b1fddbfeee8fe28385b5371ca6f2fba71b.tar.gz
rneovim-45e606b1fddbfeee8fe28385b5371ca6f2fba71b.tar.bz2
rneovim-45e606b1fddbfeee8fe28385b5371ca6f2fba71b.zip
feat(treesitter): async parsing
**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>
Diffstat (limited to 'src/nvim/lua/treesitter.c')
-rw-r--r--src/nvim/lua/treesitter.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index 28ad2cf4d3..9bd2baad27 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -489,7 +489,11 @@ static int parser_parse(lua_State *L)
// Sometimes parsing fails (timeout, or wrong parser ABI)
// In those case, just return an error.
if (!new_tree) {
- return luaL_error(L, "An error occurred when parsing.");
+ if (ts_parser_timeout_micros(p) == 0) {
+ // No timeout set, must have had an error
+ return luaL_error(L, "An error occurred when parsing.");
+ }
+ return 0;
}
// The new tree will be pushed to the stack, without copy, ownership is now to the lua GC.