Skip to content

Commit 99da76c

Browse files
committed
feat: add VSCode config files and docs
1 parent e15533e commit 99da76c

File tree

8 files changed

+326
-18
lines changed

8 files changed

+326
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

77
## [Unreleased]
8+
9+
### Added
10+
11+
- Initial project structure and VSCode configs.

README.md

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,71 @@
1-
# Irnas's Projects template
2-
3-
IRNAS template for a GitHub repository. It comes with a
4-
[basic group](https://github.com/IRNAS/irnas-workflows-software/tree/main/workflow-templates/basic)
5-
of CI workflows for release automation.
6-
7-
## Checklist
8-
9-
- [ ] Provide a concise and accurate description of your project in the GitHub
10-
"description" field.
11-
- [ ] Provide a concise and accurate description of your project in this
12-
`README.md` file, replace the title.
13-
- [ ] Ensure that your project follows
14-
[repository naming scheme](https://github.com/IRNAS/irnas-guidelines-docs/blob/main/docs/github_projects_guidelines.md#repository-naming-scheme-).
15-
- [ ] Turn on `gitlint` tool by running `gitlint install-hook`. If you do not
16-
have it yet, follow instructions
17-
[here](https://github.com/IRNAS/irnas-guidelines-docs/tree/main/tools/gitlint).
18-
- [ ] As the final step delete this checklist and commit changes.
1+
# VSCode setup by IRNAS
2+
3+
![vscode-banner](images/vscode-banner.webp)
4+
5+
## Introduction
6+
7+
This repository contains installation scripts and configuration files for setting up the VSCode
8+
editor from scratch. The configuration files inside the `dotfiles/.config/Code` are pretty
9+
opinionated. They are suitable for embedded Zephyr/NCS development, writing Python scripts and
10+
JavaScript/React Native applications.
11+
12+
The configuration is especially coupled to our `.pre-commit-config.yaml` file in the
13+
[irnas-zephyr-template] repo, as it sets up formatters, linters and other tools that are used by the
14+
`pre-commit` tool.
15+
16+
[irnas-zephyr-template]: https://github.com/IRNAS/irnas-zephyr-template/tree/main
17+
18+
## Setup
19+
20+
1. To install VsCode run:
21+
22+
```shell
23+
./installation_scripts/install_vscode.sh
24+
```
25+
26+
2. To install all extensions run:
27+
28+
```shell
29+
./installation_scripts/install_extensions.sh
30+
```
31+
32+
3. To symlink VSCode settings to its correct location:
33+
34+
```shell
35+
cd dotfiles
36+
./place_dotfiles.sh
37+
```
38+
39+
4. Open VSCode. All extensions are now installed, all that is left to do is to configure some
40+
specific paths, follow instructions in the pop-up notifications.
41+
42+
## Backing up existing settings
43+
44+
If you care about your current VSCode configuration you may want to backup below folders:
45+
46+
On Windows:
47+
48+
- `%APPDATA%\Code`
49+
- `%USERPROFILE%\.vscode`
50+
51+
On Linux and macOS:
52+
53+
- `$HOME/.config/Code/`
54+
- `$HOME/.vscode`
55+
56+
### Maintaining your configuration and expected workflow
57+
58+
`place_dotfiles.sh` creates a symlink for the `.config/Code` alongside it to its correct location in
59+
the `~/` home directory.
60+
61+
This means that whatever changes are made in the `~/.config/Code`, they are reflected in this repo
62+
and thus visible in the `git` version control system.
63+
64+
Developers can thus:
65+
66+
- fork this repo to their personal GitHub account,
67+
- start with a good working VSCode configuration,
68+
- expand it further by their preferences, commit changes and
69+
- sync with the upstream repo, when they want to fetch new commits.
70+
71+
Developers can also manually copy the things that they want and manually update when they want to.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
// General settings
3+
"editor.formatOnSave": true,
4+
"files.associations": {
5+
"CMakeLists.txt": "cmake",
6+
"*.h": "c"
7+
},
8+
"files.trimTrailingWhitespace": true,
9+
"files.trimFinalNewlines": true,
10+
"files.insertFinalNewline": true,
11+
"[c][cpp]": {
12+
"editor.detectIndentation": false,
13+
"editor.tabSize": 8,
14+
"editor.insertSpaces": false
15+
},
16+
// Don't change focus, when debugging.
17+
"debug.focusWindowOnBreak": false,
18+
"debug.focusEditorOnBreak": false,
19+
"[c]": {
20+
"editor.defaultFormatter": "xaver.clang-format"
21+
},
22+
"editor.cursorBlinking": "smooth",
23+
"[markdown]": {
24+
"editor.defaultFormatter": "esbenp.prettier-vscode"
25+
},
26+
"editor.autoClosingComments": "always",
27+
"[javascript]": {
28+
"editor.defaultFormatter": "esbenp.prettier-vscode"
29+
},
30+
"[jsonc]": {
31+
"editor.defaultFormatter": "esbenp.prettier-vscode"
32+
},
33+
"git.openRepositoryInParentFolders": "never",
34+
"security.workspace.trust.enabled": false,
35+
// Extensions
36+
"clang-format.executable": "/usr/bin/clang-format-17",
37+
"errorLens.enabledDiagnosticLevels": [
38+
"error",
39+
"warning",
40+
"info",
41+
"hint"
42+
],
43+
"auto-comment-blocks.singleLineBlockOnEnter": true,
44+
"errorLens.messageEnabled": false,
45+
"errorLens.gutterIconsEnabled": true,
46+
"doxdocgen.generic.paramTemplate": "@param[in] {param} ",
47+
"doxdocgen.generic.returnTemplate": "@return ",
48+
"clangd.arguments": [
49+
"--enable-config",
50+
"--query-driver=/usr/bin/**/clang-*,/bin/clang,/bin/clang++,/usr/bin/gcc,/usr/bin/g++,${env:HOME}/gnuarmemb/bin/arm-none-eabi-gcc",
51+
"--all-scopes-completion",
52+
"--background-index",
53+
"-j=8",
54+
"--clang-tidy",
55+
"--completion-style=detailed",
56+
"--function-arg-placeholders",
57+
"--header-insertion-decorators",
58+
"--header-insertion=never",
59+
"--pch-storage=memory"
60+
],
61+
"cortex-debug.enableTelemetry": false,
62+
"cortex-debug.liveWatchRefreshRate": 250,
63+
"C_Cpp.intelliSenseEngine": "disabled",
64+
"workbench.colorTheme": "Default Dark Modern",
65+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"hfile": {
3+
"prefix": [
4+
"hfile"
5+
],
6+
"body": [
7+
"/** @file $TM_FILENAME_BASE.h",
8+
" *",
9+
" * @brief ${2:A description of the module's purpose.}",
10+
" *",
11+
" * @par",
12+
" * COPYRIGHT NOTICE: (c) $CURRENT_YEAR Irnas. All rights reserved.",
13+
" */",
14+
"",
15+
"#ifndef ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H",
16+
"#define ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H",
17+
"",
18+
"#ifdef __cplusplus",
19+
"extern \"C\" {",
20+
"#endif",
21+
"",
22+
"${0}",
23+
"",
24+
"#ifdef __cplusplus",
25+
"}",
26+
"#endif",
27+
"",
28+
"#endif /* ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H */",
29+
"",
30+
],
31+
"description": "IRNAS .h file template"
32+
},
33+
"cfile": {
34+
"prefix": [
35+
"cfile"
36+
],
37+
"body": [
38+
"/** @file $TM_FILENAME_BASE.c",
39+
" * ",
40+
" * @par ",
41+
" * COPYRIGHT NOTICE: (c) $CURRENT_YEAR Irnas. All rights reserved.",
42+
" */",
43+
"",
44+
"",
45+
"#include \"$TM_FILENAME_BASE.h\"",
46+
"",
47+
"${0}",
48+
"",
49+
],
50+
"description": "IRNAS .c file template"
51+
},
52+
"slc": {
53+
"prefix": [
54+
"slc"
55+
],
56+
"body": [
57+
"/* ${0} */"
58+
],
59+
"description": "C89-style single line comment"
60+
},
61+
"mlc": {
62+
"prefix": [
63+
"mlc"
64+
],
65+
"body": [
66+
"/*",
67+
" * ${0}",
68+
" */"
69+
],
70+
"description": "C89-style multi line comment"
71+
}
72+
}

dotfiles/place_dotfiles.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
dotfilesDir=$(pwd)
4+
5+
function linkDotfile {
6+
dest="${1}/${2}"
7+
dateStr=$(date +%Y-%m-%d-%H%M)
8+
9+
if [ -h ~/"${2}" ]; then
10+
# Existing symlink
11+
echo "Removing existing symlink: ${dest}"
12+
sudo rm "${dest}"
13+
14+
elif [ -f "${dest}" ]; then
15+
# Existing file
16+
echo "Backing up existing file: ${dest}"
17+
sudo mv "${dest}""{,.${dateStr}}"
18+
19+
elif [ -d "${dest}" ]; then
20+
# Existing dir
21+
echo "Backing up existing dir: ${dest}"
22+
sudo mv "${dest}""{,.${dateStr}}"
23+
fi
24+
25+
echo "Creating new symlink: ${dest}"
26+
sudo ln -s "${dotfilesDir}"/"${2}" "${dest}"
27+
}
28+
29+
# Create config folder if it does not exists, below symlinks fail otherwise
30+
mkdir -p ~/.config
31+
32+
# Create symlink for a file/folder on a right in the folder on the left
33+
linkDotfile /home/"$USER" .config/Code

images/vscode-banner.webp

22.9 KB
Binary file not shown.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
function install {
4+
code --install-extension "$1"
5+
}
6+
7+
# General development core
8+
install eamodio.gitlens
9+
install usernamehw.errorlens
10+
11+
# C/C++ extensions
12+
install xaver.clang-format
13+
install cheshirekow.cmake-format
14+
install twxs.cmake
15+
install llvm-vs-code-extensions.vscode-clangd
16+
install cschlosser.doxdocgen
17+
install IRNAS.auto-comment-blocks-single-star
18+
install harry-ross-software.c-snippets
19+
install jeff-hykin.better-c-syntax
20+
install jeff-hykin.better-cpp-syntax
21+
22+
# JS/TS extensions
23+
install esbenp.prettier-vscode # Also used for formatting markdown files.
24+
install dbaeumer.vscode-eslint
25+
install xabikos.JavaScriptSnippets
26+
27+
# Python extensions
28+
install ms-python.python
29+
install magicstack.MagicPython
30+
install charliermarsh.ruff
31+
install njpwerner.autodocstring
32+
install frhtylcn.pythonsnippets
33+
34+
# Cmake
35+
install twxs.cmake
36+
install cheshirekow.cmake-format
37+
38+
# Docker
39+
install ms-azuretools.vscode-docker
40+
install exiasr.hadolint
41+
42+
# Jupyter
43+
install ms-toolsai.jupyter
44+
45+
# Embedded development
46+
install marus25.cortex-debug
47+
install ms-vscode.vscode-embedded-tools
48+
install keroc.hex-fmt
49+
50+
# Extras
51+
install ms-vscode-remote.vscode-remote-extensionpack
52+
install tekumara.typos-vscode
53+
install DavidAnson.vscode-markdownlint
54+
install yzhang.markdown-all-in-one
55+
install github.copilot
56+
install github.copilot-chat
57+
install Graphite.gti-vscode
58+
install wayou.vscode-todo-highlight
59+
install mattlott.copy-github-url
60+
install redhat.vscode-yaml
61+
install tamasfe.even-better-toml
62+
install coolchyni.beyond-debug
63+
install vsciot-vscode.vscode-arduino
64+
65+
# Themes
66+
install github.github-vscode-theme
67+
install liviuschera.noctis
68+
install anoff.theme-monokai-light
69+
70+
# Extra tools needed by some extensions, but not directly provided by them.
71+
pip install cmake-format
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
# Add microsoft's repository to apt
4+
sudo apt update
5+
sudo apt install software-properties-common apt-transport-https wget
6+
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
7+
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
8+
9+
# install
10+
sudo apt install code

0 commit comments

Comments
 (0)