From d47c320593e87f0dea4da4704bd29740a80ad49b Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Wed, 8 Nov 2023 22:12:45 +0800 Subject: [PATCH] feat: add default option for popup mode --- README.md | 9 +++++++++ lua/hurl/init.lua | 7 +++++++ lua/hurl/popup.lua | 11 +++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fe36e1a..7078082 100644 --- a/README.md +++ b/README.md @@ -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', diff --git a/lua/hurl/init.lua b/lua/hurl/init.lua index 5881781..dd4f8e2 100644 --- a/lua/hurl/init.lua +++ b/lua/hurl/init.lua @@ -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' }, diff --git a/lua/hurl/popup.lua b/lua/hurl/popup.lua index 13182a1..8b20b82 100644 --- a/lua/hurl/popup.lua +++ b/lua/hurl/popup.lua @@ -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 = { @@ -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)