Skip to content

Commit

Permalink
making rgPath configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Badragan committed May 23, 2024
1 parent e83d33a commit 754d263
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,25 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
neovim_version: ['v0.9.5', 'v0.10.0']
neovim_version: ['v0.9.5']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Install xmllint
run: sudo apt-get install -y ripgrep
- name: Setup neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim_version }}
- name: Install ripgrep
run: |
mkdir ripgrep
cd ripgrep
wget -O - https://github.com/BurntSushi/ripgrep/releases/download/14.1.0/ripgrep-14.1.0-x86_64-unknown-linux-musl.tar.gz | tar zxf - --strip-component=1
ls
cd ..
./ripgrep/rg foo .
- name: Run tests
run: make prepare && make test
run: |
make prepare
env RG_PATH=/home/runner/work/grug-far.nvim/grug-far.nvim/ripgrep/rg make test
5 changes: 5 additions & 0 deletions lua/grug-far/opts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ M.defaultOptions = {
-- max number of parallel replacements tasks
maxWorkers = 4,

-- ripgrep executable to use, can be a different path if you need to configure
rgPath = 'rg',

-- extra args that you always want to pass to rg
-- like for example if you always want context lines around matches
extraRgArgs = '',
Expand Down Expand Up @@ -187,6 +190,7 @@ M.defaultOptions = {
---@field debounceMs integer
---@field minSearchChars integer
---@field maxWorkers integer
---@field rgPath string
---@field extraRgArgs string
---@field disableBufferLineNumbers boolean
---@field maxSearchCharsInTitles integer
Expand All @@ -203,6 +207,7 @@ M.defaultOptions = {
---@field debounceMs? integer
---@field minSearchChars? integer
---@field maxWorkers? integer
---@field rgPath? string
---@field extraRgArgs? string
---@field disableBufferLineNumbers? boolean
---@field maxSearchCharsInTitles? integer
Expand Down
1 change: 1 addition & 0 deletions lua/grug-far/rg/fetchFilesWithMatches.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local function fetchFilesWithMatches(params)

return fetchWithRg({
args = args,
options = params.options,
on_fetch_chunk = function(data)
local lines = vim.split(data, '\n')
for i = 1, #lines do
Expand Down
1 change: 1 addition & 0 deletions lua/grug-far/rg/fetchReplacedFileContent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local function fetchReplacedFileContent(params)
local content = ''
return fetchWithRg({
args = args,
options = params.options,
on_fetch_chunk = function(data)
content = content .. data
end,
Expand Down
1 change: 1 addition & 0 deletions lua/grug-far/rg/fetchResults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ local function fetchResults(params)

return fetchWithRg({
args = args,
options = params.options,
on_fetch_chunk = function(data)
params.on_fetch_chunk(parseResults(data))
end,
Expand Down
3 changes: 2 additions & 1 deletion lua/grug-far/rg/fetchWithRg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ end

---@class FetchWithRgParams
---@field args string[] | nil
---@field options GrugFarOptions
---@field on_fetch_chunk fun(data: string)
---@field on_finish fun(status: GrugFarStatus, errorMesage: string | nil)

Expand All @@ -32,7 +33,7 @@ local function fetchWithRg(params)
local stderr = uv.new_pipe()

local handle
handle = uv.spawn('rg', {
handle = uv.spawn(params.options.rgPath, {
stdio = { nil, stdout, stderr },
cwd = vim.fn.getcwd(),
args = args,
Expand Down
3 changes: 3 additions & 0 deletions lua/grug-far/test/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ function M.initChildNeovim(child)
-- Restart child process with custom 'init.lua' script
child.restart({ '-u', 'scripts/minimal_init.lua' })

local rgPath = vim.env.RG_PATH or 'rg'

child.lua(
[[
vim.api.nvim_set_current_dir('temp_test_dir')
Expand All @@ -112,6 +114,7 @@ function M.initChildNeovim(child)
]],
{
{
rgPath = rgPath,
icons = {
resultsStatusReady = 'STATUS_READY',
resultsStatusError = 'STATUS_ERROR',
Expand Down

0 comments on commit 754d263

Please sign in to comment.