Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Commit f07e643

Browse files
Merge pull request #34 from leonid-shevtsov/ripgrep-support
Add ripgrep support
2 parents 6d495d7 + 0d20f9e commit f07e643

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

SearchInProject.sublime-settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
"search_in_project_ThePlatinumSearcher_path_to_executable": "pt",
3030
"search_in_project_ThePlatinumSearcher_mandatory_options": "--column --nogroup --nocolor",
3131

32+
/* Ripgrep configuration */
33+
"search_in_project_Ripgrep_path_to_executable": "rg",
34+
"search_in_project_Ripgrep_mandatory_options": "--column --no-heading --color never",
3235

3336
/* GitGrep configuration */
3437
"search_in_project_GitGrep_path_to_executable": "git",

searchengines/ripgrep.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Start of fixing import paths
2+
import os, sys, inspect
3+
# realpath() with make your script run, even if you symlink it :)
4+
cmd_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile( inspect.currentframe() ))[0]))
5+
if cmd_folder not in sys.path:
6+
sys.path.insert(0, cmd_folder)
7+
# use this if you want to include modules from a subforder
8+
cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],"subfolder")))
9+
if cmd_subfolder not in sys.path:
10+
sys.path.insert(0, cmd_subfolder)
11+
# Info:
12+
# cmd_folder = os.path.dirname(os.path.abspath(__file__)) # DO NOT USE __file__ !!!
13+
# __file__ fails if script is called in different ways on Windows
14+
# __file__ fails if someone does os.chdir() before
15+
# sys.argv[0] also fails because it doesn't not always contains the path
16+
### End of fixing import paths
17+
18+
import base
19+
20+
class Ripgrep (base.Base):
21+
22+
def _is_search_error(self, returncode, output, error):
23+
return (returncode != 0) and self._sanitize_output(error) != ""
24+
25+
engine_class = Ripgrep

0 commit comments

Comments
 (0)