Closed Flamme13 closed 1 month ago
Can you post your config?
My config for the plugin:
return {
"mistweaverco/kulala.nvim",
event = "VeryLazy",
config = function()
require("kulala").setup({
default_view = "headers_body",
})
vim.api.nvim_set_keymap("n", "<C-\\>", ":lua require('kulala').run()<CR>", { noremap = true, silent = true })
end,
}
I didn't change anything in the config, but after the update this error started to appear.
==============================================================================
kulala: require("kulala.health").check()
- {kulala.nvim} version 3.7.0
- OK {curl} found
Checking formatters ~
- WARNING {text/html} formatter not found
- OK {application/json} formatter: jq .
- WARNING {application/xml} formatter not found
==============================================================================
What does lua require("kulala").version()
print?
And, can you also post a basic stripped down version of the .http file you try to run requests on?
Same issue
trying
GET http://localhost:3000/config
Oh, Shit, I think I know the issue. I think fenced code block support might have broken it for you.
When you're in the http file, what does :set buftype
give you?
It is not set
Can you try to set it to http and run a request?
Actually it seems i just needed to set filetype
It works with
filetype=http
buftype=
setting filetype=""
raises the OP error
Yeah, will push a fix. Then this is due to the newly introduced fenced code block support
Thanks for catching this! ❤️🙏🏾
Fix should be in main now. Re-open if the issue still persists, please.
@gorillamoe I can confirm that this issue persists on the main
branch at the time of writing.
As a workaround for the time being, I've ended up adding the following keymap to the plugin configuration (LazyVim):
{
keys = {
{ "<leader>RN", "<cmd>enew<cr><cmd>set filetype=http<cr>", desc = "Scratch buffer" }
}
}
or, if you'd rather stick to pure Lua:
{
keys = {
{ "<leader>RS", desc = "Scratch buffer",
function()
vim.cmd.enew()
vim.bo.filetype = "http"
end
}
}
}
Ah, there's also the scratchpad method!
require("kulala").scratchpad()
So just to make I understand this correctly, the issue is that you open a buffer which has no file type set and the run kulala.run right?
We should catch that error and display an error message, but it won't work, because kulala runs either on http and rest files (with the file type set) or anything else within fenced code blocks.
The only exception to this is the scratchpad() function from kulala itself, which takes care setting the correct file type.
So to sum it up: kulala only runs on files with either http or rest as file type or the scratchpad. For anything else Kulala assumes you must be in a file with a fenced code block (like markdown files ..)
So just to make I understand this correctly, the issue is that you open a buffer which has no file type set and the run kulala.run right?
Yes, that's right. I agree about the need to handle this edge case gracefully somehow.
I've settled for these keymaps in the end and I'm unlikely to tweak them any further:
keys = {
{ "<leader>Ra", desc = "Open scratchpad",
function()
require("kulala").scratchpad()
end,
{ noremap = true, silent = true }
},
{ "<leader>Rb", desc = "Open scratchpad (empty)",
function()
vim.cmd.edit(require("kulala.globals").SCRATCHPAD_ID)
vim.bo.buftype = "nofile"
vim.bo.filetype = "http"
end,
{ noremap = true, silent = true }
},
{ "<leader>Rc", desc = "Close scratchpad",
function()
require("kulala").close()
vim.cmd.bdelete { args = { require("kulala.globals").SCRATCHPAD_ID }, bang = true }
end,
{ noremap = true, silent = true }
},
}
Later, I may also try executing a request from within a fenced code block.
Tell me how can I solve this problem. Everything was fine before, but now when I try to make a request, an error appears: