summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clangd4
-rw-r--r--.vscode/extensions.json2
-rw-r--r--.vscode/settings.json7
-rw-r--r--docs/other_vscode.md51
4 files changed, 20 insertions, 44 deletions
diff --git a/.clangd b/.clangd
new file mode 100644
index 0000000000..2be2d817fc
--- /dev/null
+++ b/.clangd
@@ -0,0 +1,4 @@
1CompileFlags:
2 Add: [-Wno-unknown-attributes, -Wno-maybe-uninitialized, -Wno-unknown-warning-option]
3 Remove: [-W*, -mcall-prologues]
4 Compiler: clang
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 889d9d610e..068d3d784d 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -3,7 +3,7 @@
3 "recommendations": [ 3 "recommendations": [
4 "EditorConfig.EditorConfig", 4 "EditorConfig.EditorConfig",
5 "xaver.clang-format", 5 "xaver.clang-format",
6 "ms-vscode.cpptools", 6 "llvm-vs-code-extensions.vscode-clangd",
7 "bierner.github-markdown-preview", 7 "bierner.github-markdown-preview",
8 "donjayamanne.git-extension-pack" 8 "donjayamanne.git-extension-pack"
9 ] 9 ]
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 76117e52e0..f369ecb174 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -26,6 +26,9 @@
26 }, 26 },
27 "python.formatting.provider": "yapf", 27 "python.formatting.provider": "yapf",
28 "[json]": { 28 "[json]": {
29 "editor.formatOnSave": false 29 "editor.formatOnSave": false
30 } 30 },
31 "clangd.arguments": [
32 "--header-insertion=never"
33 ]
31} 34}
diff --git a/docs/other_vscode.md b/docs/other_vscode.md
index a10002570b..83ae6e6ed0 100644
--- a/docs/other_vscode.md
+++ b/docs/other_vscode.md
@@ -92,59 +92,28 @@ No, really, that's it. The paths needed are already included when installing th
92 92
93There are a number of extensions that you may want to install: 93There are a number of extensions that you may want to install:
94 94
95* [Git Extension Pack](https://marketplace.visualstudio.com/items?itemName=donjayamanne.git-extension-pack) - 95* [Git Extension Pack](https://marketplace.visualstudio.com/items?itemName=donjayamanne.git-extension-pack) - This installs a bunch of Git related tools that may make using Git with QMK Firmware easier.
96This installs a bunch of Git related tools that may make using Git with QMK Firmware easier. 96* [clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) - _[Optional]_ - This is the language server for C/C++ that VS Code uses. It provides IntelliSense and other features.
97* [EditorConfig for VS Code](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) - _[Optional]_ - Helps to keep the code to the QMK Coding Conventions. 97* [EditorConfig for VS Code](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) - _[Optional]_ - Helps to keep the code to the QMK Coding Conventions.
98* [GitHub Markdown Preview](https://marketplace.visualstudio.com/items?itemName=bierner.github-markdown-preview) - _[Optional]_ - Makes the markdown preview in VS Code more like GitHub's. 98* [GitHub Markdown Preview](https://marketplace.visualstudio.com/items?itemName=bierner.github-markdown-preview) - _[Optional]_ - Makes the markdown preview in VS Code more like GitHub's.
99* [VS Live Share Extension Pack](https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare-pack) - _[Optional]_ - This extension allows somebody else to access your workspace (or you to access somebody else's workspace) and help out. This is great if you're having issues and need some help from somebody. 99* [VS Live Share Extension Pack](https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare-pack) - _[Optional]_ - This extension allows somebody else to access your workspace (or you to access somebody else's workspace) and help out. This is great if you're having issues and need some help from somebody.
100 100
101Restart once you've installed any extensions 101Restart once you've installed any extensions.
102 102
103# Configure VS Code for QMK 103# Configure VS Code for QMK
104 104
1051. Click <kbd><kbd>File</kbd> > <kbd>Open Folder</kbd></kbd> 1051. Click <kbd><kbd>File</kbd> > <kbd>Open Folder</kbd></kbd>
1062. Open the QMK Firmware folder that you cloned from GitHub. 1062. Open the QMK Firmware folder that you cloned from GitHub.
1073. Click <kbd><kbd>File</kbd> > <kbd>Save Workspace As...</kbd></kbd> 1073. Click <kbd><kbd>File</kbd> > <kbd>Save Workspace As...</kbd></kbd>
108 108
109## Configuring VS Code 109## Configuring VS Code
110 110
111Using the [standard `compile_commands.json` database](https://clang.llvm.org/docs/JSONCompilationDatabase.html), we can get VS code C/C++ extension to use the exact same includes and defines used for your keyboard and keymap. 111Using the [standard `compile_commands.json` database](https://clang.llvm.org/docs/JSONCompilationDatabase.html), we can get the VS code _clangd_ extension to use the correct includes and defines used for your keyboard and keymap.
112 112
1131. Run `qmk generate-compilation-database -kb <keyboard> -km <keymap>` to generate the `compile_commands.json`. 1131. Run `qmk generate-compilation-database -kb <keyboard> -km <keymap>` to generate the `compile_commands.json`.
1141. Create `.vscode/c_cpp_properties.json` with the following content: 1141. Inside VS code, press <kbd><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd></kbd> (macOS: <kbd><kbd>Command</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd></kbd>) to open the command palette.
115``` 1151. Start typing `clangd: Download Language Server` and select it when it appears. Note that this only needs to be done once on clangd extension installation, if it didn't already ask to do so.
116{ 1161. Inside VS code, press <kbd><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd></kbd> (macOS: <kbd><kbd>Command</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd></kbd>) to open the command palette.
117 "configurations": [ 1171. Start typing `clangd: Restart Language Server` and select it when it appears.
118 {
119 "name": "qmk",
120 "compilerArgs": ["-mmcu=atmega32u4"],
121 "compilerPath": "/usr/bin/avr-gcc",
122 "cStandard": "gnu11",
123 "cppStandard": "gnu++14",
124 "compileCommands": "${workspaceFolder}/compile_commands.json",
125 "intelliSenseMode": "linux-gcc-arm",
126 "browse": {
127 "path": [
128 "${workspaceFolder}"
129 ],
130 "limitSymbolsToIncludedHeaders": true,
131 "databaseFilename": ""
132 }
133 }
134 ],
135 "version": 4
136}
137```
138
139Change values in `.vscode/c_cpp_properties.json` for your environment:
140
1411. Copy the `-mmcu` argument from `compile_commands.json` into your `compilerArgs`. This is to work around a [bug in vscode c/c++ extension](https://github.com/microsoft/vscode-cpptools/issues/6478).
1421. Use the `compilerPath` from `compile_commands.json`.
1431. Modify `cStandard`, `cppStandard` and `intelliSenseMode` values to the correct values for your platform. See [this section](https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference#_configuration-properties) for reference. For WSL, it should still be gcc-x64.
144
145And now you're ready to code QMK Firmware in VS Code
146
147
148## Troubleshooting VSCode C/C++ extension
149 118
150If the defines are not matching what you expect, open the source code and run action `C/C++: Log Diagnostics`. This will list the exact list of defines and include paths defined in `compile_commands.json`, and if it's not part of your compilation database, it will tell you so. \ No newline at end of file 119Now you're ready to code QMK Firmware in VS Code!