diff --git a/README.md b/README.md index e61a726..304bbbb 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Add the following configuration to your Neovim setup with [lazy.nvim](https://gi { "A", "HurlRunner", desc = "Run All requests" }, { "a", "HurlRunnerAt", desc = "Run Api request" }, { "te", "HurlRunnerToEntry", desc = "Run Api request to entry" }, + { "tE", "HurlRunnerToEnd", desc = "Run Api request from current entry to end" }, { "tm", "HurlToggleMode", desc = "Hurl Toggle Mode" }, { "tv", "HurlVerbose", desc = "Run Api in verbose mode" }, -- Run Hurl request in visual mode @@ -210,6 +211,10 @@ Place your cursor on the line you want to run to that entry and press `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. diff --git a/doc/hurl.nvim.txt b/doc/hurl.nvim.txt index 9df8876..73dec2f 100644 --- a/doc/hurl.nvim.txt +++ b/doc/hurl.nvim.txt @@ -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* @@ -89,6 +89,7 @@ Add the following configuration to your Neovim setup with lazy.nvim { "A", "HurlRunner", desc = "Run All requests" }, { "a", "HurlRunnerAt", desc = "Run Api request" }, { "te", "HurlRunnerToEntry", desc = "Run Api request to entry" }, + { "tE", "HurlRunnerToEnd", desc = "Run Api request from current entry to end" }, { "tm", "HurlToggleMode", desc = "Hurl Toggle Mode" }, { "tv", "HurlVerbose", desc = "Run Api in verbose mode" }, -- Run Hurl request in visual mode @@ -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. diff --git a/lua/hurl/main.lua b/lua/hurl/main.lua index 6ebec58..9412362 100644 --- a/lua/hurl/main.lua +++ b/lua/hurl/main.lua @@ -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