fdschmidt93 / telescope-egrepify.nvim

Variable user customization for telescope.live_grep to set rg flags on-the-fly
MIT License
115 stars 11 forks source link

fix: enable to open files with supplied cwd #20

Closed delphinus closed 11 months ago

delphinus commented 11 months ago

I noticed I cannot open files with cwd=/path/to/foo/dir option.

# Run Neovim in my home directory
~ $ nvim
" And open egrepify with specifying cwd
:Telescope egrepify cwd=/path/to/foo/dir

Then I select bar/init.lua, it tries to open ~/bar/init.lua instead of /path/to/foo/dir/bar/init.lua.

I fixed this with joining cwd value and relative path in filename. Is this a correct way to solve this? How do you think?

delphinus commented 11 months ago

I agree. Path:new() is too much way for joining paths, for sure.

BTW, vim.fs.joinpath has two problems. First, it naively uses / for path, so fails in Windows (maybe). Second, this func is unavailable v0.9.x that telescope.nvim still supports.

I will rewrite by using cwd .. Path.path.sep .. filename.

fdschmidt93 commented 11 months ago

Second, this func is unavailable v0.9.x that telescope.nvim still supports.

Great point! Makes the decision easy :)

BTW, vim.fs.joinpath has two problems. First, it naively uses / for path, so fails in Windows (maybe).

Oof. Windows does also support forward slashes generally speaking, but we would have had to jump through more hoops (i.e., setting forward slash in --path-separator explicitly).

fdschmidt93 commented 11 months ago

Thanks!

Just incorporated a fix (using entry.path since filename otherwise clashes with entry maker when actions.to_fuzzy_refine is called) and also as a precaution added it to title.