From 0ceae8197ab16140f0f516d3df27870c6e06fe82 Mon Sep 17 00:00:00 2001 From: SeitaHigashi Date: Fri, 24 Feb 2023 01:15:22 +0900 Subject: [PATCH] feat: cwd option can be used as function. --- lua/cmp-rg/init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/cmp-rg/init.lua b/lua/cmp-rg/init.lua index c2979d9..3c95c8e 100644 --- a/lua/cmp-rg/init.lua +++ b/lua/cmp-rg/init.lua @@ -138,6 +138,11 @@ source.complete = function(self, request, callback) end end + local cwd = request.option.cwd + if type(request.option.cwd) == "function" then + cwd = request.option.cwd() + end + self.timer:stop() self.timer:start( request.option.debounce or 100, @@ -159,7 +164,7 @@ source.complete = function(self, request, callback) on_stderr = on_event, on_stdout = on_event, on_exit = on_event, - cwd = request.option.cwd or vim.fn.getcwd(), + cwd = cwd, } ) end)