Skip to content

Commit c220c09

Browse files
committed
fix!: Don't escape % in progress()/status()
Now the users should escape % in their statusline setting.
1 parent 54f48eb commit c220c09

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
This is a Neovim plugin/library for generating statusline components from the built-in LSP client.
44

55
## Notices
6+
- **2022/05/05**: **Breaking change**. `progress()` no longer escapes `%` in the returned string. If
7+
you were using `progress()` or `status()` in your `statusline` option, you should wrap the
8+
expression inside `%{}` to escape `%`. See [below](#all-together-now) for an example.
69
- **2021/03/13**: Some users report success using the Google "Noto Emoji" font for `status_symbol`
710
and `indicator_hint`.
811
- **2020/11/19**: Please note that the default diagnostics symbols require Font Awesome or a [Nerd
@@ -236,6 +239,12 @@ function! LspStatus() abort
236239
return ''
237240
endfunction
238241
242+
" Manually set 'statusline'
243+
set statusline+=%{LspStatus()}
244+
245+
" ... or use a statusline plugin, e.g. lightline:
246+
let g:lightline.active.right = [..., ['lsp_status']]
247+
let g:lightline.component_function = {'lsp_status': 'LspStatus'}
239248
```
240249

241250
## Status

lua/lsp-status/statusline.lua

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ local function get_lsp_progress()
4747
contents = msg.title
4848
if msg.message then contents = contents .. ' ' .. msg.message end
4949

50-
-- this percentage format string escapes a percent sign once to show a percentage and one more
51-
-- time to prevent errors in vim statusline's because of it's treatment of % chars
52-
if msg.percentage then contents = contents .. string.format(" (%.0f%%%%)", msg.percentage) end
50+
if msg.percentage then contents = contents .. string.format(" (%.0f%%)", msg.percentage) end
5351

5452
if msg.spinner then
5553
contents = config.spinner_frames[(msg.spinner % #config.spinner_frames) + 1] .. ' ' ..

0 commit comments

Comments
 (0)