From 5af38e218141eab3dc369277d68b9618695fb253 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Tue, 4 Feb 2025 07:06:49 +0800 Subject: [PATCH 1/6] refactor(provider): reactor "ASYNC_DIRECT" callback signature --- lua/fzfx/schema.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/fzfx/schema.lua b/lua/fzfx/schema.lua index 0906db652..4d369e77b 100644 --- a/lua/fzfx/schema.lua +++ b/lua/fzfx/schema.lua @@ -14,7 +14,7 @@ --- @alias fzfx.CommandStringProvider fzfx.PlainCommandStringProvider|fzfx.FunctionalCommandStringProvider --- @alias fzfx.CommandArrayProvider fzfx.PlainCommandArrayProvider|fzfx.FunctionalCommandArrayProvider --- @alias fzfx.DirectProvider fun(query:string?,context:fzfx.PipelineContext?):string[]? ---- @alias fzfx.AsyncDirectProviderOnComplete fun(err:string?,data:string[]?):nil +--- @alias fzfx.AsyncDirectProviderOnComplete fun(data:string[]|nil):nil --- @alias fzfx.AsyncDirectProvider fun(query:string?,context:fzfx.PipelineContext?,on_complete:fzfx.AsyncDirectProviderOnComplete):nil --- @alias fzfx.Provider fzfx.CommandStringProvider|fzfx.CommandArrayProvider|fzfx.DirectProvider|fzfx.AsyncDirectProvider --- From aa1528c3455ea2bef5e7bac8e89c1b10b7b3f9a7 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Tue, 4 Feb 2025 07:12:25 +0800 Subject: [PATCH 2/6] Update general.lua --- lua/fzfx/detail/general.lua | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/lua/fzfx/detail/general.lua b/lua/fzfx/detail/general.lua index 0b58eb669..d31cc8c7f 100644 --- a/lua/fzfx/detail/general.lua +++ b/lua/fzfx/detail/general.lua @@ -387,34 +387,18 @@ end --- @param query string? --- @param context fzfx.PipelineContext? function ProviderSwitch:_handle_async_direct(provider_config, query, context) - --- @param err1 string? - --- @param data1 string[]? - local function _on_complete(err1, data1) + --- @param data1 string[]|nil + local function _on_complete(data1) log.debug( - string.format("|async done| data1:%s, err1:%s", vim.inspect(data1), vim.inspect(err1)) + string.format("|async done| data1:%s", vim.inspect(data1)) ) log.debug(string.format("|async done| donefile:%s", vim.inspect(self.donefile))) -- When data is ready, write it into `resultfile`. - if err1 then + if tbl.tbl_empty(data1) then fio.writefile(self.resultfile, "") - log.echo(LogLevels.INFO, err1) - -- log.err( - -- string.format( - -- "failed to complete pipeline %s (ASYNC_DIRECT provider %s)! query:%s, context:%s, error:%s", - -- vim.inspect(self.pipeline), - -- vim.inspect(provider_config), - -- vim.inspect(query), - -- vim.inspect(context), - -- vim.inspect(err1) - -- ) - -- ) else - if tbl.tbl_empty(data1) then - fio.writefile(self.resultfile, "") - else - fio.writelines(self.resultfile, data1 --[[@as string[] ]]) - end + fio.writelines(self.resultfile, data1 --[[@as string[] ]]) end -- Then notify provider it is ready. From 107cf6bdb41129453331049e3f9abc9355d62e65 Mon Sep 17 00:00:00 2001 From: linrongbin16 <6496887+linrongbin16@users.noreply.github.com> Date: Mon, 3 Feb 2025 23:12:45 +0000 Subject: [PATCH 3/6] chore(pr): auto-commit --- lua/fzfx/detail/general.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/fzfx/detail/general.lua b/lua/fzfx/detail/general.lua index d31cc8c7f..2bc0ab402 100644 --- a/lua/fzfx/detail/general.lua +++ b/lua/fzfx/detail/general.lua @@ -389,9 +389,7 @@ end function ProviderSwitch:_handle_async_direct(provider_config, query, context) --- @param data1 string[]|nil local function _on_complete(data1) - log.debug( - string.format("|async done| data1:%s", vim.inspect(data1)) - ) + log.debug(string.format("|async done| data1:%s", vim.inspect(data1))) log.debug(string.format("|async done| donefile:%s", vim.inspect(self.donefile))) -- When data is ready, write it into `resultfile`. From a806fefbb906f909dd5f80b71d496aecaa954ccd Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Tue, 4 Feb 2025 07:19:18 +0800 Subject: [PATCH 4/6] Update _lsp_locations.lua --- lua/fzfx/cfg/_lsp_locations.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lua/fzfx/cfg/_lsp_locations.lua b/lua/fzfx/cfg/_lsp_locations.lua index 73cca9dda..ebdcd4dc4 100644 --- a/lua/fzfx/cfg/_lsp_locations.lua +++ b/lua/fzfx/cfg/_lsp_locations.lua @@ -290,7 +290,8 @@ M._make_lsp_locations_async_provider = function(opts) local function impl(query, context, on_complete) local lsp_clients = lsp.get_clients({ bufnr = context.bufnr }) if tbl.tbl_empty(lsp_clients) then - on_complete("no active lsp clients.") + log.echo(LogLevels.INFO, "no active lsp clients.") + on_complete(nil) return end @@ -307,7 +308,7 @@ M._make_lsp_locations_async_provider = function(opts) end if not supported then log.echo(LogLevels.INFO, vim.inspect(opts.method) .. " not supported.") - on_complete(vim.inspect(opts.method) .. " not supported.") + on_complete(nil) return end @@ -324,11 +325,11 @@ M._make_lsp_locations_async_provider = function(opts) if tbl.tbl_empty(results) then log.echo(LogLevels.INFO, "no lsp locations found.") - on_complete("no lsp locations found.") + on_complete(nil) return end - on_complete(nil, results) + on_complete(results) end ) @@ -644,7 +645,8 @@ M._make_lsp_call_hierarchy_async_provider = function(opts) local function impl(query, context, on_complete) local lsp_clients = lsp.get_clients({ bufnr = context.bufnr }) if tbl.tbl_empty(lsp_clients) then - on_complete("no active lsp clients.") + log.echo(LogLevels.INFO, "no active lsp clients.") + on_complete(nil) return end -- log.debug( @@ -659,7 +661,8 @@ M._make_lsp_call_hierarchy_async_provider = function(opts) end end if not supported then - on_complete(vim.inspect(opts.method) .. " not supported.") + log.echo(LogLevels.INFO, vim.inspect(opts.method) .. " not supported.") + on_complete(nil) return end @@ -676,7 +679,8 @@ M._make_lsp_call_hierarchy_async_provider = function(opts) M._process_prepare_call_hierarchy_response(response1 --[[@as table? ]]) if prepared_item == nil then - on_complete("no lsp call hierarchy found.") + log.echo(LogLevels.INFO, "no lsp call hierarchy found.") + on_complete(nil) return end @@ -692,11 +696,12 @@ M._make_lsp_call_hierarchy_async_provider = function(opts) local results = M._process_call_hierarchy_response(response2 --[[@as table? ]], opts) if tbl.tbl_empty(results) then - on_complete("no lsp call hierarchy found.") + log.echo(LogLevels.INFO, "no lsp call hierarchy found.") + on_complete(nil) return end - on_complete(nil, results) + on_complete(results) end ) From 441bb579b4c582cdb709b91bff4e514b84ff21cf Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Tue, 4 Feb 2025 07:22:58 +0800 Subject: [PATCH 5/6] Update git_branches.lua --- lua/fzfx/cfg/git_branches.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/fzfx/cfg/git_branches.lua b/lua/fzfx/cfg/git_branches.lua index bd5cae6a9..e4ca36068 100644 --- a/lua/fzfx/cfg/git_branches.lua +++ b/lua/fzfx/cfg/git_branches.lua @@ -92,13 +92,15 @@ M._make_async_provider = function(opts) async.void(function() local git_root_cmd = context.git_root_cmd if git_root_cmd:failed() then - on_complete("not in git repo.") + log.echo(LogLevels.INFO, "not in git repo.") + on_complete(nil) return end local git_current_branch_cmd = cmds.run_git_current_branch_async() if git_current_branch_cmd:failed() then - on_complete(table.concat(git_current_branch_cmd.stderr, " ")) + log.echo(LogLevels.INFO, table.concat(git_current_branch_cmd.stderr, " ")) + on_complete(nil) return end @@ -107,7 +109,8 @@ M._make_async_provider = function(opts) local git_branches_cmd = cmds.run_git_branches_async(remote_branch) if git_branches_cmd:failed() then - on_complete(table.concat(git_branches_cmd.stderr, " ")) + log.echo(LogLevels.INFO, table.concat(git_branches_cmd.stderr, " ")) + on_complete(nil) return end @@ -117,7 +120,7 @@ M._make_async_provider = function(opts) end end - on_complete(nil, results) + on_complete(results) end)() end From 2b51d1368efd4a3ca2c190bf973093aecabf9980 Mon Sep 17 00:00:00 2001 From: linrongbin16 Date: Tue, 4 Feb 2025 07:25:44 +0800 Subject: [PATCH 6/6] Update ci.yml --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ad9a4545..c5c115c37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,10 +45,11 @@ jobs: run: | cargo binstall --no-confirm selene selene --config selene.toml ./lua - # - uses: stevearc/nvim-typecheck-action@v2 - # with: - # path: lua - # configpath: ".luarc.json" + - uses: stevearc/nvim-typecheck-action@v2 + with: + nvim-version: v0.10.3 + path: lua + configpath: ".luarc.json" - uses: stefanzweifel/git-auto-commit-action@v5 if: ${{ github.ref != 'refs/heads/main' }} with: