From d9ee0d2984e5fc30cb032785d32f42c72c7e64e1 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Wed, 1 Jan 2025 11:33:45 -0800 Subject: perf(treesitter): don't fetch parser for each fold line **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 Co-authored-by: Justin M. Keyes --- runtime/doc/news.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/doc') diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index b7606e65f5..17f85154c2 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -287,6 +287,8 @@ PERFORMANCE highlighting. • LSP diagnostics and inlay hints are de-duplicated (new requests cancel inflight requests). This greatly improves performance with slow LSP servers. +• 10x speedup for |vim.treesitter.foldexpr()| (when no parser exists for the + buffer). PLUGINS -- cgit