-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Move default statusline from C implementation to 'stl' expression #29389
base: master
Are you sure you want to change the base?
Conversation
Problem: - Default C implementation can not be viewed in the form of the statusline DSL - Therefore users can not base their statusline on the default with additional tweaks Solution: - Removes the C implementation of the default statusline - Implements the default statusline using the 'statusline' DSL This will make the default statusline readable as expression, and is a first step in providing a default Lua/Vimscript implementation. Reference: neovim#28809
I cannot check to make sure as I do not have access to my PC right now, but this does not seem like the correct way of setting the new default to me. This only sets the initial default value instead of a fallback value. E.g. if you did A better approach may be to take a statusline string value as a parameter in |
Yes, you're right. I forgot that setting strings option to an empty string usually reverts it to the default value. I'll look into your proposed approach. |
The easiest way to set the default statusline would be to modify the } else if (*p_stl != NUL || *wp->w_p_stl != NUL) {
// redraw custom status line
redraw_custom_statusline(wp);
} else {
// default statusline case
// define default statusline
char *default_stl = (char*)xmalloc(sizeof("hallo"));
strcpy(default_stl, "hallo");
p_stl = default_stl;
redraw_custom_statusline(wp);
} (excuse the probably really bad C code) But this seems like an antipattern to me: vim.o.statusline = ""
print(vim.o.statusline)
-- prints "hallo" when built with the C code above As @famiu suggested, another option would be to modify the functions that draw the stl ( The drawback here is that the default statusbar format is then still defined in statusbar.c, and I can imagine it not being ideal if we later want to define the default statusline from Lua/Vimscript. Also, how would @justinmk What do you think would be the right approach here? |
I don't think we should change option values as a side effect when building the statusline, that sounds like a recipe for disaster. Instead, we can define a function that returns the default value, and use that in relevant places. This keeps the default value contained to a single place while avoiding any unnecessary hacks |
Problem: No way to pass default format to statusline redrawer. Solution: This option allows to directly pass a format string to the function.
Partly fixes: #28809. After this is merged, we can look into implementing a Lua/Vimscript version of a more modern default statusline.
Let me know if/what docs I need to update. The current default is taken from :h 'statusline', where they describe it as
Emulate standard status line with 'ruler'
. I can change this toDefault statusline with 'ruler' set
. Should there also be a news entry?