Comments (8)
Kind of just jotting here. Apparently, we can add the (limited) schema into package.json
so there is a prompt of possible value when people edit the settings.json
For example:
"whichkey.bindings": {
"type": "array",
"items": {
"type": "object",
"title": "Binding",
"properties": {
"key": {
"type": "string",
"description": "Key of this binding in this level"
},
"name": {
"type": "string",
"description": "The display name of this binding"
},
"type": {
"type": "string",
"enum": ["command", "commands", "transient", "conditional"],
"description": "The type of this binding"
}
}
},
"markdownDescription": "The bindings of the which key menu",
"default": []
}
Maybe the hack mentioned in microsoft/vscode#95270 (comment) can bypass the limited functionality. Also maybe be able to reuse across extensions like VSpaceCode
and which-key
from vscode-which-key.
Just jotting notes here. Thinking we can use JSON Schema with https://ajv.js.org. To handle requirements of different requirement of properties on the type
name, we can use the if/then/else
as described in https://json-schema.org/understanding-json-schema/reference/conditionals.html and https://ajv.js.org/keywords.html#ifthenelse
And we can use https://github.com/adobe/jsonschema2md to generate documentations
from vscode-which-key.
I've used json schema before. I could write the schema if you want.
Tell me:
- the file(s) to be validated
- where to place the schema file
from vscode-which-key.
Thank you for helping, it would be great if you can help as I am going to be busy in the next few weeks. The schemas are used to validate the bindings
and bindingOverrides
.
Thebindings
contains an array of BindingItem
(s).
BindingItem
key | value |
---|---|
key | required string |
name | required string |
type | required enum string (command , commands , bindings and transient ) |
command | required string if type == command | (optional if type == transient && only if commands is not exists) |
commands | required array of strings if type == commands | (optional if type == transient && only if command is not exists) |
args | optional any object | array of objects if type == commands |
bindings | Array of BindingItem(s), required if type == bindings |
The bindingOverrides
contains an array of OverrideBindingItem
(s).
OverrideBindingItem
key | value |
---|---|
keys | required (string | array of string) |
position | optional number |
name | optional string if keys is negative else required |
type | optional enum string as in BindingItem if keys is negative else required |
command | Same as BindingItem |
commands | Same as BindingItem |
args | Same as BindingItem |
bindings | Same as BindingItem |
Can you put the schemas in src/scemas
in a new branch? Then I can use the schema to validate finish this out.
from vscode-which-key.
if keys is negative else required
Do you mean position, right?
Furthermore, is args
required if type == commands?
from vscode-which-key.
Do you mean position, right?
Sorry, yes.
Furthermore, is args required if type == commands?
They are optional as not all commands need args
from vscode-which-key.
Take a look at b331678
Are the examples valid? They are validated by vscode, but I don't think the schema is that accurate at the moment and I am not a json schema expert, so feel free to edit both schemas or examples if you want.
The biggest problem at the moment is that I don't know a better way to apply the following constraint to the schemas/binding.json
file, too.
Do you know how to solve this problem? If not, I will try to figure it out by myself and if I find no way I will just copy and paste.
from vscode-which-key.
The examples seems to be correct, although it doesn't encompass the whole spectrum. It would be still be a great testing point. Thank you for getting the preliminary schema up. I'd suggest to change the schema for bidningOverrides and bindings to the array type. Ultimately, we only care if the array user entered is correct.
I also added a testing code for loading schema and validating with Ajv. It is very preliminary, you can run it by
npm run test-compile
node out/test/suite/schema.test.js
Also make sure you run npm install
to install the dependencies.
from vscode-which-key.
Related Issues (20)
- New commands do not show in default menu HOT 1
- Unable to create when condition for pin/unpin editor HOT 4
- Option to selectively hide items from menu? HOT 3
- Support for VSCode Web HOT 3
- Navigate up / back in the menu structure HOT 2
- Show key bindings in menus HOT 3
- Support partial override HOT 1
- triggerKey Not Firing from edamagit HOT 7
- Weird behaviour with Github Pull Request extension HOT 1
- `whichkey.delay` causes a delay in `SPC SPC` shortcut, others seem to be unaffected HOT 6
- Add default binding for `git pull`
- Crash when mixing `key` / `keys` and using `whichkey.sortOrder` HOT 2
- [bug/ feature?]: whichkey.searchBindings should support fuzzy search HOT 2
- [Help Wanted] Show the menu when press g HOT 3
- Debug Transient State gets closed. HOT 4
- Support several menus HOT 4
- Space keybind with vscode-neovim and the Commands option HOT 5
- `bindings` vs `bindingOverrides` and `keys` vs `key` HOT 3
- Ability to specify font for menu "keys" HOT 6
- Typos in commands
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-which-key.