Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add RustOpenDocs command #1921

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions lua/lspconfig/server_configurations/rust_analyzer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ local function reload_workspace(bufnr)
end)
end

local function open_docs(bufnr)
bufnr = util.validate_bufnr(bufnr)
vim.lsp.buf_request(bufnr, 'experimental/externalDocs', vim.lsp.util.make_position_params(), function(err, url)
if err then
error(tostring(err))
else
vim.fn['netrw#BrowseX'](url, 0)
end
end)
end

return {
default_config = {
cmd = { 'rust-analyzer' },
Expand Down Expand Up @@ -63,6 +74,12 @@ return {
end,
description = 'Reload current cargo workspace',
},
RustOpenDocs = {
function()
open_docs(0)
end,
description = 'Open documentation for the symbol under the cursor in default browser',
},
},
docs = {
description = [[
Expand Down