jremmen / vim-ripgrep Goto Github PK
View Code? Open in Web Editor NEWUse RipGrep in Vim and display results in a quickfix list
License: MIT License
Use RipGrep in Vim and display results in a quickfix list
License: MIT License
Hi!
In my .vimrc
, I have:
set ignorecase smartcase
This allows me to search via /
ignoring case, but then switch to smart-case as soon as I type a capital.
However, this causes an undesired behavior in vim-ripgrep where the quickfix list contains all matches ignoring case, even if my search query contained a capital letter. g:rg_highlight
only highlights the case-sensitive matches, which is great, but I'd also expect all the other incorrect-case-matches to be filtered out to make :cn
and :cp
easier.
I believe this was introduced in #5, although I'm not sure if this is by-design. But regardless, I'd greatly appreciate any tips to achieve my expected behavior!
I have noticed this plugin always searches for pattern through all files in the same folder of current opened file.
but I'd like it to search from parent folders that contains .git or other markers, like CtrlP for example.
Can we do that with this plugin?
While a search is being performed, all the raw output from rg
is displayed. When the search is complete, the output is parsed and moved to the quickfix window. It would improve search speed and general UX to handle the search results in the background and hide them until they are displayed in the quickfix window.
I think all this requires is the careful use of the silent
command.
For an example of a similar plugin that does this, see https://github.com/rking/ag.vim
vim-ripgrep/plugin/vim-ripgrep.vim
Line 114 in ec87af6
I'm enjoying vim-ripgrep quite a bit but I noticed that since installing, hlsearch was being set and unset quite a bit and I wasn't sure why. I tracked it down to the line above.
If you replace it with
call matchadd('keyword', a:txt)
it'll highlight it without messing with the search at all, at the cost of not being able to cycle through all the matches manually. This was my first mess with syntax highlighting so I'm not sure if this is a one-stop solution for every use case but it worked for me.
sometimes I just want to grep the whole word, rg -w
sometimes I want to be smartcase -S
sometimes I want to ignore certain files
it would be nice is there is a config that I can add those flags myself
After running :Rg
, I want the quickfix window to be opened with something like :bot copen
.
After looking at the code, right now it's just a copen
, but I don't see how this couldn't be changed via an option.
Is there a way I can reference the last selected window instead of the default botright?
I've tried searching for :help rg_window_location
or even :help Rg
but was unable to find it.
Hi. I've encounter a problem with vim-ripgrep.
It automatically ignore my '.gitignore' file.
Root: D:\MyFolder
List:
MyFolder.gitignore
'''
*.zxc
bar.*
'''
MyFolder\foo.zxc
'''Lorem Ipsum'''
MyFolder\foo.xcv
'''Lorem Ipsum'''
MyFolder\bar.zxc
'''Lorem Ipsum'''
Command:
rg -g *.zxc -e "Lorem Ipsum"
->
Bash output:
1:Lorem Ipsum
->
Vim output: (with --vimgrep)
bar.zxc|1 col 1| Lorem Ipsum
foo.zxc|1 col 1| Lorem Ipsum
Any idea how to solve this problem?
I've did
Would love an option to have the search from a project root, like CTRL-P - e.g. the root of a git working directory, if available!
https://github.com/junegunn/fzf.vim
Thank you for your plugin
Hi, thanks for the plug-in, migrated to rg
from ag
and never looked back.
I saw #28 but I can't do :Rg -F "params({
, it swallows {
so I had to do it as :!rg -F "params({"
Maybe add an :Rgf
command that would do a string-only search?
Hi, thanks for the plugin. Just upgrading from Ack
vim.
Came across a namespace clash and I'd like to add a bit of information to help anyone else stumbling on the same issue.
By default, the fzf plugin also maps the command :Rg
. A workaround from the fzf point of view is to make use of their optional prefix for their commands - let g:fzf_command_prefix = 'Fzf'
and then call :FzfRg
I wonder if there's a way somehow avoid the clash by default by changing the vim-ripgrep
internal code but without breaking your external API :Rg
?
Hi,
I have a problem where any search string supplied to the :Rg
command will result in No match found for <search>
. I installed ripgrep
with cargo install ripgrep
and I installed NeoVim v0.3.2-6-g5ff90a100 via choco install neovim
. vim-ripgrep
was installed with vim-plug.
I attempted to debug it by running let &grepprg = g:rg_command
and then running :exe 'grep! ' . '<search>'
, which displayed:
!rg --vimgrep <search> > C:\path\to\nvim\temp\file\1
shell returned 1
However, if I run this same command in cmd.exe
and then check the return code with echo %errorlevel%
, it shows 0.
Please let me know how I can fix this. Thanks! :)
I'm trying to make rg to search on top of project instead of current opened buffer.
but try to set let g:rg_derive_root = True
doesn't work.
gvim 8.0 on windows 10.
Long time user of this plugin. I've recently encountered a new error. Trying to open a search result item shows:
Error detected while processing function <SNR>80_call:
line 3:
The current buffer has no associated file
Press ENTER or type command to continue
NVIM v0.5.0-532-g2ca8f02a6
ripgrep 12.1.0
I'm not seeing any version info in the vim-ripgrep
plugin so I can't offer that.
Like tagbar plugin that we can press p
key to jump to definition but keep stay on tagbar window.
It'd be great if we can add this feature to vim-ripgrep.
seems like this behavior can currently only be toggled via the g:rg_derive_root
setting.
it would be nice if there was a way to override the setting, and interactively trigger a search in the entire project dir, or force only to search in CWD and below.
thoughts?
PS: cool plugin, thank you!
Happy to update the docs with this info if anyone can point in the right direction.
Outside of Vim you can do rg sausages -tcss
to search for sausages in any file type of 'css'. How do you pass the same file type limit argument in Vim?
Hello. Thanks for the plugin!
Just stumbled across this. I have set smartcase
on in my .vimrc so it would be great if your plugin could be aware of those options and auto add the according flags to RG command...
What do you think?
Thanks
Hi, would it be possible to add support to search for what's currently selected?
I like that by default it search for whatever word is under the cursor, but sometimes I need to include other special chars in it and then it's annoying to type it manually. It would be much easier to just select it and run :Rg
.
Thanks
OS : Windows 10
In command line
It search all "*.c' file with pattern "foo" non-recursively
but in vim, it would not ignore the "System Volume Information" folder
I did try to append more hidden folder and put file into it, but those folders would just bypassed by the glob flag -g "!*/".
Use wildignore to affect vim to ignore "System Volume Information" folder
set wildignore+=./System\ Volume\ Information
set wildignore+=System\ Volume\ Information
it still not working.
So...is it a issue from vimgrep or vim-rg?
This issue matter a lot. This issue happen on Windows's System Files too.
AND ~
Sometimes the "OS Error" string will ruin the layout of QuickFix and then you'll fail to jump.
and of course the "OS Error" is from "System Volume Information"
Current shellpipe="&>"
is incompatible with fish which results in error something like:
fish: Expected a command, but instead found a redirection
rg --vimgrep -i foo &> /var/folders/4z/bxmdspnn5qs9x0bbz8w7cbrw0000gn/T/nvimzCL1HW/4
fish is enabled via in ~/.config/nvim/init.vim
:
set shell=fish
vim-ripgrep/plugin/vim-ripgrep.vim
Line 89 in ec87af6
Started getting the following error recently:
hint: Waiting for your editor to close the file...
Error detected while processing ~/.vim/bundle/vim-ripgrep/plugin/vim-ripgrep.vim:
line 149: E1208: -complete used without -nargs Press ENTER or type command to continue
I've noticed the same was recently fixed in coc.nvim: neoclide/coc.nvim#3211
I'm coming from ag.vim (deprecated), which has some excellent keyboard shortcuts for the quickfix list:
e to open file and close the quickfix window
o to open (same as enter)
go to preview file (open but maintain focus on ag.vim results)
t to open in new tab
T to open in new tab silently
h to open in horizontal split
H to open in horizontal split silently
v to open in vertical split
gv to open in vertical split silently
q to close the quickfix window
The o
shortcut and the t
shortcut are particularly useful to me.
I'm not sure how to even use the quickfix list without these. I'm happy to learn a new way with Rg
, but I see no documentation about how to accomplish these things. Let me know if I'm missing something. I'm pretty busy these days, but I might be able to help out with a README improvement if you tell me the info to put in it, or where to find the info.
I've noticed when I triggered rg to search something in Gvim8.0/widows10, there's cmd windows open very fast each time I write to file (:w) after using rg.
Is there any chance we can get rid of this annoying?
Hi,
EDIT: apparently I interpreted some things wrongly in my last explanation, maybe I hadn't updated git or something,.. don't remember how I came to the conclusion, everything seems to work.. though maybe a bit different than I was used to.
Following search pattern used to work, but doesn't anymore as such:
:Rg -g *.chai pattern
but when I quote the glob pattern, it does seem to work:
:Rg -g "*.chai" pattern
Though slightly annoying, I can live with that, for me this issue can be closed now.
On macOS 10.13 and MacVim 8.0.1155 (137) vim-ripgrep has changed behaviour.
The old correct way to search:
:Rg "search_term"
results are found and (optionally) highlighted.
The current situation:
:Rg "search_term"
MacVim hangs up. So I use this, and it works:
:Rg "search_term" .
results are found, however, the highlighting pattern is not "search_term" anymore, but "search_term .", hence wrong highlighting is used.
can you help me find out why has vim-ripgrep behaviour changed after updating from macOS 10.12 to 10.13? or is it MacVim's problem? reverting MacVim doesn't do the trick, so that's that.
command line vim
(8.0) does not have this issue.
relevant .vimrc
rg configuration:
let g:rg_binary = "/usr/local/bin/rg"
let g:rg_highlight = 1
let g:rg_format = "%f:%l:%c:%m"
let g:rg_command = g:rg_binary . " --vimgrep --follow -i -j1 -e"
let g:rg_derive_root = 1
oh, btw, :RgRoot
shows correct directory.
Doesn't work:
:Rg $block['className']
Bad results
:Rg block['className']
Unrecognized
:Rg block[\'className\']
This one works!
:Rg \$block\['className'\]
I guess this is because all searches are made as regex?
Can I suggest having two commands?
like Rg
to literal and Rgp
for patterns?
it's hard to think on what needs to be escaped in regex all the time
There is a problem with the derivation of RgRootDir() in Windows.
In RgMakePath - the top (root) directory is drive:/, e.g. c:/. I did a dirty little fix and changed RgMakePath to:
fun! s:RgMakePath(dirs, dir)
let l:root = has("win32") ? '' : '/'
return l:root.join(a:dirs[0:index(a:dirs, a:dir)], '/')
endfun
...but this doesn't work for UNC paths, e.g. //computer/share/folder, so there is room for a better solution.
Hi.
Many thanks for the plugin. I have it mapped to several keys, and it'd be really neat if I could pass each of those a slightly different subset of rg flags, without having to change any of the g: variables. For instance I'd like to have mapping for regex/nonregex, case sensitive/insensitive etc. As it stands, its a bit cumbersome to do so.
Just my two cents.
Thanks!
NVIM v0.6.0-dev+127-g1a10acb99
I am using the latest neovim nightly mentioned above. Just after the latest neovim nightly update I noticed that I have started getting the following error. Could you please help.
Error detected while processing /home/tridib/.local/share/nvim/site/pack/packer/start/vim-ripgrep/plugin/vim-ripgrep.vim:
line 149:
E1208: -complete used without -nargs
Press ENTER or type command to continue
Keeping hlsearch of rg maybe annoying when you out of rg output window.
please add feature to turn it off.
If the current path contains a directory called files-to-search
and you type the command :Rg pattern files-
then press Tab, you end up with a control character in your input. Adding -complete=file
to the command
would allow tab-completion (similar to Ag.vim and other plugins).
Hello, there is no wiki/man and I'm trying to figure out what the setting rg_root_type
does since the name isn't self-describing.
The description says "list of files/dir found in project root" with default being ['.git']
.
"list of files/dir found"?
so I guess if it finds a .git folder in my "project root" it ignores it?
I'm already using --glob "!.git"
in g:rg_command
. I removed it to test and it doesn't seem to ignore any .git folder so I don't know what it does.
what does "project root" mean?
is it the current working directory of the current buffer or something else?
If someone could enlighten me that would be cool. Thanks!
line 149: E1208: -complete used without allowing argumentsPress ENTER or type command to continue
I get this error every time I open vim. I tried finding a solution online, but haven't found it yet
These are the lines used in my ~/.vimrc
if executable('rg')
let g;rg_derive_root='true'
endif
nnoremap ps :Rg
Hello,
I want to return after moving to another file with the rg command.
Similar to ctrl + t in ctags.
Can I do this?
Thanks.
Hi!
If I have file A open and I hit enter on a result in the quickfix list that is in file B, it opens up a new tab page with file B. This is undesirable. How do I change that behavior?
Thank you so much for putting this project together :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.