Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,6 @@ x509.genkey

# Documentation toolchain
sphinx_*/

# Rust analyzer configuration
/rust-project.json
17 changes: 17 additions & 0 deletions Documentation/rust/quick-start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ the component manually::
The standalone installers also come with ``rustdoc``.


rust-analyzer
*************

The `rust-analyzer <https://rust-analyzer.github.io/>`_ language server can
be used with many editors to enable syntax highlighting, completion, go to
definition, and other features.

``rust-analyzer`` will need to be
`configured <https://rust-analyzer.github.io/manual.html#non-cargo-based-projects>`_
to work with the kernel by adding a ``rust-project.json`` file in the root folder.
The example ``Documentation/rust/rust-project.json`` can
be used after updating ``sysroot_src`` and including the relevant modules.
The path to ``sysroot_src`` is given by::

$(rustc --print sysroot)/lib/rustlib/src/rust/library

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newline (I used 2 between sections).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was thinking one after the code block and two additional...


Configuration
-------------

Expand Down
35 changes: 35 additions & 0 deletions Documentation/rust/rust-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"sysroot_src": <path-to-sysroot-source>,
"crates": [
{
"root_module": "rust/module.rs",
"edition": "2018",
"deps": []
},
{
"root_module": "rust/kernel/lib.rs",
"edition": "2018",
"deps": [
{
"crate": 0,
"name": "module"
}
]
},
{
"root_module": <path-to-module>,
"edition": "2018",
"deps": [
{
"crate": 0,
"name": "module"
},
{
"crate": 1,
"name": "kernel"
}
]
},
<...entries for other modules...>
]
}