Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/vscode config #1

Merged
merged 2 commits into from
Apr 30, 2024
Merged

Feature/vscode config #1

merged 2 commits into from
Apr 30, 2024

Conversation

MarkoSagadin
Copy link
Collaborator

Description

This PR adds a VSCode configuration files and accompanying documentation.

Closes #18

Areas of interest for the reviewer

I would like to ask reviewers to clone this repo to their machines, checkout the feature/vscode_config branch and try to setup the VSCode by following the instructions in the README.md.

I would like you to spend some time using this configuration and see, if it is suitable for our use.
If you see that something that should be added/changed/removed, don't hesitate to mention it.

My main goal with this configuration is that provides a good solid editor base for our developers

After-review steps

  • I will merge PR by myself.

@github-actions github-actions bot added the pull request Pull request, added automatically by CI. label Apr 18, 2024
@MarkoSagadin
Copy link
Collaborator Author

MarkoSagadin commented Apr 18, 2024

@vid553 @NejcKle @TjazVracko

I should be more explicit on how to test this:

  • before testing this disable settings sync on your VSCode account.
  • backup the mentioned folders
  • follow the setup instructions in the Readme

@MarkoSagadin MarkoSagadin force-pushed the feature/vscode_config branch 3 times, most recently from bb4769b to b7c121e Compare April 18, 2024 11:38
Copy link

@TjazVracko TjazVracko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

You must also install clang-format in a script somewhere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove all sudo calls here, you are modifying only the home directory.

README.md Outdated
./installation_scripts/install_vscode.sh
```

2. To install all extensions run:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before step 2 all vscode instances must be closed!

@TjazVracko
Copy link

TjazVracko commented Apr 22, 2024

Some more probably usefull settings to add to settings.json:

  "explorer.confirmDelete": false,  // does not ask with popup when you want to delete files
  "window.titleBarStyle": "custom",  // Title bar matches your theme

    "editor.rulers": [100] // under the [c][cpp] section??

  "editor.inlineSuggest.enabled": true,  // This replaces the sugess

// You can use this to control which file types are enabled for copilot
"github.copilot.enable": {
    "*": true,
    "plaintext": false,
    "markdown": true,
    "scminput": false  // This is the git commit message box, haha.
  },

  "diffEditor.ignoreTrimWhitespace": false  // See all changes in whitespace when viewing diffs. So that you don't accidentally change some whitespace and then not see in in the diff view.


  // Maybe a bit to personal. This also highlights the word TEST:
 // (I suggest we add a guideline when to use TODO, FIXME, TEST and other such words.)
  "todohighlight.keywords": [
    {
      "text": "TEST:",
      "color": "#ff0000",
      "backgroundColor": "#30CB30",
      "overviewRulerColor": "grey"
    }
  ]

@TjazVracko
Copy link

TjazVracko commented Apr 22, 2024

@MarkoSagadin The snippets only work in c files, not in cpp files.

This can be fixed by either having a separate cpp.json file in the snippets folder, or by modifying the file associations settings:

  "files.associations": {
    "CMakeLists.txt": "cmake",
    "*.h": "c",
    "*.hpp": "c",
    "*.cpp": "c"
  },

@TjazVracko
Copy link

TjazVracko commented Apr 24, 2024

Vscode automatically detects most conf files to be YAML, and then proceeds to show a bunch of yaml sintax errors...

There must be a way to define file associations for conf files, which usually don't have file extension (like <boardname>_defconfig)

explore using the Kconfig extension from Nordic? - after a quick test this works out of the box with almost no settings changes. A build folder is the only required thing for it to work.
File associations:

  "files.associations": {
    "*_defconfig": "kconfig",
    "*.conf": "kconfig"
  },

@TjazVracko
Copy link

I also did a quick check of the nRF DeviceTree extension. It kinda works.
It requires a workspace setting "devicetree.zephyr": "<path to zephyr root>", which I was unable to configure using a relative path. So it would would have to be set for every project specifically.

The extensions shows errors and warning when viewing a DTS file and also support a GUI editor (think CubeMX). But how accurate/valid the information shown actually is I do not know (do not have time currently to check).

@MarkoSagadin MarkoSagadin force-pushed the feature/vscode_config branch 3 times, most recently from 5dc5924 to 4dec3ea Compare April 26, 2024 12:52
@MarkoSagadin
Copy link
Collaborator Author

@TjazVracko

I force-pushed a commit with requested changes. I added the settings that you suggested except the below ones, I think that they are too specific:

  "window.titleBarStyle": "custom",  // Title bar matches your theme
  "todohighlight.keywords": [
    {
      "text": "TEST:",
      "color": "#ff0000",
      "backgroundColor": "#30CB30",
      "overviewRulerColor": "grey"
    }
  ]

I added instructions for using Profile files. Check, if they are ok.

I also added most of the Nordic plugins except the main one.

Copy link

@vid553 vid553 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work :)

I have evaluated this PR using Ubuntu 22.04.
Profile importing works great, I especially like the fact that you can choose which extensions it should install.
I had however problems when running extension installation script. The script didn't install any extensions and threw Buffer is deprecated error on each install attempt.

Comments on extensions:

  • the scripts didn't disable / uninstall Microsoft's c/c++ extension, which I think is not desired to be enabled?
  • I recommend adding the Code Spell Checker extension
  • Consider changing Github theme and Noctis extension to be optional as not every user wants to use any of those themes
  • I also think IntelliCode extension should be included as it provides code suggestions for python and TS/JS projects (writing this as I didn't get any suggestions using the setup that was made from this PR)
  • I also recommend adding isort extension which automatically sorts the imports for python
  • I also in RN projects use the extension React Native tools, please add it here as well

Settings:
Consider adding these settings:

"telemetry.telemetryLevel": "crash",
  "github.copilot.enable": {
    "markdown": true,
  },
  "git.autofetch": true,
  "terminal.integrated.defaultProfile.windows": "Command Prompt",
  "terminal.integrated.defaultProfile.osx": "zsh",
  "terminal.integrated.profiles.osx": {
    "zsh": {
      "path": "zsh",
      "args": [
        "-l",
        "-i"
      ]
    },
  },

"editor.detectIndentation": false,
"editor.tabSize": 8,
"editor.insertSpaces": false,
"editor.rulers": [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be removed as it's too specific.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only editor.rulers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it.

"debug.focusWindowOnBreak": false,
"debug.focusEditorOnBreak": false,
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong, it should be:

"[markdown]": {
    "editor.defaultFormatter": "yzhang.markdown-all-in-one"
 }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on purpose. Prettier works much better for formatting the markdowns than markdownlint does.

@MarkoSagadin
Copy link
Collaborator Author

MarkoSagadin commented Apr 29, 2024

@vid553

I had however problems when running extension installation script. The script didn't install any
extensions and threw Buffer is deprecated error on each install attempt.

I have seen this warning on my side as well, but the extensions were installed anyway. This might be
a difference between MacOS and Linux.

the scripts didn't disable / uninstall Microsoft's c/c++ extension, which I think is not desired
to be enabled?

If scripts are used they should be used on a completely clean VSCode setup. They won't uninstall
anything by default. The C/C++ extension is actually disabled in the settings.json:
"C_Cpp.intelliSenseEngine": "disabled", (it must be so that is not fighting with the Clangd).

Did you back up your existing configuration before trying scripts?

  • I recommend adding the Code Spell Checker extension

We have the tekumara.typos-vscode extension that does the same thing. Benefit of using this one is
that is using the same typos tool that our pre-commit does.

Consider changing Github theme and Noctis extension to be optional as not every user wants to use
any of those themes.

They are only installed but not configured to be used (the used theme is the VSCode default one,
"Default Dark Modern"). Should I remove them from the install_extensions.sh script?

I also think IntelliCode extension should be included as it provides code suggestions for python
and TS/JS projects (writing this as I didn't get any suggestions using the setup that was made
from this PR)

I will add it, I was not aware of it.

I also recommend adding isort extension which automatically sorts the imports for python

So, this extension is supported in Ruff and is also already enabled in our ruff.toml file that is provided with the irnas-zephyr-template (see line 5).

To have the consistent formatting in your Python files just copy the ruff.toml into your project's
root dir and it will work.

I also in RN projects use the extension React Native tools, please add it here as well.

I have added it.

Consider adding these settings:

Our Copilot setting already does what you want so that is ok. I will make
"telemetry.telemetryLevel": "none", (thank you for that I was not aware of it).

Everything else I would say that is personal preference, and should be added explicitly by the user.

@MarkoSagadin MarkoSagadin merged commit 564b029 into main Apr 30, 2024
@MarkoSagadin MarkoSagadin deleted the feature/vscode_config branch April 30, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request Pull request, added automatically by CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants