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

fix(format): fix '%' escape issue again #118

Merged
merged 16 commits into from
Feb 9, 2024
35 changes: 27 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ on:
- main
- master
jobs:
pr_conventional_commit:
name: PR Conventional Commit
conventional_commit:
name: Conventional Commit
if: ${{ github.ref != 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - uses: webiny/[email protected]
- uses: ytanikin/[email protected]
with:
task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert","break"]'
Expand All @@ -37,7 +36,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --config-path .stylua.toml lua/ test/
args: --config-path .stylua.toml ./lua ./test
- uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.ref != 'refs/heads/main' }}
with:
Expand All @@ -59,15 +58,34 @@ jobs:
with:
luaVersion: "luajit-2.1.0-beta3"
- uses: leafo/gh-actions-luarocks@v4
- name: Run test cases
- name: Run Tests
shell: bash
run: |
luarocks install luacheck
luarocks install vusted
vusted --shuffle ./test
code_coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rhysd/action-setup-vim@v1
id: vim
with:
neovim: true
version: stable
- uses: leafo/gh-actions-lua@v10
with:
luaVersion: "luajit-2.1.0-beta3"
- uses: leafo/gh-actions-luarocks@v4
- name: Run Tests
shell: bash
run: |
luarocks install luacheck
luarocks install luacov
luarocks install cluacov
luarocks install vusted
vusted --coverage --shuffle ./test
- name: Generate coverage reports
vusted --coverage ./test
- name: Generate Coverage Report
shell: bash
run: |
echo "ls ."
Expand All @@ -89,6 +107,7 @@ jobs:
needs:
- luacheck
- unit_test
- code_coverage
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# lsp-progress.nvim

<p align="center">
<a href="https://github.com/neovim/neovim/releases/v0.6.0"><img alt="Neovim" src="https://img.shields.io/badge/Neovim-v0.6+-57A143?logo=neovim&logoColor=57A143" /></a>
<a href="https://luarocks.org/modules/linrongbin16/lsp-progress.nvim"><img alt="luarocks" src="https://custom-icon-badges.demolab.com/luarocks/v/linrongbin16/lsp-progress.nvim?label=LuaRocks&labelColor=2C2D72&logo=tag&logoColor=fff&color=blue" /></a>
<a href="https://github.com/linrongbin16/lsp-progress.nvim/actions/workflows/ci.yml"><img alt="ci.yml" src="https://img.shields.io/github/actions/workflow/status/linrongbin16/lsp-progress.nvim/ci.yml?label=GitHub%20CI&labelColor=181717&logo=github&logoColor=fff" /></a>
<a href="https://app.codecov.io/github/linrongbin16/lsp-progress.nvim"><img alt="codecov" src="https://img.shields.io/codecov/c/github/linrongbin16/lsp-progress.nvim?logo=codecov&logoColor=F01F7A&label=Codecov" /></a>
<p>
<a href="https://github.com/neovim/neovim/releases/v0.6.0"><img alt="Neovim" src="https://img.shields.io/badge/require-0.6%2B-blue" /></a>
<a href="https://luarocks.org/modules/linrongbin16/lsp-progress.nvim"><img alt="luarocks" src="https://img.shields.io/luarocks/v/linrongbin16/lsp-progress.nvim" /></a>
<a href="https://github.com/linrongbin16/lsp-progress.nvim/actions/workflows/ci.yml"><img alt="ci.yml" src="https://img.shields.io/github/actions/workflow/status/linrongbin16/lsp-progress.nvim/ci.yml?label=ci" /></a>
<a href="https://app.codecov.io/github/linrongbin16/lsp-progress.nvim"><img alt="codecov" src="https://img.shields.io/codecov/c/github/linrongbin16/lsp-progress.nvim/main?label=codecov" /></a>
</p>

<p align="center"><i> A performant lsp progress status for Neovim. </i></p>
Expand Down Expand Up @@ -166,8 +166,8 @@ For more details, please see [Design & Technics](https://github.com/linrongbin16

## Requirement

- Neovim &ge; 0.6.0.
- [Nerd fonts](https://www.nerdfonts.com/) for icons.
- neovim &ge; 0.6.0.
- [nerd fonts](https://www.nerdfonts.com/) for icons.

## Install

Expand Down Expand Up @@ -245,8 +245,9 @@ lua require('lsp-progress').setup()
```lua
require("lualine").setup({
sections = {
lualine_a = { "mode" },
lualine_b = { "filename" },
-- Other Status Line components
lualine_a = { ... },
lualine_b = { ... },
lualine_c = {
-- invoke `progress` here.
require('lsp-progress').progress,
Expand Down Expand Up @@ -284,7 +285,8 @@ local StatusLine = {
{ ... },

-- Lsp progress status component here
LspProgress
LspProgress,
...
}

require('heirline').setup({
Expand Down
6 changes: 5 additions & 1 deletion lua/lsp-progress.lua
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,14 @@
content = vim.fn.strpart(
content,
0,
vim.fn.max({ option.max_size - 1, 0 })
math.max(option.max_size - 1, 0)

Check warning on line 302 in lua/lsp-progress.lua

View check run for this annotation

Codecov / codecov/patch

lua/lsp-progress.lua#L302

Added line #L302 was not covered by tests
) .. "…"
end
end
if type(content) == "string" then
content = content:gsub("%%", "%%%%")

Check warning on line 307 in lua/lsp-progress.lua

View check run for this annotation

Codecov / codecov/patch

lua/lsp-progress.lua#L306-L307

Added lines #L306 - L307 were not covered by tests
end

logger.debug(
"|lsp-progress.progress| returned content: %s",
vim.inspect(content)
Expand Down
8 changes: 3 additions & 5 deletions lua/lsp-progress/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,15 @@ local Defaults = {
local has_title = false
local has_message = false
if type(title) == "string" and string.len(title) > 0 then
local escaped_title = title:gsub("%%", "%%%%")
table.insert(builder, escaped_title)
table.insert(builder, title)
has_title = true
end
if type(message) == "string" and string.len(message) > 0 then
local escaped_message = message:gsub("%%", "%%%%")
table.insert(builder, escaped_message)
table.insert(builder, message)
has_message = true
end
if percentage and (has_title or has_message) then
table.insert(builder, string.format("(%.0f%%%%)", percentage))
table.insert(builder, string.format("(%.0f%%)", percentage))
end
if done and (has_title or has_message) then
table.insert(builder, "- done")
Expand Down
Loading