]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
docs: rust: add rust-analyzer notes to quick-start.rst
authorAdam Bratschi-Kaye <ark.email@gmail.com>
Tue, 20 Apr 2021 20:11:05 +0000 (22:11 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 27 Apr 2021 03:06:13 +0000 (05:06 +0200)
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 <ark.email@gmail.com>
[re-worded]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
.gitignore
Documentation/rust/quick-start.rst
Documentation/rust/rust-project.json [new file with mode: 0644]

index 6ba4f516f46ce27a110cb3b8031843f8610e9aae..da64dc7f26e3c26114d92d37c59beb762d786fd6 100644 (file)
@@ -159,3 +159,6 @@ x509.genkey
 
 # Documentation toolchain
 sphinx_*/
+
+# Rust analyzer configuration
+/rust-project.json
index 42367e4365c3e8611f19dd472386c520c54ea133..e78125d9289bd691695c6eded248204cbb1a25d2 100644 (file)
@@ -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
+
+
 Configuration
 -------------
 
diff --git a/Documentation/rust/rust-project.json b/Documentation/rust/rust-project.json
new file mode 100644 (file)
index 0000000..e0f64b8
--- /dev/null
@@ -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...>
+    ]
+}
\ No newline at end of file