Make Popups Configurable (#129)

This makes the popups in the plugin (those for editing and creating comments, replies, the pipeline, etc) configurable. Users can change the default width, height, transparency, and border properties, and set overrides per popup.
This commit is contained in:
Jakub F. Bortlík
2023-12-05 14:06:32 +01:00
committed by GitHub
parent 02db3e4b0e
commit cc68476b15
8 changed files with 75 additions and 37 deletions

View File

@@ -344,8 +344,16 @@ M.jump_to_buffer = function(bufnr, line_number)
vim.api.nvim_win_set_cursor(0, { line_number, 0 })
end
M.create_popup_state = function(title, width, height)
return {
---Get the popup view_opts
---@param title string The string to appear on top of the popup
---@param settings table User defined popup settings
---@param width string Override default width
---@param height string Override default height
---@return table
M.create_popup_state = function(title, settings, width, height)
local default_settings = require("gitlab.state").settings.popup
local user_settings = settings or {}
local view_opts = {
buf_options = {
filetype = "markdown",
},
@@ -353,17 +361,19 @@ M.create_popup_state = function(title, width, height)
enter = true,
focusable = true,
border = {
style = "rounded",
style = user_settings.border or default_settings.border,
text = {
top = title,
},
},
position = "50%",
size = {
width = width,
height = height,
width = user_settings.width or width or default_settings.width,
height = user_settings.height or height or default_settings.height,
},
opacity = user_settings.opacity or default_settings.opacity,
}
return view_opts
end
M.read_file = function(file_path)