diff --git a/pyproject.toml b/pyproject.toml index 797ef53..a5bbb04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "example" +name = "create-python-app" version = "0.0.1" description = "" authors = [ diff --git a/src/python.rs b/src/python.rs index c97e10e..49fe0dc 100644 --- a/src/python.rs +++ b/src/python.rs @@ -10,6 +10,14 @@ use std::process; #[template(path = ".gitignore", escape = "none")] struct GitIgnore {} +#[derive(Template)] +#[template(path = ".vscode/settings.json", escape = "none")] +struct VSCodeSettings {} + +#[derive(Template)] +#[template(path = ".vscode/extensions.json", escape = "none")] +struct VSCodeExtensions {} + #[derive(Template)] #[template(path = "Makefile", escape = "none")] struct Makefile {} @@ -65,6 +73,30 @@ pub fn setup_preset(mut preset: String, name: String, create: bool) { .and_then(|mut file| file.write_all(GHWorkflowCI {}.render().expect("Failed to render ci.yaml").as_bytes())) .expect("Failed to create or write to ci.yaml"); + // Render .vscode/settings.json + File::create(format!("{}/.vscode/settings.json", prefix)) + .and_then(|mut file| { + file.write_all( + VSCodeSettings {} + .render() + .expect("Failed to render .vscode/settings.json") + .as_bytes(), + ) + }) + .expect("Failed to create or write to .vscode/settings.json"); + + // Render .vscode/extensions.json + File::create(format!("{}/.vscode/extensions.json", prefix)) + .and_then(|mut file| { + file.write_all( + VSCodeExtensions {} + .render() + .expect("Failed to render .vscode/extensions.json") + .as_bytes(), + ) + }) + .expect("Failed to create or write to .vscode/extensions.json"); + // Render .gitignore File::create(format!("{}/.gitignore", prefix)) .and_then(|mut file| file.write_all(GitIgnore {}.render().expect("Failed to render .gitignore").as_bytes())) diff --git a/templates/.vscode/extensions.json b/templates/.vscode/extensions.json new file mode 100644 index 0000000..a73380a --- /dev/null +++ b/templates/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.isort", + "ms-python.black-formatter", + "ms-python.flake8" + ] +} diff --git a/templates/.vscode/settings.json b/templates/.vscode/settings.json new file mode 100644 index 0000000..bd6b16b --- /dev/null +++ b/templates/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "[python]": { + "editor.formatOnType": true, + "editor.formatOnSave": true, + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "flake8.args": ["--config=.cpa/flake8.cfg"], + "files.insertFinalNewline": true +}