cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
941 stars 103 forks source link

Windows installation procedure for VSCode #298

Open RomanKhv opened 1 year ago

RomanKhv commented 1 year ago

Hi! Could you please git it working for me? 1) I've install Python latest version, 2) in VSCode i've installed cmake-format extension 3) should I do something more?..

In VSCode I open CMakeLists.txt, select "Format Document" command - nothing happens :(

Thank you in advance

AhiyaHiya commented 1 year ago

If you still haven't gotten this working, you may want to do the following:

  1. Open the command palette (Ctrl+Shift+P)
  2. Type 'sett' and select "Preferences: Open User Settings (JSON)"
  3. Add exePath and args to the existing JSON; see below for an example
  4. Save the changed JSON file and close the document

At this point, you should be able to invoke the "Format Document" command, as you noted above and should see you CMakeLists.txt file change.

Note, to get the format file, with settings, you have to export it from cmake-format.exe and make changes as required: cmake-format.exe --dump-config python > sample-settings.py

Hope this helps.

Example JSON settings:

{
    "editor.fontFamily": "MesloLGM Nerd Font Mono",
    [...]
    "cmakeFormat.exePath": "C:\\FillInYourPythonPath\\Scripts\\cmake-format.exe",
    "cmakeFormat.args": ["--config-file", "C:\\FillInYourPreferredDocPath\\my_cmake_format.py"]
}
Michael-Liao commented 1 year ago

See my latest comment on #242 Hope it helps :)