mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-05 18:56:13 +00:00
feat!(terminal): unify terminal window behavior and centralize sizing config (#102)
- add terminal.window.type support (hsplit, vsplit, floating, tab) - add terminal.window.split_size for split-based layouts - rename floating size options to terminal.window.floating_width/floating_height - validate terminal window ratios during setup - make terminal.run/run_floating merge default keymaps internally - remove cmd.split width/height sizing in favor of terminal.window config - improve floating/log buffer state handling and refresh behavior - update README examples and configuration docs BREAKING CHANGE: terminal sizing/config moved to terminal.window.*. Removed cmd.split.width/cmd.split.height. Renamed terminal.window.width/height to terminal.window.floating_width/floating_height
This commit is contained in:
@@ -3,21 +3,6 @@ local M = {}
|
||||
local utils = require("jj.utils")
|
||||
local terminal = require("jj.ui.terminal")
|
||||
|
||||
--- Clamps a ratio value between 0.1 and 1.0, returning a default of 1.0 if the input is invalid.
|
||||
---@param value? number
|
||||
---@param field string
|
||||
---@return number
|
||||
local function clamp_ratio(value, field)
|
||||
if type(value) ~= "number" or value < 0.1 or value > 1.0 then
|
||||
utils.notify(
|
||||
string.format("Value for field `%s` must be between `0.1` and `1.0`. Defaulted to `1.0`", field),
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
return 1.0
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
local function build_split_command(opts)
|
||||
local args = { "jj", "split" }
|
||||
|
||||
@@ -56,8 +41,6 @@ function M.split(opts)
|
||||
|
||||
local cmd_mod = require("jj.cmd")
|
||||
opts = vim.tbl_deep_extend("force", cmd_mod.config.split or {}, opts or {}) --[[@as jj.cmd.split.opts]]
|
||||
opts.height = clamp_ratio(opts.height, "height")
|
||||
opts.width = clamp_ratio(opts.width, "width")
|
||||
|
||||
-- If it's empty do nothing
|
||||
if utils.is_change_empty(opts.rev or "@") then
|
||||
@@ -69,8 +52,6 @@ function M.split(opts)
|
||||
terminal.run_floating(cmd, nil, {
|
||||
title = " JJ Split ",
|
||||
modifiable = true,
|
||||
height = math.floor(vim.o.lines * opts.height),
|
||||
width = math.floor(vim.o.columns * opts.width),
|
||||
keep_modifiable = true,
|
||||
interactive = true,
|
||||
on_exit = opts.on_exit or nil,
|
||||
|
||||
Reference in New Issue
Block a user