GuardianDll / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
0 stars 0 forks source link

How to configure your Notepad++ to use json_formatter.exe #13

Closed GuardianDll closed 9 months ago

GuardianDll commented 1 year ago

This version is deprecated, see #16


GIF 14-05-2023 22-16-01

GIF 14-05-2023 22-16-51

Solution you would like.

  1. Install NppExec addon from Plugin Admin
  2. After installation, go to Plugins - NppExec - Execute NppExec Script... image
3. Into menu, paste the next code (under the spoiler): ``` NPP_CONSOLE - //hide the log output npe_console p- //hide the ==== READY ==== message in the end npp_save //save the file, so linter will lint the actual edited file, and not its original, unedited copy cmd /C //actual linting - call cmd, /C so it will close the cmd in the end NPP_CONSOLE + //turn back the log output, so if linter will show any error, user will see the error message C:\Games\cddaDev\json_formatter.exe $(FULL_CURRENT_PATH) // !!! first part is what you should edit manually, // just paste the path into your json_formatter.exe // $(FULL_CURRENT_PATH) respond to tell the linter which file (this one) to lint NPP_CONSOLE - //turning log off again set var_exitcode=$(EXITCODE) //save the exit code set var1=$(FULL_CURRENT_PATH) //save the path to the file, so we can reload it npp_close $(var1) //awful way to reload file by closing and opening it again npp_open $(var1) //because the only another way is to change the tab, and its worse unset var1 if $(var_exitcode)==0 goto exit_console //if exit code 0, it means everything is good goto print_console //else we left the console open :exit_console npp_console off exit :print_console npp_console on ```

image

  1. In this code, replace C:\Games\cdda\json_formatter.exe with your own path to json_formatter.exe file
  2. Press Save…, and rename it like you want (like Lint the file) image
  3. Exit the menu
  4. Go to Plugins - NppExec and activate Follow $(CURRENT_DIRECTORY) image
  5. Go to Plugins - NppExec - Advanced Options image 8.1 Change Visible (on start) to be No
  6. From Associated Script menu, pick your script, give him some name, and add it image 9.1 Restart the Notepad
  7. Go to Settings - Shortcut Mapper
  8. In Plugin commands, find your script, and give him some proper shortcut image
  9. Go to Plugins - NppExec - Console Output Filters… image
  10. Go to Highlight menu, and add *Json error* text into the proper field, press the first checkbox, and write FF into the Red field image

Done! Now pressing the shortcut will save, lint, and reload the file. If there would be some error, linter will show the error message similar to the in game one, with string number, where the error occur

Additional context

I still think it's possible to make the code point the user toward the place where the error occur, but my brain is too smooth to make it

Note: one can go to Settings - Preferences - MISC, and pick "update silently", it'll remove "the file has been modified by another program" popup, and your files would be updated automatically.