-
Notifications
You must be signed in to change notification settings - Fork 29
Idea: Offering VSCode Snippets #140
Description
As suggested by @jessebraham in the last community meeting, adding more and more options will make the template (even) harder to maintain and we probably should only generate a minimal project
As @MabezDev mentioned the thing users are struggling the most with is choosing the needed dependencies (and features) - so we probably should generate Cargo.toml even for more advanced configurations (embassy, wifi, ble etc.)
One thing that came to my mind is we could still support at least VSCode users by providing snippets (see https://code.visualstudio.com/docs/editor/userdefinedsnippets) - and even add more convenience
e.g. adding ./.vscode/rust.code-snippets like this
{
"Construct SPI": {
"prefix": "setup_spi",
"body": [
"//use hal::{IO, spi::{master::Spi, SpiMode}};",
"let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);",
"let sclk = io.pins.gpio$1;",
"let miso = io.pins.gpio$2;",
"let mosi = io.pins.gpio$3;",
"let cs = io.pins.gpio$4;",
"",
"let mut spi = Spi::new(peripherals.SPI2, 100u32.kHz(), SpiMode::Mode0, &clocks).with_pins(",
" Some(sclk),",
" Some(mosi),",
" Some(miso),",
" Some(cs),",
");"
],
"description": "Setup SPI"
}
}
Would give the user an easy way to create an SPI instance. Since snippets are not very powerful, they still need to figure out the right imports - we could just add a local use statement or (like in this very simple example) a commented out use statement which users can manually copy (or remove). Or don't do that and let the user use the quick-fix feature.
We could also have snippets to add dependencies to Cargo.toml instead of generating it (e.g. a snippet to add embassy or esp-wifi)
This way we could also add more elaborate snippets like setting up wifi, ble etc.
But I'm not sure if this is really a very useful thing or just sounds good in my head. I'm also not sure which snippets to include (for me I always have to look up how to setup some peripherals but maybe that's just me)
Downsides of this
- we cannot verify the snippets in CI
- needs some maintenance whenever there are breaking API changes
- might clutter the CTRL+SPACE code completion if we have a lot of these snippets
Metadata
Metadata
Assignees
Labels
Type
Projects
Status