From 4f60c6fcd1c459ff9a0639583167d1ccf8914b8f Mon Sep 17 00:00:00 2001 From: Udayvir Singh <97400310+udayvir-singh@users.noreply.github.com> Date: Wed, 1 Mar 2023 09:05:38 +0530 Subject: [PATCH] [utils]: make result window width static --- fnl/tangerine/utils/window.fnl | 8 +++----- lua/tangerine/utils/window.lua | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/fnl/tangerine/utils/window.fnl b/fnl/tangerine/utils/window.fnl index 4a29634..5bc07f4 100644 --- a/fnl/tangerine/utils/window.fnl +++ b/fnl/tangerine/utils/window.fnl @@ -149,16 +149,14 @@ "defines a floating window with height 'lineheight'." (normalize-parent (vim.api.nvim_get_current_win)) (let [buffer (vim.api.nvim_create_buf false true) - win-width (vim.api.nvim_win_get_width 0) win-height (vim.api.nvim_win_get_height 0) bordersize 2 - width (- win-width bordersize) height (math.max 1 (math.floor (math.min (/ win-height 1.5) lineheight)))] (vim.api.nvim_open_win buffer true { - : width - : height - :col 0 :row (- win-height bordersize height win-stack.total) + :col 0 + :height height + :width 360 :style "minimal" :anchor "NW" :border "single" diff --git a/lua/tangerine/utils/window.lua b/lua/tangerine/utils/window.lua index b593ca6..975ee10 100644 --- a/lua/tangerine/utils/window.lua +++ b/lua/tangerine/utils/window.lua @@ -169,12 +169,10 @@ win["create-float"] = function(lineheight0, filetype, hl_normal, _3fhl_border) _G.assert((nil ~= lineheight0), "Missing argument lineheight on fnl/tangerine/utils/window.fnl:148") normalize_parent(vim.api.nvim_get_current_win()) local buffer = vim.api.nvim_create_buf(false, true) - local win_width = vim.api.nvim_win_get_width(0) local win_height = vim.api.nvim_win_get_height(0) local bordersize = 2 - local width = (win_width - bordersize) local height = math.max(1, math.floor(math.min((win_height / 1.5), lineheight0))) - vim.api.nvim_open_win(buffer, true, {width = width, height = height, col = 0, row = (win_height - bordersize - height - win_stack.total), style = "minimal", anchor = "NW", border = "single", relative = "win"}) + vim.api.nvim_open_win(buffer, true, {row = (win_height - bordersize - height - win_stack.total), col = 0, height = height, width = 360, style = "minimal", anchor = "NW", border = "single", relative = "win"}) insert_stack(vim.api.nvim_get_current_win()) update_stack() vim.api.nvim_buf_set_option(buffer, "ft", filetype) @@ -183,9 +181,9 @@ win["create-float"] = function(lineheight0, filetype, hl_normal, _3fhl_border) return buffer end win["set-float"] = function(lines, filetype, hl_normal, _3fhl_border) - _G.assert((nil ~= hl_normal), "Missing argument hl-normal on fnl/tangerine/utils/window.fnl:177") - _G.assert((nil ~= filetype), "Missing argument filetype on fnl/tangerine/utils/window.fnl:177") - _G.assert((nil ~= lines), "Missing argument lines on fnl/tangerine/utils/window.fnl:177") + _G.assert((nil ~= hl_normal), "Missing argument hl-normal on fnl/tangerine/utils/window.fnl:175") + _G.assert((nil ~= filetype), "Missing argument filetype on fnl/tangerine/utils/window.fnl:175") + _G.assert((nil ~= lines), "Missing argument lines on fnl/tangerine/utils/window.fnl:175") local lines0 = vim.split(lines, "\n") local nlines = lineheight(lines0) local buffer = win["create-float"](nlines, filetype, hl_normal, _3fhl_border)