Skip to content

Commit

Permalink
feat: add default option for popup mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Nov 8, 2023
1 parent e3c3ca2 commit d47c320
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,18 @@ local default_config = {

-- Set the display mode for the response: 'split' or 'popup'
mode = 'split',

-- Split settings
split_position = "right",
split_size = "50%",

-- Popup settings
popup_position = '50%',
popup_size = {
width = 80,
height = 40,
},

-- Default environment file name
env_file = 'vars.env',

Expand Down
7 changes: 7 additions & 0 deletions lua/hurl/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
local default_config = {
debug = false,
mode = 'split',
-- Default split options
split_position = 'right',
split_size = '50%',
-- Default popup options
popup_position = '50%',
popup_size = {
width = 80,
height = 40,
},
env_file = 'vars.env',
formatters = {
json = { 'jq' },
Expand Down
11 changes: 5 additions & 6 deletions lua/hurl/popup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ local popups = {
local layout = Layout(
{
relative = 'editor',
position = '50%',
size = {
width = 80,
height = 40,
},
position = _HURL_GLOBAL_CONFIG.popup_position,
size = _HURL_GLOBAL_CONFIG.popup_size,
},
Layout.Box({
Layout.Box(popups.top, { size = {
Expand Down Expand Up @@ -90,10 +87,12 @@ M.show = function(data, type)

-- Set content to highlight
vim.api.nvim_buf_set_option(popups.top.bufnr, 'filetype', 'bash')
vim.api.nvim_buf_set_option(popups.bottom.bufnr, 'filetype', type)
-- Add word wrap
vim.api.nvim_buf_set_option(popups.top.bufnr, 'wrap', true)

-- Enable folding for bottom buffer
vim.api.nvim_buf_set_option(popups.bottom.bufnr, 'foldmethod', 'expr')
vim.api.nvim_buf_set_option(popups.bottom.bufnr, 'filetype', type)

-- Add content to the bottom
vim.api.nvim_buf_set_lines(popups.bottom.bufnr, 0, -1, false, content)
Expand Down

0 comments on commit d47c320

Please sign in to comment.