rest.nvim
rest.nvim copied to clipboard
packer: opt=true causes rest.nvim to fail
I set up rest.nvim as an optional dependency like this:
use({
"NTBBloodbath/rest.nvim",
requires = { "nvim-lua/plenary.nvim" },
opt = true,
ft = { "http" },
config = function()
require("rest-nvim").setup({
result_split_horizontal = false,
})
vim.cmd([[
au FileType http nmap <buffer> <silent> <C-j> <Plug>RestNvim
]])
end,
})
When I open a file, set the file type to http
and press <C-j>
I get the following error:
Error executing luv callback:
...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:614: ENOENT: no such file or directory: /tmp/plenary_curl_b3524790.headers
With opt=false
everything works fine.
Hey, this is being a bit odd to me because the error comes from plenary so I don't know exactly what's going on under the hood :eyes:
Also there's no need for opt = true
if you're already using ft
, unless you also want to lazy-load plenary but still this shouldn't be a problem hmm do you have any ftdetect file to automatically detect http files?
Yes, good point that opt = true
is optional in this case. I have an autocommand that sets the http file type for file names matching *.http
.
I also find it weird that the error comes from plenary. Are you able to reproduce the error?
I am not exactly sure what you are trying to do here...but maybe this helps a bit. I don't use Packer but still have setup rest.nvim as an optional plugin. Don't really know if this improves loading time or performance. It's mere an experiment:
Install the plugin with Paq, Packer should be quite similar I guess:
require("paq-nvim")({
....
{ "NTBBloodbath/rest.nvim", opt = true },
....
})
Then in a module required from init.lua:
vim.cmd([[ au BufEnter *.http call v:lua.require("plugins.rest").loadRestClient() ]])
local M = {}
function M.loadRestClient()
if vim.g.loaded_rest_nvim ~= 1 then
vim.cmd([[ packadd rest.nvim ]])
require("rest-nvim").setup({
result_split_horizontal = false,
skip_ssl_verification = false,
highlight = { enabled = true, timeout = 150 },
jump_to_request = false,
})
vim.api.nvim_set_keymap("n", "<leader>r", "<Plug>RestNvim", { nowait = true })
vim.api.nvim_set_keymap("n", "<leader>pr", "<Plug>RestNvimPreview", { nowait = true })
vim.cmd("command! RestNvim lua require('rest-nvim').run()")
vim.cmd("command! RestNvimPreview lua require('rest-nvim').run(true)")
end
end
return M
This seems to load the plugin correctly when opening a .http file. For other files the commands and mappings are not available.
feel free to reopen if you still have the issue.