diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3aca085..c0ad353 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/action-conventional-commits@v1.1.0 - uses: ytanikin/PRConventionalCommits@1.1.0 with: task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert","break"]' @@ -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: @@ -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 ." @@ -89,6 +107,7 @@ jobs: needs: - luacheck - unit_test + - code_coverage runs-on: ubuntu-latest steps: - uses: google-github-actions/release-please-action@v3 diff --git a/README.md b/README.md index 13f7902..02bba6f 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ # lsp-progress.nvim -

-Neovim -luarocks -ci.yml -codecov +

+Neovim +luarocks +ci.yml +codecov

A performant lsp progress status for Neovim.

@@ -166,8 +166,8 @@ For more details, please see [Design & Technics](https://github.com/linrongbin16 ## Requirement -- Neovim ≥ 0.6.0. -- [Nerd fonts](https://www.nerdfonts.com/) for icons. +- neovim ≥ 0.6.0. +- [nerd fonts](https://www.nerdfonts.com/) for icons. ## Install @@ -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, @@ -284,7 +285,8 @@ local StatusLine = { { ... }, -- Lsp progress status component here - LspProgress + LspProgress, + ... } require('heirline').setup({ diff --git a/lua/lsp-progress.lua b/lua/lsp-progress.lua index 6694853..fefb86c 100644 --- a/lua/lsp-progress.lua +++ b/lua/lsp-progress.lua @@ -299,10 +299,14 @@ local function progress(option) content = vim.fn.strpart( content, 0, - vim.fn.max({ option.max_size - 1, 0 }) + math.max(option.max_size - 1, 0) ) .. "…" end end + if type(content) == "string" then + content = content:gsub("%%", "%%%%") + end + logger.debug( "|lsp-progress.progress| returned content: %s", vim.inspect(content) diff --git a/lua/lsp-progress/defaults.lua b/lua/lsp-progress/defaults.lua index 1d65b82..6162239 100644 --- a/lua/lsp-progress/defaults.lua +++ b/lua/lsp-progress/defaults.lua @@ -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")