Skip to content
Open
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
11 changes: 10 additions & 1 deletion lua/cmp-rg/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ source.complete = function(self, request, callback)
0,
vim.schedule_wrap(function()
vim.fn.jobstop(self.running_job_id)

local cwd = request.option.cwd or vim.fn.getcwd()
if type(cwd) == "function" then
cwd = cwd()
end
if cwd == nil then
return
end

self.running_job_id = vim.fn.jobstart(
string.format(
"rg --heading --json --word-regexp -B %d -A %d --color never %s %s%s%s%s .",
Expand All @@ -159,7 +168,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)
Expand Down