I really like the new vim.o.foldtext="" functionality that enables syntax highlighting. However, I am unsure how to modify it to show not only the first line of the fold but also the number of lines and the last line. Is it possible to easily add the number of lines and the last line to foldtext while still using the new syntax highlighting?

Expected result is:

int foo() {
   return 0;

int bar() { ... 4 lines ... }

I know how to do this with a custom function that parses text with Treesitter, as shown in this post. However, I am looking for a more convenient solution. My current setup looks like this:

Preview image.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.