Custom operators
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
I'd like to help make it possible for VscodeVim to interact with other plugins by defining custom operators. I'd like to try to implement this myself, if possible, but I would benefit from pointers and some indication of how difficult this would be to do actually do.
Essentially, what I'd like is some interface where, within a new VSCode extension I can define:
vscodevim.defineOperatorCommand('name_of_new_operator','my-extension.command-name')
command = vscode.commands.registerCommand('my-extension.command-name',
(start: number? stop: number?) => {
if(!start && !stop){
// non-operater version of the command...
// (e.g. maybe do something with the currently selected text)
}else{
// operator version of the command...
// (e.g. use the text denoted by the start and stop positions)
}
})
And then I can define a vim shortcut for this operator, like so:
"vim.normalModeKeyBindings": [
{
"before": ["leader", "."],
"after": [],
"commands": [
{
"command": "name_of_new_operator",
"args": []
}
]
},
The expected behavior would be that if I typed <leader>.iw with the above setup, vscodevim would apply the function for 'my-extension.command-name', passing it the position of the first (start) and last (end) character of the current word. Likewise <leader>.ip would apply the function, passing the position of the first and last character of the current paragraph.
I recognize I am probably I long way off from doing this with my current knowledge about how to write VSCode extensions, and the codebase of VSCode vim, and I'm not asking for anyone to do the work to figure this out for me, but any pointers as to where to begin to figure out how to implement this in VSCodeVim, or an indication that this isn't really possible (and therefore I can avoid wasting my time trying to figure it out) would be appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests; begin by tracing VSCodeVim's command and keybinding entry points and the VS Code extension command interface. Determine whether a custom operator can receive start and end positions from motions such as iw and ip. Done would mean a defined extension interface and verified operator behavior, or a documented feasibility limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100