Skip to content
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

implement default titlestring using statusline #1248

Open
josephholsten opened this issue Sep 27, 2014 · 5 comments
Open

implement default titlestring using statusline #1248

josephholsten opened this issue Sep 27, 2014 · 5 comments
Assignees
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md core Nvim core functionality or code defaults issues or PRs involving changing the defaults enhancement feature request statusline tabline, winbar, statuscolumn
Milestone

Comments

@josephholsten
Copy link
Contributor

josephholsten commented Sep 27, 2014

At the moment, when titlestring is not set, the default value is generated by accessing curbuf->b_fname, bufIsChanged(curbuf), curbuf->b_ffname & append_arg_number() (an extracted version of this is in src/nvim/title.c:113).

Unfortunately, it is not possible to reproduce this behaviour using a statusline format string. The closest might be:

:set titlestring=%t%(\ %M%)%(\ \(%F\)%)%a\ -\ VIM

where those represent the flags found in option_defs.h:

#define STL_FILENAME    't'             /* last part (tail) of file path */
#define STL_MODIFIED_ALT 'M'            /* modified flag - other display */
#define STL_FULLPATH    'F'             /* full path of file in buffer */
#define STL_ARGLISTSTAT 'a'             /* argument list status as (x of y) */

The only part which differs from the default titlestring is %F, which shows the full path of the file, including the last part (tail). The default uses the full path of the file with the part in %t and the final seperator removed.

The best way to allow for this would be to add a new statusline flag, say %d which shows the full path of the directory containing the current file.

Then, since statusline support is on all the time (according to src/nvim/version.c:140), we can simplify the implementation of maketitle() to always use the standard statusline processing.

Thoughts? Objections?

@bfredl
Copy link
Member

bfredl commented Sep 27, 2014

Completely argree. It would be much more convenient to start customizing the titlestring if one actually could start with the default string and gradually modifying it (rather than first having to google for a workaround, that almost, but not completely, replicates the builtin behavior)
Unrelated to your point, but wouldn't it be better if the default had 'NVIM' instead of 'VIM' ?

@justinmk justinmk added the enhancement feature request label Apr 29, 2015
@justinmk justinmk added this to the 0.3 milestone Aug 19, 2015
@justinmk justinmk modified the milestones: 0.4, todo Dec 14, 2018
@justinmk justinmk added complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md core Nvim core functionality or code and removed tui labels Dec 14, 2018
@Billy4195
Copy link
Contributor

After I traced the current titlestring document (in :help titlestring), I think this issue is done by someone else. Maybe this could be close?

@justinmk justinmk added the statusline tabline, winbar, statuscolumn label Jul 15, 2022
@justinmk
Copy link
Member

The only part which differs from the default titlestring is %F, which shows the full path of the file, including the last part (tail). The default uses the full path of the file with the part in %t and the final seperator removed.

This seems to mimic the default, what's missing?

set titlestring=%t%(\ %M%)%(\ \(%{expand(\"%:~:h\")}\)%)%a\ -\ NVIM

@justinmk justinmk mentioned this issue Jul 15, 2022
8 tasks
@cristianUrbina

This comment was marked as off-topic.

@clason

This comment was marked as off-topic.

@justinmk justinmk added the defaults issues or PRs involving changing the defaults label Dec 6, 2023
@glepnir glepnir self-assigned this Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md core Nvim core functionality or code defaults issues or PRs involving changing the defaults enhancement feature request statusline tabline, winbar, statuscolumn
Projects
None yet
Development

No branches or pull requests

7 participants