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

Don't escape % in status() #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lua/lsp-status/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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] .. ' ' ..
Expand Down