Skip to content

Commit

Permalink
add vscode conf generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ysawa0 committed Nov 9, 2023
1 parent 00c1020 commit b899bec
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "example"
name = "create-python-app"
version = "0.0.1"
description = ""
authors = [
Expand Down
32 changes: 32 additions & 0 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -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()))
Expand Down
9 changes: 9 additions & 0 deletions templates/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.isort",
"ms-python.black-formatter",
"ms-python.flake8"
]
}
9 changes: 9 additions & 0 deletions templates/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit b899bec

Please sign in to comment.