Closed wenjinnn closed 1 month ago
Open the branch in Web Editor • VS Code • Insiders
Open Preview
Latest commit: f2fb792d781cfd8328136f5f73a710faa5c179c7
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/wenjinnn/hurl.nvim/new/main?filename=.changeset/cuddly-ducks-double.md&value=---%0A%22%40fake-scope%2Ffake-pkg%22%3A%20patch%0A---%0A%0Afix(hurl)%3A%20fold%20not%20work%20if%20set%20foldexpr%20to%20%60vim.treesitter.foldexpr()%60%0A)
Your free trial has expired. To keep using Ellipsis, sign up at https://app.ellipsis.dev for $20/seat/month or reach us at help@ellipsis.dev
The recent changes in the lua/hurl/split.lua
file focus on optimizing the buffer options setup within the Split
and M.show
functions. The buf_options
declaration has been moved from the Split
function to a conditional block in M.show
, which now also includes logic to conditionally set the filetype
using edgy.nvim
if available, and then based on the type
parameter.
File Path | Change Summary |
---|---|
lua/hurl/split.lua |
Removed initial buf_options declaration from Split function. Added conditional block in M.show to set filetype using edgy.nvim if available, and then based on the type parameter. |
🐰✨ In code we trust, through changes we grow,
Buffers now smarter, with options in tow.
Edgy and nimble, the filetypes align,
Lua scripts dancing, in harmony they shine.
Hurl’s split evolves, with logic so fine,
A toast to the coders, on this bright design! 🌟
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Authors of pull request: @wenjinnn
Made the setting of the 'filetype' buffer option conditional based on the availability of 'edgy.nvim' and adjusted the timing of setting the filetype to the provided type parameter.
Hi @wenjinnn
Also I was wondering if there have any way to set buf name safety with nui.nvim?
That's exactly what the author answered as below. The usage is correct.
buf_options = { filetype = 'hurl-nvim' },
https://github.com/MunifTanjim/nui.nvim/issues/76#issuecomment-1001358770
Hi @wenjinnn
Also I was wondering if there have any way to set buf name safety with nui.nvim?
That's exactly what the author answered as below. The usage is correct.
buf_options = { filetype = 'hurl-nvim' },
Thanks for reply @jellydn . I think this issue you refers to just explain this PR. set filetype to hurl-nvim
make treesitter parser can't identify which language are in the response buffer (I guess we just can't have filetype 'hurl-nvim' and get treesitter highlight together), the reason that we got treesitter highlight from response buffer is we set filetype to particular language later in show
function:
-- Set content to highlight, refer https://github.com/MunifTanjim/nui.nvim/issues/76#issuecomment-1001358770
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', type)
Although we got treesitter highlight, but we can't get foldlevel calculate by vim.treesitter.foldexpr()
, cause the foldlevel calculate only happens at first filetype setup (Not 100% sure, but this is the result of my test), my configuration was like:
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
Also I was wondering if there have any way to set buf name safety with nui.nvim?
And this is another problem I want to improve yet, just discuss in here. right now the response buffer have no name, it shows like:
I think give a buffer name like 'hurl-response' would be nice, please feel free to correct me.
I think give a buffer name like 'hurl-response' would be nice, please feel free to correct me.
That sounds good @wenjinnn Let's do it. Thanks.
Thanks @wenjinnn LGTM!
One thing I noticed on this PR @wenjinnn the edgy
integration won't work anymore.
{ title = "hurl.nvim", ft = "hurl-nvim", size = { width = 0.4 } },
One thing I noticed on this PR @wenjinnn the
edgy
integration won't work anymore.{ title = "hurl.nvim", ft = "hurl-nvim", size = { width = 0.4 } },
After we have buffer name, this setting could work with edgy.nvim, just a little wordy:
left = {
{
ft = "json",
title = "hurl-response",
},
{
ft = "html",
title = "hurl-response",
},
{
ft = "text",
title = "hurl-response",
},
},
I can update the README, and maybe remove all these lines at https://github.com/jellydn/hurl.nvim/blob/a185094058f75eb7f32ebf69f2dcc3361628290c/lua/hurl/split.lua#L22-L27 , since it not work anymore.
One thing I noticed on this PR @wenjinnn the
edgy
integration won't work anymore.{ title = "hurl.nvim", ft = "hurl-nvim", size = { width = 0.4 } },
After we have buffer name, this setting could work with edgy.nvim, just a little wordy:
left = { { ft = "json", title = "hurl-response", }, { ft = "html", title = "hurl-response", }, { ft = "text", title = "hurl-response", }, },
I can update the README, and maybe remove all these lines at
, since it not work anymore.
Well, that won't work as well. The ft
will move all json/html/text
files to the left. Do you try with https://github.com/folke/edgy.nvim by above setting? @wenjinnn
FYI - Fixed with my commit, here is the working config https://github.com/jellydn/lazy-nvim-ide/blob/main/lua/plugins/extras/hurl.lua
One thing I noticed on this PR @wenjinnn the
edgy
integration won't work anymore.{ title = "hurl.nvim", ft = "hurl-nvim", size = { width = 0.4 } },
After we have buffer name, this setting could work with edgy.nvim, just a little wordy:
left = { { ft = "json", title = "hurl-response", }, { ft = "html", title = "hurl-response", }, { ft = "text", title = "hurl-response", }, },
I can update the README, and maybe remove all these lines at https://github.com/jellydn/hurl.nvim/blob/a185094058f75eb7f32ebf69f2dcc3361628290c/lua/hurl/split.lua#L22-L27
, since it not work anymore.
Well, that won't work as well. The
ft
will move alljson/html/text
files to the left. Do you try with https://github.com/folke/edgy.nvim by above setting? @wenjinnn
Oh sorry for that, I just try it once with edgy.nvim, cuz I don't really use it daily. I have misunderstood the title setting, fortunately we can still achieve this with filter, I do some more test with it, now this should work well:
{
ft = "json",
filter = function(buf)
return vim.fn.bufname(buf) == "hurl-response"
end,
},
{
ft = "html",
filter = function(buf)
return vim.fn.bufname(buf) == "hurl-response"
end,
},
{
ft = "text",
filter = function(buf)
return vim.fn.bufname(buf) == "hurl-response"
end,
},
FYI - Fixed with my commit, here is the working config https://github.com/jellydn/lazy-nvim-ide/blob/main/lua/plugins/extras/hurl.lua
This made fold level computing failed again. but I find a way to compatible with edgy.nvim and the treesitter foldexpr, I'll open another PR.
Set filetype to
hurl-nvim
by default makevim.treesitter.foldexpr()
not work, causes zc zo to fail in response buffer, it happens only on nvim 0.10. this commit check if edgy.nvim exists and then set filetype to hurl-nvim, otherwise just set filetype to input paramtype
.Also I was wondering if there have any way to set buf name safety with nui.nvim?
I tried to use
vim.api.nvim_buf_set_name(split.bufnr, 'hurl-response')
at split.show, but got a error when run a request second time, it seems like bufnr got wrong value or something. I would love to make a PR if I can fix it, right now the split result window have no name, maybe add a name will be nice.Summary by CodeRabbit
edgy.nvim
when available.