From 426c45a68752da0f42c411aad6cdb30bc01d8162 Mon Sep 17 00:00:00 2001 From: Oli Dacombe Date: Sun, 12 Nov 2023 21:08:04 +0000 Subject: [PATCH 1/2] Allow overriding url opener (if you don't use `netrw` for example) --- lua/rust-tools/config.lua | 5 +++++ lua/rust-tools/external_docs.lua | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/rust-tools/config.lua b/lua/rust-tools/config.lua index 2854138..d64b16c 100644 --- a/lua/rust-tools/config.lua +++ b/lua/rust-tools/config.lua @@ -21,6 +21,11 @@ local defaults = { -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. reload_workspace_from_cargo_toml = true, + -- function for opening external URLs + open_url = function(url) + vim.fn["netrw#BrowseX"](url, 0) + end, + -- These apply to the default RustSetInlayHints command inlay_hints = { -- automatically set inlay hints (type hints) diff --git a/lua/rust-tools/external_docs.lua b/lua/rust-tools/external_docs.lua index 20f1dcd..47da51d 100644 --- a/lua/rust-tools/external_docs.lua +++ b/lua/rust-tools/external_docs.lua @@ -9,7 +9,7 @@ function M.open_external_docs() vim.lsp.util.make_position_params(), function(_, url) if url then - vim.fn["netrw#BrowseX"](url, 0) + rt.config.options.tools.open_url(url) end end ) From 0224f0d4650da2648850c0b320614a36d642b8c1 Mon Sep 17 00:00:00 2001 From: Oli Dacombe Date: Sun, 12 Nov 2023 21:09:06 +0000 Subject: [PATCH 2/2] Add option to `README` defaults documentation --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7edaa8f..4681d7b 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,11 @@ local opts = { -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. reload_workspace_from_cargo_toml = true, + -- function for opening external URLs + open_url = function(url) + vim.fn["netrw#BrowseX"](url, 0) + end, + -- These apply to the default RustSetInlayHints command inlay_hints = { -- automatically set inlay hints (type hints)