From 6be1504c6217f7b6463fce9a1abd6560e126e63b Mon Sep 17 00:00:00 2001 From: Adam Bratschi-Kaye Date: Tue, 20 Apr 2021 22:11:05 +0200 Subject: [PATCH] docs: rust: add rust-analyzer notes to quick-start.rst Include an example JSON configuration too and, since users will likely copy it to the root folder and customize it, add it to `.gitignore` too. Signed-off-by: Adam Bratschi-Kaye [re-worded] Signed-off-by: Miguel Ojeda --- .gitignore | 3 +++ Documentation/rust/quick-start.rst | 17 ++++++++++++++ Documentation/rust/rust-project.json | 35 ++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 Documentation/rust/rust-project.json diff --git a/.gitignore b/.gitignore index 6ba4f516f46ce..da64dc7f26e3c 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,6 @@ x509.genkey # Documentation toolchain sphinx_*/ + +# Rust analyzer configuration +/rust-project.json diff --git a/Documentation/rust/quick-start.rst b/Documentation/rust/quick-start.rst index 42367e4365c3e..e78125d9289bd 100644 --- a/Documentation/rust/quick-start.rst +++ b/Documentation/rust/quick-start.rst @@ -145,6 +145,23 @@ the component manually:: The standalone installers also come with ``rustdoc``. +rust-analyzer +************* + +The `rust-analyzer `_ 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 `_ +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 + + Configuration ------------- diff --git a/Documentation/rust/rust-project.json b/Documentation/rust/rust-project.json new file mode 100644 index 0000000000000..e0f64b8dec1e3 --- /dev/null +++ b/Documentation/rust/rust-project.json @@ -0,0 +1,35 @@ +{ + "sysroot_src": , + "crates": [ + { + "root_module": "rust/module.rs", + "edition": "2018", + "deps": [] + }, + { + "root_module": "rust/kernel/lib.rs", + "edition": "2018", + "deps": [ + { + "crate": 0, + "name": "module" + } + ] + }, + { + "root_module": , + "edition": "2018", + "deps": [ + { + "crate": 0, + "name": "module" + }, + { + "crate": 1, + "name": "kernel" + } + ] + }, + <...entries for other modules...> + ] +} \ No newline at end of file -- 2.51.0