Skip to content

Commit

Permalink
Merge branch 'main' into feature/url-show-and-repeat-history
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn authored Oct 22, 2024
2 parents f817207 + bd7f6b6 commit 0118867
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Add the following configuration to your Neovim setup with [lazy.nvim](https://gi
{ "<leader>A", "<cmd>HurlRunner<CR>", desc = "Run All requests" },
{ "<leader>a", "<cmd>HurlRunnerAt<CR>", desc = "Run Api request" },
{ "<leader>te", "<cmd>HurlRunnerToEntry<CR>", desc = "Run Api request to entry" },
{ "<leader>tE", "<cmd>HurlRunnerToEnd<CR>", desc = "Run Api request from current entry to end" },
{ "<leader>tm", "<cmd>HurlToggleMode<CR>", desc = "Hurl Toggle Mode" },
{ "<leader>tv", "<cmd>HurlVerbose<CR>", desc = "Run Api in verbose mode" },
-- Run Hurl request in visual mode
Expand Down Expand Up @@ -210,6 +211,10 @@ Place your cursor on the line you want to run to that entry and press `<leader>t

Note: it's running from start of file to the selected entry and ignore the remaining of the file. It is useful for debugging purposes.

### Run from current entry to end

Similar to `HurlRunnerToEntry`, we could run from current entry to end of file with `HurlRunnerToEnd` command.

### Toggle Mode

Run `HurlToggleMode` command to toggle between split and popup mode.
Expand Down
9 changes: 8 additions & 1 deletion doc/hurl.nvim.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*hurl.nvim.txt* For NVIM v0.8.0 Last change: 2024 September 30
*hurl.nvim.txt* For NVIM v0.8.0 Last change: 2024 October 22

==============================================================================
Table of Contents *hurl.nvim-table-of-contents*
Expand Down Expand Up @@ -89,6 +89,7 @@ Add the following configuration to your Neovim setup with lazy.nvim
{ "<leader>A", "<cmd>HurlRunner<CR>", desc = "Run All requests" },
{ "<leader>a", "<cmd>HurlRunnerAt<CR>", desc = "Run Api request" },
{ "<leader>te", "<cmd>HurlRunnerToEntry<CR>", desc = "Run Api request to entry" },
{ "<leader>tE", "<cmd>HurlRunnerToEnd<CR>", desc = "Run Api request from current entry to end" },
{ "<leader>tm", "<cmd>HurlToggleMode<CR>", desc = "Hurl Toggle Mode" },
{ "<leader>tv", "<cmd>HurlVerbose<CR>", desc = "Run Api in verbose mode" },
-- Run Hurl request in visual mode
Expand Down Expand Up @@ -277,6 +278,12 @@ Note: it’s running from start of file to the selected entry and ignore the
remaining of the file. It is useful for debugging purposes.


RUN FROM CURRENT ENTRY TO END ~

Similar to `HurlRunnerToEntry`, we could run from current entry to end of file
with `HurlRunnerToEnd` command.


TOGGLE MODE ~

Run `HurlToggleMode` command to toggle between split and popup mode.
Expand Down
17 changes: 17 additions & 0 deletions lua/hurl/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,23 @@ function M.setup()
nargs = '*',
range = true,
})
-- Run from current line/entry to end of file
utils.create_cmd('HurlRunnerToEnd', function(opts)
local is_support_hurl = utils.is_nightly() or utils.is_hurl_parser_available
local result = is_support_hurl and http.find_hurl_entry_positions_in_buffer()
or http.find_http_verb_positions_in_buffer()
if result.current > 0 and result.start_line and result.end_line then
utils.log_info(
'hurl: running request at line ' .. result.start_line .. ' to ' .. result.end_line
)
opts.fargs = opts.fargs or {}
local end_line = vim.api.nvim_buf_line_count(0)
run_at_lines(result.start_line, end_line, opts.fargs)
else
utils.log_info('hurl: no HTTP method found in the current line')
utils.notify('hurl: no HTTP method found in the current line', vim.log.levels.INFO)
end
end, { nargs = '*', range = true })
end

return M

0 comments on commit 0118867

Please sign in to comment.