-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/json schema for keybindings #8
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/json schema for keybindings #8
Conversation
davidmelvin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks very much for this suggestion! I think it's a great improvement on what we have! :)
Do you think you could update the README with simple instructions as to where users should put the new .vscode/settings.json and schemas/keybindings.json files, that they will need to install an extension like redhat.vscode-yaml to see the Intellisense?
schemas/keybindings.json
Outdated
| "type": "string", | ||
| "minLength": 1, | ||
| "not": { | ||
| "pattern": "---|([^-]+)-\\1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think you could update the pattern to account for our exact keybinding format? I understand that might be hard to do in regex!
It's important so we don't create a situation where the keyboard shortcuts look good to VS Code, but don't work in Warp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with comprehensive regex that it will be shown (by YAML Red Hat plugin) when wrong value is passed. And it will look unreadable and hard to figure out what's wrong. :) I think that the best option here is to implement simple plugin which checks format completely and displays possible key combinations. So, yeah, JSON Schema does not always covers everything.
|
Tomorrow I try to finish this PR. |
|
@davidmelvin, I've wrote a script to extract all shortcuts as JSON (just #!/usr/bin/env bash
to_css_path() {
declare in_number="$1"
declare prefix='/html/body/div[1]/div/div/div[2]/div/div[2]/div/div/main/div[2]/div[1]/div/'
declare suffix='/div/div/div/div/div/div/div/div/div/div/div/div/div/table'
echo "${prefix}div[$in_number]$suffix" |
sed --regexp-extended 's|/html/body/||' |
sed --regexp-extended 's|/| > |g' |
sed --regexp-extended 's|\[(..?)\]|:nth-of-type(\1)|g'
}
get_shortcut_info() {
declare show_shortcut=false
declare show_command=false
declare show_action=false
declare in_table="$1"
declare -i in_index="$2"
declare show_shortcut=false
declare show_command=false
declare show_action=false
shift 2
while [[ -n $1 ]]; do
declare flag="$1"
case "$flag" in
--shortcut|-s)
show_shortcut=true
;;
--command|-c)
show_command=true
;;
--action|-a)
show_action=true
;;
esac
shift
done
[[ $show_shortcut == true ]] &&
yq --input-format xml ".table.tbody.tr[$in_index].td[0].div.div.div.div.div.span.code.+content" <(echo "$in_table") 2> /dev/null
[[ $show_command == true ]] &&
yq --input-format xml ".table.tbody.tr[$in_index].td[1].div.div.div.div.div.span.span.+content" <(echo "$in_table") 2> /dev/null
[[ $show_action == true ]] &&
yq --input-format xml ".table.tbody.tr[$in_index].td[2].div.div.div.div.div.span.code.+content" <(echo "$in_table") 2> /dev/null
}
get_shortcut_definition() {
declare in_shortcut="$1"
declare in_command="$2"
declare in_action="$3"
echo "\"$in_action\": {
\"title\": \"$in_action\",
\"description\": \"$(sed --regexp-extended 's/(.)(.*)/\1\L\2/' <<< "$in_command")\",
\"default\": \"$in_shortcut\",
\"\$ref\": \"#/definitions/key\"
}"
}
declare tables=()
for item in $(seq 9 17); do
(( item % 2 == 0 )) && continue
tables+=("$(pup --file doc.html "$(to_css_path "$item")")")
done
for table in "${tables[@]}"; do
declare shortcut=
declare -i index=0
# shellcheck disable=2155
while true; do
declare shortcut="$(get_shortcut_info "$table" "$index" --shortcut)"
declare command="$(get_shortcut_info "$table" "$index" --command)"
declare action="$(get_shortcut_info "$table" "$index" --action)"
[[ "$shortcut" == null ]] && break
get_shortcut_definition "$shortcut" "$command" "$action"
echo ,
index+=1
done
done > output.json
This doc page should be downloaded and saved as |
|
@davidmelvin, there are two undocumented properties in docs:
|
|
@EmilySeville7cfg thank you!! Will review this soon. |
What about to review this PR? ;) |
|
JSON schemas for Warp are available here now. PR is closed as I didn't get any response from project maintainers in a reasonable time. |
Notes
alt-altQuestions
Are they correct (but still not documented here) or invalid? I see
editor:insert_last_word_previous_commandappears in docs. Is FORMAT.md just outdated?