feat: add clear_env option (#598)

This commit is contained in:
fcying 2024-08-08 18:34:48 +08:00 committed by GitHub
parent 8ed0f52006
commit 16a2873e67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View file

@ -195,6 +195,7 @@ require("toggleterm").setup{
persist_mode = true, -- if set to true (default) the previous terminal mode will be remembered
direction = 'vertical' | 'horizontal' | 'tab' | 'float',
close_on_exit = true, -- close the terminal window when the process exits
clear_env = false, -- use only environmental variables from `env`, passed to jobstart()
-- Change the default shell. Can be a string or a function returning a string
shell = vim.o.shell,
auto_scroll = true, -- automatically scroll to the bottom on terminal output

View file

@ -26,6 +26,7 @@ local function shade(color, factor) return colors.shade_color(color, factor) end
--- @field persist_size boolean
--- @field persist_mode boolean
--- @field close_on_exit boolean
--- @field clear_env boolean
--- @field direction '"horizontal"' | '"vertical"' | '"float"'
--- @field shading_factor number
--- @field shading_ratio number
@ -49,6 +50,7 @@ local config = {
persist_size = true,
persist_mode = true,
close_on_exit = true,
clear_env = false,
direction = "horizontal",
shading_factor = constants.shading_amount,
shading_ratio = constants.shading_ratio,

View file

@ -208,7 +208,7 @@ function Terminal:new(term)
term.id = id or next_id()
term.display_name = term.display_name
term.float_opts = vim.tbl_deep_extend("keep", term.float_opts or {}, conf.float_opts)
term.clear_env = term.clear_env
term.clear_env = vim.F.if_nil(term.clear_env, conf.clear_env)
term.auto_scroll = vim.F.if_nil(term.auto_scroll, conf.auto_scroll)
term.env = vim.F.if_nil(term.env, conf.env)
term.hidden = vim.F.if_nil(term.hidden, false)