Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rg --path-separator option not working #304

Closed
doongjohn opened this issue Nov 10, 2024 · 5 comments
Closed

rg --path-separator option not working #304

doongjohn opened this issue Nov 10, 2024 · 5 comments
Labels
question Further information is requested

Comments

@doongjohn
Copy link

my config:

require 'grug-far'.setup {
  engines = {
    ripgrep = {
      extraArgs =
          '--no-heading -.ni --path-separator=/'
          .. ' -g !.git'
          .. ' -g !.github'
          .. ' -g !*cache'
          .. ' -g !obj'
          .. ' -g !.objs'
          .. ' -g !.deps'
          .. ' -g !bin'
          .. ' -g !out'
          .. ' -g !build'
          .. ' -g !target'
          .. ' -g !vendor'
          .. ' -g !dist'
          .. ' -g !node_modules'
          .. ' -g !.svelte-kit'
          .. ' -g !zig-out'
          .. ' -g !.godot',
    },
  },
  windowCreationCommand = 'vert topleft split',
  wrap = false,
}

I'm on windows but I want to set path separator to / because of this issue: nvim-telescope/telescope.nvim#2446

However, it still uses \ even if I set --path-separator to /.

@MagicDuck
Copy link
Owner

MagicDuck commented Nov 12, 2024

hmm, I think it's ripgrep --json option itself that does not respect --path-separator (I am on mac where default is forward slash).
image

Are you seeing an actual bug when triggering the Open action? I do wrap it with fnameescape() here:

vim.fn.win_execute(targetWin, 'e! ' .. vim.fn.fnameescape(location.filename), true)

@doongjohn
Copy link
Author

If I open a file src\routes\(csr)\+layout.ts with the open action (,o) the file is empty.
Recording 2024-11-13 at 10 43 50

If I do <c-g> in that empty file, the path is incorrect:
image

@MagicDuck
Copy link
Owner

hi @doongjohn, I have incorporated logic from neo-tree.nvim when escaping the file paths for opening.
They seem to have gone through a long history of fixes in this area and apparently replacing \ with / is not always ideal since it can confuse other plugins that rely on the right separator for the platform. Although doing that is always an option if it ends up not working.

I can't easily test on windows myself. Can you grab the latest version and check that opening is working fine now?

@MagicDuck MagicDuck added the question Further information is requested label Nov 13, 2024
@doongjohn
Copy link
Author

It's working really well! Thank you for the quick fix!

@MagicDuck
Copy link
Owner

Great! Thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants