Skip to content

Commit a0bfc3d

Browse files
committed
Add support for platinum searcher
1 parent 8d5c368 commit a0bfc3d

File tree

4 files changed

+75
-28
lines changed

4 files changed

+75
-28
lines changed

‎README.md‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ grep
44
Plugin to integrate various grep like search tools with Vim.
55

66
The grep plugin integrates grep like utilities (grep, fgrep, egrep, agrep,
7-
findstr, silver searcher (ag), ripgrep, ack, git grep and sift) with Vim and
8-
allows you to search for a pattern in one or more files and jump to them.
7+
findstr, silver searcher (ag), ripgrep, ack, git grep, sift and platinum
8+
searcher) with Vim and allows you to search for a pattern in one or more files
9+
and jump to them.
910

1011
To use this plugin, you will need the grep like utilities in your system. If a
1112
particular utility is not present, then you cannot use the corresponding
@@ -49,6 +50,11 @@ utility from:
4950

5051
https://sift-tool.org
5152

52-
The silver searcher, ripgrep and ack utilities can search for a pattern
53-
recursively across directories without using any other additional utilities
54-
like find and xargs.
53+
If you want to use the platinum searcher (pt) with this plugin, then you can
54+
download the platinum searcher utility from:
55+
56+
https://github.com/monochromegane/the_platinum_searcher
57+
58+
The silver searcher, ripgrep, ack and platinum searcher utilities can search
59+
for a pattern recursively across directories without using any other additional
60+
utilities like find and xargs.

‎autoload/grep.vim‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
" File: grep.vim
22
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
33
" Version: 2.1
4-
" Last Modified: March 11, 2018
4+
" Last Modified: March 13, 2018
55
"
66
" Plugin to integrate grep like utilities with Vim
77
" Supported utilities are: grep, fgrep, egrep, agrep, findstr, ag, ack,
8-
" ripgrep, git grep and sift
8+
" ripgrep, git grep, sift and platinum searcher
99
"
1010
" License: MIT License
1111
" Copyright (c) 2002-2018 Yegappan Lakshmanan
@@ -83,6 +83,11 @@ if !exists("Sift_Path")
8383
let Sift_Path = 'sift'
8484
endif
8585

86+
" Location of the platinum searcher utility
87+
if !exists("Pt_Path")
88+
let Pt_Path = 'pt'
89+
endif
90+
8691
" grep options
8792
if !exists("Grep_Options")
8893
let Grep_Options = ''
@@ -133,6 +138,11 @@ if !exists("Sift_Options")
133138
let Sift_Options = ''
134139
endif
135140

141+
" pt options
142+
if !exists("Pt_Options")
143+
let Pt_Options = ''
144+
endif
145+
136146
" Location of the find utility
137147
if !exists("Grep_Find_Path")
138148
let Grep_Find_Path = 'find'
@@ -304,6 +314,14 @@ let s:cmdTable = {
304314
\ 'opts' : g:Sift_Options,
305315
\ 'expropt' : '-e',
306316
\ 'nulldev' : ''
317+
\ },
318+
\ 'pt' : {
319+
\ 'cmdpath' : g:Pt_Path,
320+
\ 'optprefix' : '-',
321+
\ 'defopts' : '--nocolor --nogroup',
322+
\ 'opts' : g:Pt_Options,
323+
\ 'expropt' : '',
324+
\ 'nulldev' : ''
307325
\ }
308326
\ }
309327

@@ -554,7 +572,8 @@ function! s:recursive_search_cmd(cmd_name)
554572
return a:cmd_name == 'ag' ||
555573
\ a:cmd_name == 'rg' ||
556574
\ a:cmd_name == 'ack' ||
557-
\ a:cmd_name == 'git'
575+
\ a:cmd_name == 'git' ||
576+
\ a:cmd_name == 'pt'
558577
endfunction
559578

560579
" formFullCmd()

‎doc/grep.txt‎

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
44
For Vim version 7.0 and above
5-
Last change: March 11, 2018
5+
Last change: March 13, 2018
66

77
==============================================================================
88
*grep-license*
@@ -39,8 +39,9 @@ CONTENTS~
3939
1. Overview~
4040

4141
The grep plugin integrates grep like utilities (grep, fgrep, egrep, agrep,
42-
findstr, silver searcher, ack, ripgrep, git grep, sift) with Vim and allows
43-
you to search for a pattern in one or more files and jump to them.
42+
findstr, silver searcher, ack, ripgrep, git grep, sift and platinum searcher)
43+
with Vim and allows you to search for a pattern in one or more files and jump
44+
to them.
4445

4546
To use this plugin, you will need the grep like utilities in your system. If
4647
a particular utility is not present, then you cannot use the corresponding
@@ -79,14 +80,19 @@ ripgrep utility from:
7980

8081
https://github.com/BurntSushi/ripgrep
8182

82-
If you want to use sift with this plugin, then you can download the sift
83-
utility from:
83+
If you want to use the sift utility with this plugin, then you can download
84+
the sift utility from:
8485

8586
https://sift-tool.org
8687

87-
The silver searcher, ripgrep, ack and sift utilities can search for a pattern
88-
recursively across directories without using any other additional utilities
89-
like find and xargs.
88+
If you want to use the platinum searcher with this plugin, then you can
89+
download the platinum searcher utility from:
90+
91+
https://github.com/monochromegane/the_platinum_searcher
92+
93+
The silver searcher, ripgrep, ack, sift and platinum searcher utilities can
94+
search for a pattern recursively across directories without using any other
95+
additional utilities like find and xargs.
9096

9197
The github repository for this plugin is at https://github.com/yegappan/grep
9298

@@ -153,6 +159,8 @@ The grep.vim plugin introduces the following Vim commands:
153159
:GitgrepAdd - Same as ":Gitgrep" but adds the results to the current list
154160
:Sift - Run sift
155161
:SiftAdd - Same as ":Sift" but adds the results to the current list
162+
:Ptgrep - Run the platinum searcher (pt)
163+
:PtgrepAdd - Same as ":Ptgrep" but adds the results to the current list
156164

157165
The above commands can be invoked like this:
158166

@@ -170,6 +178,7 @@ The above commands can be invoked like this:
170178
:Rg [<options>] [<search_pattern> [<file_name(s)>]]
171179
:Gitgrep [<options>] [<search_pattern> [<file_name(s)>]]
172180
:Sift [<options>] [<search_pattern> [<file_name(s)>]]
181+
:Ptgrep [<options>] [<search_pattern> [<file_name(s)>]]
173182

174183
:GrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
175184
:RgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
@@ -184,7 +193,8 @@ The above commands can be invoked like this:
184193
:AckAdd [<options>] [<search_pattern> [<file_name(s)>]]
185194
:RgAdd [<options>] [<search_pattern> [<file_name(s)>]]
186195
:GitgrepAdd [<options>] [<search_pattern> [<file_name(s)>]]
187-
:SftAdd [<options>] [<search_pattern> [<file_name(s)>]]
196+
:SiftAdd [<options>] [<search_pattern> [<file_name(s)>]]
197+
:PtgrepAdd [<options>] [<search_pattern> [<file_name(s)>]]
188198

189199
:GrepBuffer [<grep_options>] [<search_pattern>]
190200
:Bgrep [<grep_options>] [<search_pattern>]
@@ -295,10 +305,10 @@ When using GUI Vim, the Tools->Search menu item with a few sub-menu items is
295305
created for few variations of the search command.
296306

297307
Note that when recursively searching for a pattern using the silver searcher,
298-
ripgrep, ack, git grep or sift utilities, if a large number (several
299-
thousands) of matching files are found, then it will take some time for Vim to
300-
load all the files into the buffer list. In the meantime, Vim will be slow to
301-
respond or may not respond to keystrokes.
308+
ripgrep, ack, git grep, sift or platinum searcher utilities, if a large number
309+
(several thousands) of matching files are found, then it will take some time
310+
for Vim to load all the files into the buffer list. In the meantime, Vim will
311+
be slow to respond or may not respond to keystrokes.
302312

303313
==============================================================================
304314
*grep-configuration*
@@ -355,12 +365,18 @@ command:
355365

356366
:let Git_Path = 'C:\Progra~1\git\git.exe'
357367

358-
The 'Sift_Path' variable is used to locate the sift utility used by the
359-
Siftgrep command. By default, this is set to sift. You can change this using
360-
the let command:
368+
The 'Sift_Path' variable is used to locate the sift utility used by the Sift
369+
command. By default, this is set to sift. You can change this using the let
370+
command:
361371

362372
:let Sift_Path = 'C:\Progra~1\sift\sift.exe'
363373

374+
The 'Pt_Path' variable is used to locate the platinum searcher utility used by
375+
the Ptgrep command. By default, this is set to pt. You can change this
376+
using the let command:
377+
378+
:let Pt_Path = 'C:\Progra~1\pt\pt.exe'
379+
364380
The 'Grep_Find_Path' variable is used to locate the find utility. By default,
365381
this is set to 'find'. Note that on MS-Windows, there is a find.exe that is
366382
part of the base OS. This find utility is different from the Unix find
@@ -392,8 +408,8 @@ using the let command:
392408

393409
Similarly you can pass command line options to other commands by setting the
394410
'Fgrep_Options', 'Egrep_Options', 'Agrep_Options', 'Findstr_Options',
395-
'Ag_options', 'Ack_Options', 'Rg_Options', "Gitgrep_Options' and
396-
'Sift_Options' variables in your .vimrc file.
411+
'Ag_options', 'Ack_Options', 'Rg_Options', "Gitgrep_Options', 'Sift_Options'
412+
and 'Pt_Options' variables in your .vimrc file.
397413

398414
The 'Grep_Skip_Dirs' variable specifies the list of directories to skip while
399415
doing recursive searches. By default, this is set to 'RCS CVS SCCS'. You can

‎plugin/grep.vim‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
" File: grep.vim
22
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
33
" Version: 2.1
4-
" Last Modified: March 11, 2018
4+
" Last Modified: March 13, 2018
55
"
66
" Plugin to integrate grep like utilities with Vim
77
" Supported utilities are: grep, fgrep, egrep, agrep, findstr, ag, ack,
8-
" ripgrep, git grep and sift
8+
" ripgrep, git grep, sift and platinum searcher
99
"
1010
" License: MIT License
1111
" Copyright (c) 2002-2018 Yegappan Lakshmanan
@@ -114,6 +114,12 @@ command! -nargs=* -complete=file Sift
114114
command! -nargs=* -complete=file SiftAdd
115115
\ call grep#runGrep('SiftAdd', 'sift', 'add', <f-args>)
116116

117+
" Platinum Searcher commands
118+
command! -nargs=* -complete=file Ptgrep
119+
\ call grep#runGrep('Ptgrep', 'pt', 'set', <f-args>)
120+
command! -nargs=* -complete=file PtgrepAdd
121+
\ call grep#runGrep('PtgrepAdd', 'pt', 'add', <f-args>)
122+
117123
" findstr commands
118124
if has('win32')
119125
command! -nargs=* -complete=file Findstr

0 commit comments

Comments
 (0)