diff --git a/README.md b/README.md index 45cdb6b..7d59b67 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,12 @@ Add the following configuration to your Neovim setup with [lazy.nvim](https://gi '-q', }, }, + -- Default mappings for the response popup or split views + mappings = { + close = 'q', -- Close the response popup or split view + next_panel = '', -- Move to the next response popup window + prev_panel = '', -- Move to the previous response popup window + }, }, keys = { -- Run API request diff --git a/doc/hurl.nvim.txt b/doc/hurl.nvim.txt index 25a6671..e2f4252 100644 --- a/doc/hurl.nvim.txt +++ b/doc/hurl.nvim.txt @@ -77,6 +77,12 @@ Add the following configuration to your Neovim setup with lazy.nvim '-q', }, }, + -- Default mappings for the response popup or split views + mappings = { + close = 'q', -- Close the response popup or split view + next_panel = '', -- Move to the next response popup window + prev_panel = '', -- Move to the previous response popup window + }, }, keys = { -- Run API request @@ -337,13 +343,16 @@ DEFAULT KEY MAPPINGS *hurl.nvim-default-key-mappings* `hurl.nvim` comes with some default key mappings to streamline your workflow: -- `q`: Close the current popup window. +- `q`: Close the current popup window or split. - ``: Switch to the next popup window. - ``: Switch to the previous popup window. These key mappings are active within the popup windows that `hurl.nvim` displays. +The mappings can be customized in the configuration table passed to the setup +function. + CONFIGURATION *hurl.nvim-configuration* @@ -396,6 +405,11 @@ CONFIGURATION *hurl.nvim-configuration* '-q', }, }, + mappings = { + close = 'q', + next_panel = '', + prev_panel = '', + }, } < @@ -420,6 +434,9 @@ To apply these configurations, include them in your Neovim setup like this: '-q', }, }, + mappings = { + close = '', + }, }) < diff --git a/lua/hurl/init.lua b/lua/hurl/init.lua index 88f0370..d5594e2 100644 --- a/lua/hurl/init.lua +++ b/lua/hurl/init.lua @@ -45,6 +45,12 @@ local default_config = { '-q', }, }, + -- Default mappings for the response popup or split views + mappings = { + close = 'q', -- Close the response popup or split view + next_panel = '', -- Move to the next response popup window + prev_panel = '', -- Move to the previous response popup window + }, } --- Global configuration for entire plugin, easy to access from anywhere _HURL_GLOBAL_CONFIG = default_config @@ -60,7 +66,7 @@ function M.setup(options) options.env_file = { options.env_file } end - _HURL_GLOBAL_CONFIG = vim.tbl_extend('force', _HURL_GLOBAL_CONFIG, options or default_config) + _HURL_GLOBAL_CONFIG = vim.tbl_deep_extend('force', _HURL_GLOBAL_CONFIG, options or default_config) require('hurl.main').setup() end diff --git a/lua/hurl/popup.lua b/lua/hurl/popup.lua index 7ac40f4..3f9031a 100644 --- a/lua/hurl/popup.lua +++ b/lua/hurl/popup.lua @@ -62,25 +62,25 @@ M.show = function(data, type) end -- Map q to quit - popups.top:map('n', 'q', function() + popups.top:map('n', _HURL_GLOBAL_CONFIG.mappings.close, function() quit() end) - popups.bottom:map('n', 'q', function() + popups.bottom:map('n', _HURL_GLOBAL_CONFIG.mappings.close, function() quit() end) -- Map to next popup - popups.top:map('n', '', function() + popups.top:map('n', _HURL_GLOBAL_CONFIG.mappings.next_panel, function() vim.api.nvim_set_current_win(popups.bottom.winid) end) - popups.bottom:map('n', '', function() + popups.bottom:map('n', _HURL_GLOBAL_CONFIG.mappings.next_panel, function() vim.api.nvim_set_current_win(popups.top.winid) end) -- Map to previous popup - popups.top:map('n', '', function() + popups.top:map('n', _HURL_GLOBAL_CONFIG.mappings.prev_panel, function() vim.api.nvim_set_current_win(popups.bottom.winid) end) - popups.bottom:map('n', '', function() + popups.bottom:map('n', _HURL_GLOBAL_CONFIG.mappings.prev_panel, function() vim.api.nvim_set_current_win(popups.top.winid) end) diff --git a/lua/hurl/split.lua b/lua/hurl/split.lua index 859ee33..a23039b 100644 --- a/lua/hurl/split.lua +++ b/lua/hurl/split.lua @@ -81,7 +81,7 @@ M.show = function(data, type) vim.cmd('q') split:unmount() end - split:map('n', 'q', function() + split:map('n', _HURL_GLOBAL_CONFIG.mappings.close, function() quit() end) end