From c220c09bc9213c25f445b19e9f1bb33e126b5925 Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Thu, 5 May 2022 02:07:34 +0900 Subject: [PATCH] fix!: Don't escape % in progress()/status() Now the users should escape % in their statusline setting. --- README.md | 9 +++++++++ lua/lsp-status/statusline.lua | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d8e7c61..8305404 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ This is a Neovim plugin/library for generating statusline components from the built-in LSP client. ## Notices +- **2022/05/05**: **Breaking change**. `progress()` no longer escapes `%` in the returned string. If + you were using `progress()` or `status()` in your `statusline` option, you should wrap the + expression inside `%{}` to escape `%`. See [below](#all-together-now) for an example. - **2021/03/13**: Some users report success using the Google "Noto Emoji" font for `status_symbol` and `indicator_hint`. - **2020/11/19**: Please note that the default diagnostics symbols require Font Awesome or a [Nerd @@ -236,6 +239,12 @@ function! LspStatus() abort return '' endfunction +" Manually set 'statusline' +set statusline+=%{LspStatus()} + +" ... or use a statusline plugin, e.g. lightline: +let g:lightline.active.right = [..., ['lsp_status']] +let g:lightline.component_function = {'lsp_status': 'LspStatus'} ``` ## Status diff --git a/lua/lsp-status/statusline.lua b/lua/lsp-status/statusline.lua index 1526bd8..38e0cff 100644 --- a/lua/lsp-status/statusline.lua +++ b/lua/lsp-status/statusline.lua @@ -47,9 +47,7 @@ local function get_lsp_progress() contents = msg.title if msg.message then contents = contents .. ' ' .. msg.message end - -- this percentage format string escapes a percent sign once to show a percentage and one more - -- time to prevent errors in vim statusline's because of it's treatment of % chars - if msg.percentage then contents = contents .. string.format(" (%.0f%%%%)", msg.percentage) end + if msg.percentage then contents = contents .. string.format(" (%.0f%%)", msg.percentage) end if msg.spinner then contents = config.spinner_frames[(msg.spinner % #config.spinner_frames) + 1] .. ' ' ..