Closed augustocdias closed 3 months ago
can you test this handler if it works for you? I'm not really using rust so I have little to no knowledge š
It works for the most important use cases. You can point a dependency to a git repo, but you have the url there and calling gx on the url goes to the url instead of crates.io, so I think this is not important.
i'm not sure if i understand you correctly. So for example you have a dependency like the following:
regex = { git = "https://github.com/rust-lang/regex.git" }
if you press gx
and your cursor is on the regex part you go to crates.io/crates/regex and if you press gx
on the url part you go to the github repo - isnāt that supposed to happen?
btw please provide me with edge cases where gx
doesn't work. The more data I have, the better the tool will become š
i'm not sure if i understand you correctly. So for example you have a dependency like the following:
regex = { git = "https://github.com/rust-lang/regex.git" }
if you press
gx
and your cursor is on the regex part you go to crates.io/crates/regex and if you pressgx
on the url part you go to the github repo - isnāt that supposed to happen?
This is what I expected to happen yes. Though someone might have a different opinion. Since the dependency is pointing to a git repo, someone might expect to gx with the cursor on regex
and go to the github url instead of crates.io
btw please provide me with edge cases where gx doesn't work. The more data I have, the better the tool will become š
There are other ways to declare dependencies:
[patch.crates-io.openmls]
package = "openmls"
git = "https://github.com/wireapp/openmls"
branch = "feat/rfc9420"
If you want to follow the current behavior, calling Browse
inside the brackets could got to crates.io too. The regex might be tricky though. You can see more examples here: https://github.com/wireapp/core-crypto/blob/develop/Cargo.toml And here: https://github.com/wireapp/core-crypto/blob/develop/crypto/Cargo.toml#L58-L63
Hmm.. I donāt think it would be a good idea to merge this hacky handler and I also donāt know how to improve this (I already tried something with treesitter, but it didnāt work out). So my suggestion is to abandon this PR until I (or someone else) have the time and resources to properly implement this.
I think what you already implemented will be helpful for 99% of the time and users.
Maybe add a disclaimer in the readme about this "limitation" and merge?
Hm, as I said I'm not fully satisfied with the current behavior, so I donāt like to merge this PR. But you can add a custom rust handler (possible since #49) for this specific use case. E.g.:
require("lazy").setup({
{
dir = "~/jam-dev/home/gx.nvim",
keys = { { "gx", "<cmd>Browse<cr>", mode = { "n", "x" }} },
cmd = { "Browse" },
init = function ()
vim.g.netrw_nogx = 1 -- disable netrw gx
end,
config = function() require("gx").setup{
handlers = {
rust = { -- custom handler to open rust's cargo packages
filetype = { "toml" },
filename = "Cargo.toml",
handle = function(mode, line, _)
local crate = require("gx.helper").find(line, mode, "(%w+)%s-=%s")
if crate then
return "https://crates.io/crates/" .. crate
end
end,
},
},
} end,
},
})
Similar to package.json it would be nice to support Ruts's cargo dependencies. Opening in either crates.io or docs.rs