cmp-rg
cmp-rg copied to clipboard
feat: use vim.uv.spawn instead of vim.fn.jobstart
The current code uses vim.schedule_wrap
to call vim.fn.jobstart
for running rg
. This can be replaced by uv.spawn
that can be called “in fast event”. This makes it run rg
as soon as cmp starts to complete.
But this change has 2 problems.
-
vim.fn.json_decode
cannot be called in fast event. We should always usevim.json.decode
, so we must remove support for Neovim older than v0.6. -
uv.spawn
always run a process directly (without shell). Nowadditional_arguments
option should be an array instead of string.
I think benefits we can get by this change are larger than these breaking changes.
Does this actually make a different to the performance? Can you profile this?
I simply test by record duration between begining of complete() and where callback being called, it was 150ms before and 50ms now in init.lua file with debounce of 0.
The difference is vim.schedule_wrap is delayed by 100ms(depends on cmp bussyness) to start the job