-
-
Notifications
You must be signed in to change notification settings - Fork 924
Description
Description
Hello! today I've tried to add some additional arguments to live_grep on Windows. However, I ran into the problem that this some arguments ripgrep just refused to work and provided empty output.
So, what I originally tried to do is this:
exts_shader_code = "--type-add shader:*.{hlsl,azsl,glsl,comp,rchit,rcmiss,rgen,hlsli,azsli,h,shader,pass} -tshader"
exts_cpu = "-tc -tcpp"
require('telescope.builtin').live_grep({
additional_args = {
"--no-ignore",
exts_shader_code,
exts_cpu,
},
})However, this leads to unexpected behavior above. The trick is to do it like this:
exts_shader_code = {"--type-add", "shader:*.{hlsl,azsl,glsl,comp,rchit,rcmiss,rgen,hlsli,azsli,h,shader,pass}", "-tshader"}
exts_cpu = {"-tc", "-tcpp"}
require('telescope.builtin').live_grep({
additional_args = {
"--no-ignore",
exts_shader_code,
exts_cpu,
},
})Now it works, because nvim.uv (nvim.loop) automatically puts the arguments to ripgrep in double quotes on Windows ONLY and if you have several arguments in one string it quotes the entire string and the args become invalid.
To be honest, this is extremely counterintuitive behavior that's OS specific. You can remedy this by setting options.verbatim of uv.spawn to true (in lua/telescope/_.lua. The file is probably generated, I didn't check the repo ). Alternatively, you can specifically explain this behavior in the docs to Telescope and make it more apparent (if it already is explained, I've missed it and it drives my point home IMHO).
Neovim version
NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068Operating system and version
Windows 11
Telescope version / branch / rev
df534c3 fix(git_status): correctly count result on_complete (#3321) (3 weeks ago)
checkhealth telescope
==============================================================================
telescope: health#telescope#check
Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.
Checking external dependencies ~
- OK rg: found ripgrep 14.1.1 (rev 4649aa9700)
- WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities
===== Installed extensions ===== ~
Telescope Extension: `ag` ~
- No healthcheck provided
Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configuredSteps to reproduce
- Be on windows
- Install NeoVim and ripgrep (from scoop)
- Install telescope
- Configure live_grep as shown above
- Run live_grep
Expected behavior
ripgrep returns expected results or tells you which arguments are incorrect.
Actual behavior
ripgrep shows empty output.
Minimal config
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
vim.fn.system {
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
}
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
require("telescope").setup {}
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
exts_shader_code = "--type-add shader:*.{hlsl,azsl,glsl,comp,rchit,rcmiss,rgen,hlsli,azsli,h,shader,pass} -tshader"
exts_cpu = "-tc -tcpp"
vim.keymap.set('n', '<F5>',
(function()
require('telescope.builtin').live_grep({
additional_args = {
"--no-ignore",
exts_shader_code,
exts_cpu,
},
})
end)
)