-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(fold): colorful foldtext #23471
Conversation
32a7cd0
to
a88bc23
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
This would need to go through typval conversion and the code for parsing virtual text is implemented using API objects. So supporting vimscript would be more work and slower. |
Allowing only one option to use a Lua expression is quite strange. It's better to support that for all '*expr' options, like how the following two Vim patches improve the performance of calling a simple function: |
@@ -1695,6 +1697,27 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char *marker, size_t marker | |||
} | |||
} | |||
|
|||
static char *get_foldtext_lua(char *fdt, char *buf, VirtText *vt, int *vtwidth) | |||
{ | |||
int len = snprintf(buf, FOLD_TEXT_LEN, "return %s", fdt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int len = snprintf(buf, FOLD_TEXT_LEN, "return %s", fdt); | |
int len = snprintf(buf, FOLD_TEXT_LEN, "return (%s)", fdt); |
|
||
if (strncmp(wp->w_p_fdt, "=", 1) == 0) { | ||
// evaluate as lua expression | ||
text = get_foldtext_lua(wp->w_p_fdt + 1, buf, vt, vtwidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs textlock
and maybe sandbox
Your right. Let's go with your way. |
If
'foldtext'
begins with=
, it will be evaluated as a Lua expression. This Lua expression can be a list of text-hl tuples (just like virtual text).Closes #12649