From 3264f0ae9dc48ed5a20c346ff05f2de49f2d3f27 Mon Sep 17 00:00:00 2001 From: MarcusGrass <34198073+MarcusGrass@users.noreply.github.com> Date: Fri, 26 Jul 2024 05:25:46 +0200 Subject: [PATCH] feat(previewer): allow passing env to `new_termopen_previewer` (#3224) * Allow passing env through term opts * Add doc update --- lua/telescope/previewers/init.lua | 5 ++++- lua/telescope/previewers/term_previewer.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/telescope/previewers/init.lua b/lua/telescope/previewers/init.lua index cf998e2..9984a57 100644 --- a/lua/telescope/previewers/init.lua +++ b/lua/telescope/previewers/init.lua @@ -90,13 +90,16 @@ end --- Additionally you can define: --- - `title` a static title for example "File Preview" --- - `dyn_title(self, entry)` a dynamic title function which gets called +--- - `env` table: define environment variables to forward to the terminal +--- process. Example: +--- - `{ ['PAGER'] = '', ['MANWIDTH'] = 50 }` --- when config value `dynamic_preview_title = true` --- --- It's an easy way to get your first previewer going and it integrates well --- with `bat` and `less`. Providing out of the box scrolling if the command --- uses less. --- ---- Furthermore, it will forward all `config.set_env` environment variables to +--- Furthermore, if `env` is not set, it will forward all `config.set_env` environment variables to --- that terminal process. previewers.new_termopen_previewer = term_previewer.new_termopen_previewer diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index 8b4bae6..a75fac0 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -202,7 +202,7 @@ previewers.new_termopen_previewer = function(opts) local term_opts = { cwd = opts.cwd or vim.loop.cwd(), - env = conf.set_env, + env = opts.env or conf.set_env, } local cmd = opts.get_command(entry, status)