It is a plugin for Sublime Text 4, used to prettify the debug string of Protobuf messages.
Use Python Lex-Yacc to parse the debug string.
Install "Pretty Protobuf" via Package Control.
Or manually, take macOS as an example:
# Go to the packages directory of Sublime Text
# Sublime Text -> Preferences -> Browse Packages...
cd $HOME/Library/Application\ Support/Sublime\ Text/Packages
git clone https://github.com/hanfezh/pretty-protobuf.git Pretty\ Protobuf
To prettify proto's debug string, select message's debug string and run command "Pretty Protobuf: Format Message Debug String" through Command Palette Command+Shift+P (macOS). If no selection, the entire file is used by default.
To map a key combination like Ctrl+Shift+J to the Minify command, you can add a setting like this to your .sublime-keymap file (eg: Packages/User/Default (OSX).sublime-keymap
):
[
{
"keys": [
"ctrl+shift+j"
],
"command": "pretty_debug_string"
}
]
To prettify Protobuf, execute command "Pretty Protobuf: Format Protobuf":
- Requirements: clang-format
Default settings for prettifying message debug string:
- indent: 4 spaces
- sort_keys: false, set true to sort keys
- use_entire_file_if_no_selection: true
- clang_format_path: clang-format, change to canonical path, such as /usr/local/bin/clang-format
{
"indent": 4,
"sort_keys": false,
"use_entire_file_if_no_selection": true,
"clang_format_path": "clang-format"
}