diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index edaefddc..8e2bc43a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/lua/grug-far/opts.lua b/lua/grug-far/opts.lua index e732bd5d..d9978380 100644 --- a/lua/grug-far/opts.lua +++ b/lua/grug-far/opts.lua @@ -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 = '', @@ -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 @@ -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 diff --git a/lua/grug-far/rg/fetchFilesWithMatches.lua b/lua/grug-far/rg/fetchFilesWithMatches.lua index 815b9b7b..9266f282 100644 --- a/lua/grug-far/rg/fetchFilesWithMatches.lua +++ b/lua/grug-far/rg/fetchFilesWithMatches.lua @@ -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 diff --git a/lua/grug-far/rg/fetchReplacedFileContent.lua b/lua/grug-far/rg/fetchReplacedFileContent.lua index ab8ab90d..ee1001c5 100644 --- a/lua/grug-far/rg/fetchReplacedFileContent.lua +++ b/lua/grug-far/rg/fetchReplacedFileContent.lua @@ -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, diff --git a/lua/grug-far/rg/fetchResults.lua b/lua/grug-far/rg/fetchResults.lua index 9bab3b0f..835c7a70 100644 --- a/lua/grug-far/rg/fetchResults.lua +++ b/lua/grug-far/rg/fetchResults.lua @@ -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, diff --git a/lua/grug-far/rg/fetchWithRg.lua b/lua/grug-far/rg/fetchWithRg.lua index c25d7c08..d9426f8d 100644 --- a/lua/grug-far/rg/fetchWithRg.lua +++ b/lua/grug-far/rg/fetchWithRg.lua @@ -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) @@ -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, diff --git a/lua/grug-far/test/helpers.lua b/lua/grug-far/test/helpers.lua index ccad8c31..692ce116 100644 --- a/lua/grug-far/test/helpers.lua +++ b/lua/grug-far/test/helpers.lua @@ -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') @@ -112,6 +114,7 @@ function M.initChildNeovim(child) ]], { { + rgPath = rgPath, icons = { resultsStatusReady = 'STATUS_READY', resultsStatusError = 'STATUS_ERROR',