From c1f4e749ee386471616c4282b4539c788f49cc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Mon, 20 Jan 2025 21:50:58 +0100 Subject: [PATCH] statusline: Provide `overwrite` mode indicator --- internal/config/settings.go | 2 +- internal/display/statusline.go | 6 ++++++ runtime/help/options.md | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/config/settings.go b/internal/config/settings.go index a1c01c81dd..02a58270ed 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -93,7 +93,7 @@ var defaultCommonSettings = map[string]interface{}{ "softwrap": false, "splitbottom": true, "splitright": true, - "statusformatl": "$(filename) $(modified)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)", + "statusformatl": "$(filename) $(modified)$(overwrite)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)", "statusformatr": "$(bind:ToggleKeyMenu): bindings, $(bind:ToggleHelp): help", "statusline": true, "syntax": true, diff --git a/internal/display/statusline.go b/internal/display/statusline.go index 4a48a9004d..fe2f8a4257 100644 --- a/internal/display/statusline.go +++ b/internal/display/statusline.go @@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{ } return "" }, + "overwrite": func(b *buffer.Buffer) string { + if b.OverwriteMode && !b.Type.Readonly { + return "[overwrite] " + } + return "" + }, "lines": func(b *buffer.Buffer) string { return strconv.Itoa(b.LinesNum()) }, diff --git a/runtime/help/options.md b/runtime/help/options.md index 87943392e4..418610a3ba 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -415,11 +415,11 @@ Here are the available options: * `statusformatl`: format string definition for the left-justified part of the statusline. Special directives should be placed inside `$()`. Special directives include: `filename`, `modified`, `line`, `col`, `lines`, - `percentage`, `opt`, `bind`. + `percentage`, `opt`, `overwrite`, `bind`. The `opt` and `bind` directives take either an option or an action afterward and fill in the value of the option or the key bound to the action. - default value: `$(filename) $(modified)($(line),$(col)) $(status.paste)| + default value: `$(filename) $(modified)$(overwrite)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)` * `statusformatr`: format string definition for the right-justified part of the