tangled
alpha
login
or
join now
robinwobin.dev
/
artio.nvim
3
fork
atom
minimal extui fuzzy finder for neovim
3
fork
atom
overview
issues
pulls
pipelines
refactor(view): move `win_config` to method
robinwobin.dev
1 week ago
a5a11ba4
fc36ae6f
+23
-23
1 changed file
expand all
collapse all
unified
split
lua
artio
view.lua
+23
-23
lua/artio/view.lua
···
32
33
local prompt_hl_id = vim.api.nvim_get_hl_id_by_name("ArtioPrompt")
34
35
-
--- Set the 'cmdheight' and cmdline window height. Reposition message windows.
36
-
---
37
-
---@param win integer Cmdline window in the current tabpage.
38
-
---@param hide boolean Whether to hide or show the window.
39
-
---@param height integer (Text)height of the cmdline window.
40
-
local function win_config(win, hide, height)
41
-
if ui2.cmdheight == 0 and vim.api.nvim_win_get_config(win).hide ~= hide then
42
-
vim.api.nvim_win_set_config(win, { hide = hide, height = not hide and height or nil })
43
-
elseif vim.api.nvim_win_get_height(win) ~= height then
44
-
vim.api.nvim_win_set_height(win, height)
45
-
end
46
-
if vim.o.cmdheight ~= height then
47
-
-- Avoid moving the cursor with 'splitkeep' = "screen", and altering the user
48
-
-- configured value with noautocmd.
49
-
vim._with({ noautocmd = true, o = { splitkeep = "screen" } }, function()
50
-
vim.o.cmdheight = height
51
-
end)
52
-
ui2.msg.set_pos()
53
-
end
54
-
end
55
-
56
---@class artio.View
57
---@field picker artio.Picker
58
---@field closed boolean
···
169
self:hlselect()
170
end
171
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
172
---@param predicted? integer The predicted height of the cmdline window
173
function View:updatewinheight(predicted)
174
local height = math.max(1, predicted or vim.api.nvim_win_text_height(ui2.wins.cmd, {}).all)
175
height = math.min(height, self.win.height)
176
-
win_config(ui2.wins.cmd, false, height)
177
end
178
179
function View:saveview()
···
391
clear(cmdline.prompt)
392
393
cmdline.prompt, cmdline.level = false, 0
394
-
win_config(ui2.wins.cmd, true, ui2.cmdheight)
395
end
396
397
function View:trigger_show()
···
32
33
local prompt_hl_id = vim.api.nvim_get_hl_id_by_name("ArtioPrompt")
34
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
35
---@class artio.View
36
---@field picker artio.Picker
37
---@field closed boolean
···
148
self:hlselect()
149
end
150
151
+
--- Set the 'cmdheight' and cmdline window height. Reposition message windows.
152
+
---
153
+
---@param win integer Cmdline window in the current tabpage.
154
+
---@param hide boolean Whether to hide or show the window.
155
+
---@param height integer (Text)height of the cmdline window.
156
+
function View:win_config(win, hide, height)
157
+
if ui2.cmdheight == 0 and vim.api.nvim_win_get_config(win).hide ~= hide then
158
+
vim.api.nvim_win_set_config(win, { hide = hide, height = not hide and height or nil })
159
+
elseif vim.api.nvim_win_get_height(win) ~= height then
160
+
vim.api.nvim_win_set_height(win, height)
161
+
end
162
+
if vim.o.cmdheight ~= height then
163
+
-- Avoid moving the cursor with 'splitkeep' = "screen", and altering the user
164
+
-- configured value with noautocmd.
165
+
vim._with({ noautocmd = true, o = { splitkeep = "screen" } }, function()
166
+
vim.o.cmdheight = height
167
+
end)
168
+
ui2.msg.set_pos()
169
+
end
170
+
end
171
+
172
---@param predicted? integer The predicted height of the cmdline window
173
function View:updatewinheight(predicted)
174
local height = math.max(1, predicted or vim.api.nvim_win_text_height(ui2.wins.cmd, {}).all)
175
height = math.min(height, self.win.height)
176
+
self:win_config(ui2.wins.cmd, false, height)
177
end
178
179
function View:saveview()
···
391
clear(cmdline.prompt)
392
393
cmdline.prompt, cmdline.level = false, 0
394
+
self:win_config(ui2.wins.cmd, true, ui2.cmdheight)
395
end
396
397
function View:trigger_show()