Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing env to new_termopen_previewer #3224

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

MarcusGrass
Copy link
Contributor

@MarcusGrass MarcusGrass commented Jul 25, 2024

Description

I'm trying to use difft for a custom picker and regular git diff on another.
Using the global set_env for telescope becomes too aggressive, just like in utils.job_maker I'd like to be able to pass env in the same format to do this:

previewer = prev.new_termopen_previewer({
    title = "Difft preview",
    env = { ['GIT_EXTERNAL_DIFF'] = '~/.local/bin/difft' },
    get_command = function(entry)
        local merge_base = git.git_show_merge_base()
        return { "git", "diff", merge_base, entry.value }
    end
})

Since it's a term command, being able to pass custom envs seems appropriate, the implementation is trivial and similar to what's done in utils.job_maker.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Run with local build from main using set_env = { GIT_EXTERNAL_DIFF = '~/.local/bin/difft' }, see difft diff
  • Run with local build from main not using set_env, see regular diff
  • Run with local build with my changes using set_env = { GIT_EXTERNAL_DIFF = '~/.local/bin/difft' }, see difft diff
  • Run with local build with my changes not using set_env, see regular diff
  • Run with local build with my changes not using set_env, passing no opts, see regular diff
  • Run with local build with my changes not using set_env, passing opts.env = { GIT_EXTERNAL_DIFF = '~/.local/bin/difft' }, see difft diff

Configuration:

  • Neovim version (nvim --version):
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
  • Operating system and version:
Linux 6.10.0-gentoo x86_64 GNU/Linux

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

Ps.

Create draft to see if CI adds docs to my PR, reworks #3223

Pps.

Any ideas on why the docs aren't changing?

@MarcusGrass MarcusGrass marked this pull request as ready for review July 25, 2024 08:32
@jamestrew
Copy link
Contributor

Looks good to me.
I'll try to generate the docs separately. The doc gen tool we're relying on is pretty outdated, I've been struggling to get it work reliably if at all. I have a replacement in the works.

@jamestrew jamestrew merged commit 3264f0a into nvim-telescope:master Jul 26, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants