Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

add RustOpenExternalDocs to open docs for element under the cursor #188

Merged
merged 1 commit into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ RustDebuggables
RustViewCrateGraph
RustReloadWorkspace
RustSSR
RustOpenExternalDocs
```

## Standalone File Support
Expand Down
3 changes: 3 additions & 0 deletions lua/rust-tools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ local function setup_commands()
RustSetInlayHints = {
require("rust-tools.inlay_hints").set_inlay_hints,
},
RustOpenExternalDocs= {
require("rust-tools.external_docs").open_external_docs,
},
RustDisableInlayHints = {
require("rust-tools.inlay_hints").disable_inlay_hints,
},
Expand Down
17 changes: 17 additions & 0 deletions lua/rust-tools/external_docs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local M = {}
local utils = require("rust-tools.utils.utils")

function M.open_external_docs()
utils.request(
0,
"experimental/externalDocs",
vim.lsp.util.make_position_params(),
function(_, url)
if url then
vim.fn["netrw#BrowseX"](url, 0)
syphar marked this conversation as resolved.
Show resolved Hide resolved
end
end
)
end

return M