diff --git a/README.md b/README.md index 4c411ad..f686ac9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lua/toggleterm/config.lua b/lua/toggleterm/config.lua index d6d15b2..9ae1ecf 100644 --- a/lua/toggleterm/config.lua +++ b/lua/toggleterm/config.lua @@ -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, diff --git a/lua/toggleterm/terminal.lua b/lua/toggleterm/terminal.lua index 904eb34..9218749 100644 --- a/lua/toggleterm/terminal.lua +++ b/lua/toggleterm/terminal.lua @@ -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)