Skip to content

Commit 5d3f834

Browse files
committed
Add rust-analyzer notes to quick-start.rst
Signed-off-by: Adam Bratschi-Kaye <[email protected]>
1 parent 30d13c6 commit 5d3f834

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,6 @@ x509.genkey
162162

163163
# Documentation toolchain
164164
sphinx_*/
165+
166+
# Rust analyzer configuration
167+
/rust-project.json

Documentation/rust/quick-start.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,23 @@ the component manually::
145145
The standalone installers also come with ``rustdoc``.
146146

147147

148+
rust-analyzer
149+
*************
150+
151+
The `rust-analyzer <https://rust-analyzer.github.io/>`_ language server can
152+
be used with many editors to enable syntax highlighting, completion, go to
153+
definition, and other features.
154+
155+
``rust-analyzer`` will need to be
156+
`configured <https://rust-analyzer.github.io/manual.html#non-cargo-based-projects>`_
157+
to work with the kernel by adding a ``rust-project.json`` file in the root folder.
158+
The example ``Documentation/rust/rust-project.json`` can
159+
be used after updating ``sysroot_src`` and including the relevant modules.
160+
The path to ``sysroot_src`` is given by::
161+
162+
$(rustc --print sysroot)/lib/rustlib/src/rust/library
163+
164+
148165
Configuration
149166
-------------
150167

Documentation/rust/rust-project.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"sysroot_src": <path-to-sysroot-source>,
3+
"crates": [
4+
{
5+
"root_module": "rust/module.rs",
6+
"edition": "2018",
7+
"deps": []
8+
},
9+
{
10+
"root_module": "rust/kernel/lib.rs",
11+
"edition": "2018",
12+
"deps": [
13+
{
14+
"crate": 0,
15+
"name": "module"
16+
}
17+
]
18+
},
19+
{
20+
"root_module": <path-to-module>,
21+
"edition": "2018",
22+
"deps": [
23+
{
24+
"crate": 0,
25+
"name": "module"
26+
},
27+
{
28+
"crate": 1,
29+
"name": "kernel"
30+
}
31+
]
32+
},
33+
<...entries for other modules...>
34+
]
35+
}

0 commit comments

Comments
 (0)