Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lua/toggleterm/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local utils = require("toggleterm.utils")
local M = {}

local fmt = string.format
local if_nil = vim.fn.has("nvim-0.13") == 1 and vim.nonnil or vim.F.if_nil

local function shade(color, factor) return colors.shade_color(color, factor) end

Expand Down Expand Up @@ -86,8 +87,8 @@ local config = {
local function get_highlights(conf)
local user = conf.highlights
local defaults = {
NormalFloat = vim.F.if_nil(user.NormalFloat, { link = "Normal" }),
FloatBorder = vim.F.if_nil(user.FloatBorder, { link = "Normal" }),
NormalFloat = if_nil(user.NormalFloat, { link = "Normal" }),
FloatBorder = if_nil(user.FloatBorder, { link = "Normal" }),
StatusLine = { gui = "NONE" },
StatusLineNC = { cterm = "italic", gui = "NONE" },
}
Expand Down
21 changes: 11 additions & 10 deletions lua/toggleterm/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local constants = lazy.require("toggleterm.constants")
local api = vim.api
local fmt = string.format
local fn = vim.fn
local if_nil = vim.fn.has("nvim-0.13") == 1 and vim.nonnil or vim.F.if_nil

local mode = {
INSERT = "i",
Expand Down Expand Up @@ -208,16 +209,16 @@ function Terminal:new(term)
term.id = id or M.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 = 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)
term.on_create = vim.F.if_nil(term.on_create, conf.on_create)
term.on_open = vim.F.if_nil(term.on_open, conf.on_open)
term.on_close = vim.F.if_nil(term.on_close, conf.on_close)
term.on_stdout = vim.F.if_nil(term.on_stdout, conf.on_stdout)
term.on_stderr = vim.F.if_nil(term.on_stderr, conf.on_stderr)
term.on_exit = vim.F.if_nil(term.on_exit, conf.on_exit)
term.clear_env = if_nil(term.clear_env, conf.clear_env)
term.auto_scroll = if_nil(term.auto_scroll, conf.auto_scroll)
term.env = if_nil(term.env, conf.env)
term.hidden = if_nil(term.hidden, false)
term.on_create = if_nil(term.on_create, conf.on_create)
term.on_open = if_nil(term.on_open, conf.on_open)
term.on_close = if_nil(term.on_close, conf.on_close)
term.on_stdout = if_nil(term.on_stdout, conf.on_stdout)
term.on_stderr = if_nil(term.on_stderr, conf.on_stderr)
term.on_exit = if_nil(term.on_exit, conf.on_exit)
term.__state = { mode = "?" }
if term.close_on_exit == nil then term.close_on_exit = conf.close_on_exit end
-- Add the newly created terminal to the list of all terminals
Expand Down
9 changes: 5 additions & 4 deletions lua/toggleterm/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local terms = lazy.require("toggleterm.terminal")
local fn = vim.fn
local fmt = string.format
local api = vim.api
local if_nil = vim.fn.has("nvim-0.13") == 1 and vim.nonnil or vim.F.if_nil

local origin_window
local persistent = {}
Expand Down Expand Up @@ -277,14 +278,14 @@ function M._get_float_config(term, opening)
local width = math.ceil(math.min(vim.o.columns, math.max(80, vim.o.columns - 20)))
local height = math.ceil(math.min(vim.o.lines, math.max(20, vim.o.lines - 10)))

width = vim.F.if_nil(M._resolve_size(opts.width, term), width)
height = vim.F.if_nil(M._resolve_size(opts.height, term), height)
width = if_nil(M._resolve_size(opts.width, term), width)
height = if_nil(M._resolve_size(opts.height, term), height)

local row = math.ceil(vim.o.lines - height) * 0.5 - 1
local col = math.ceil(vim.o.columns - width) * 0.5 - 1

row = vim.F.if_nil(M._resolve_size(opts.row, term), row)
col = vim.F.if_nil(M._resolve_size(opts.col, term), col)
row = if_nil(M._resolve_size(opts.row, term), row)
col = if_nil(M._resolve_size(opts.col, term), col)

local version = vim.version()

Expand Down