Skip to content

Commit 3264f0a

Browse files
authored
feat(previewer): allow passing env to new_termopen_previewer (#3224)
* Allow passing env through term opts * Add doc update
1 parent 47ab113 commit 3264f0a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lua/telescope/previewers/init.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,16 @@ end
9090
--- Additionally you can define:
9191
--- - `title` a static title for example "File Preview"
9292
--- - `dyn_title(self, entry)` a dynamic title function which gets called
93+
--- - `env` table: define environment variables to forward to the terminal
94+
--- process. Example:
95+
--- - `{ ['PAGER'] = '', ['MANWIDTH'] = 50 }`
9396
--- when config value `dynamic_preview_title = true`
9497
---
9598
--- It's an easy way to get your first previewer going and it integrates well
9699
--- with `bat` and `less`. Providing out of the box scrolling if the command
97100
--- uses less.
98101
---
99-
--- Furthermore, it will forward all `config.set_env` environment variables to
102+
--- Furthermore, if `env` is not set, it will forward all `config.set_env` environment variables to
100103
--- that terminal process.
101104
previewers.new_termopen_previewer = term_previewer.new_termopen_previewer
102105

lua/telescope/previewers/term_previewer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ previewers.new_termopen_previewer = function(opts)
202202

203203
local term_opts = {
204204
cwd = opts.cwd or vim.loop.cwd(),
205-
env = conf.set_env,
205+
env = opts.env or conf.set_env,
206206
}
207207

208208
local cmd = opts.get_command(entry, status)

0 commit comments

Comments
 (0)