jellydn / hurl.nvim

Hurl.nvim is a Neovim plugin designed to run HTTP requests directly from `.hurl` files. Elevate your API development workflow by executing and viewing responses without leaving your editor.
https://gyazo.com/19492e8b5366cec3f22d5fd97a63f37a
MIT License
122 stars 13 forks source link

Features: Change variable values as buffers #155

Open bartoszb-rgb opened 1 month ago

bartoszb-rgb commented 1 month ago

Details

It would be nice if there would be possibility to edit variables as buffer. Currently you can edit the Manage buffer, but after close, the change is forgotten.

Usually I need to edit the variable, copy it and then press e to paste it correctly... It is kinda annoying

Checklist - [X] Modify `lua/hurl/main.lua` ✓ https://github.com/jellydn/hurl.nvim/commit/625db53ab5c2926c397930c29335d67c170deb94 [Edit](https://github.com/jellydn/hurl.nvim/edit/sweep/features_change_variable_values_as_buffe_7d067/lua/hurl/main.lua) - [X] Modify `lua/hurl/main.lua` ✓ https://github.com/jellydn/hurl.nvim/commit/625db53ab5c2926c397930c29335d67c170deb94 [Edit](https://github.com/jellydn/hurl.nvim/edit/sweep/features_change_variable_values_as_buffe_7d067/lua/hurl/main.lua) - [X] Modify `lua/hurl/main.lua` ✓ https://github.com/jellydn/hurl.nvim/commit/625db53ab5c2926c397930c29335d67c170deb94 [Edit](https://github.com/jellydn/hurl.nvim/edit/sweep/features_change_variable_values_as_buffe_7d067/lua/hurl/main.lua)
sweep-ai[bot] commented 1 month ago

🚀 Here's the PR! #157

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 9833843cdb)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/jellydn/hurl.nvim/blob/fccd096f555864d3de1f103622c7020224ba6246/lua/hurl/main.lua#L1-L551

Step 2: ⌨️ Coding

-- Add e key binding to edit the variable text_popup:map('n', 'e', function() local line = vim.api.nvim_get_current_line() local var_name = line:match('^(.-) =') if var_name then local new_value = vim.fn.input('Enter new value for ' .. var_name .. ': ') _HURL_GLOBAL_CONFIG.global_vars[var_name] = new_value vim.api.nvim_set_current_line(var_name .. ' = ' .. new_value) end end) -- Add e key binding to edit the variable inline in the buffer text_popup:map('n', 'e', function() local line = vim.api.nvim_get_current_line() local var_name = line:match('^(.-) =') if var_name then vim.api.nvim_input('A') end end)

end, { nargs = '*', range = true, }) end, { nargs = '*', range = true, on_write = function() local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) for _, line in ipairs(lines) do local var_name, var_value = line:match('^(.-) = (.+)$') if var_name and var_value then _HURL_GLOBAL_CONFIG.global_vars[var_name] = var_value end end end, })

vim.api.nvim_buf_set_lines(0, line_position, -1, false, { var_name .. ' = ' .. var_value }) end) vim.api.nvim_buf_set_lines(0, line_position, -1, false, { var_name .. ' = ' .. var_value }) -- Refresh the buffer display vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.tbl_map(function(key) return key .. ' = ' .. _HURL_GLOBAL_CONFIG.global_vars[key] end, vim.tbl_keys(_HURL_GLOBAL_CONFIG.global_vars))) end)


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/features_change_variable_values_as_buffe_dcabf.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.