plenary.nvim icon indicating copy to clipboard operation
plenary.nvim copied to clipboard

Question about usage

Open TheLazyLemur opened this issue 10 months ago • 1 comments

Hey everyone 👋🏼

I have a question regarding using this lib with rg.

I have this call:

Job:new({
  command = 'rg',
  args = { '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case', '--', 'sync' },
  cwd = '/home/dan/.config/nvim2024',
  env = { ['a'] = 'b' },
  on_exit = function(j, return_val)
    _ = j
    _ = return_val
  end,
}):sync()

However when I get it, plenary timesout after 5000ms. Even If I set it to a higher value, I still get a timeout.

Error detected while processing /home/dan/.config/nvim2024/init.lua:                                                                                                                      
E5113: Error while calling lua chunk: ...2024/site/pack/deps/opt/plenary.nvim/lua/plenary/job.lua:499: 'rg --color=never --no-heading --with-filename --line-number --column --smart-case 
-- sync' was unable to complete in 5000 ms                                                                                                                                                
stack traceback:                                                                                                                                                                          
        [C]: in function 'error'                                                                                                                                                          
        ...2024/site/pack/deps/opt/plenary.nvim/lua/plenary/job.lua:499: in function 'wait'                                                                                               
        ...2024/site/pack/deps/opt/plenary.nvim/lua/plenary/job.lua:453: in function 'sync'                                                                                               
        /home/dan/.config/nvim2024/init.lua:19: in main chunk 

I do not get this error If I use another command like fd or even ls.

Thank you 🙏🏼

TheLazyLemur avatar Apr 18 '24 08:04 TheLazyLemur

When using rg you are searching for strings in files or files with the filename "sync", but fd and ls only are looking for files.

If I use it like:

Job:new({
  command = 'rg',
  args = { "--files" },
  cwd = os.getenv("HOME") .. '/.config/nvim',
  on_exit = function(j, return_val)
    print(vim.inspect(j:result()))
    _ = return_val
  end,
}):sync()

-- output: { "init.lua", ... }

For some reason rg it's not working when looking into the files.

AlejandroSuero avatar Apr 21 '24 19:04 AlejandroSuero