t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

Add service to allow custom commands to hook in #1070

Open calebmeyer opened 6 years ago

calebmeyer commented 6 years ago
debug info ```json { "atom": "1.27.0", "platform": "win32", "release": "10.0.16299", "vmpVersion": "1.32.0", "vmpConfig": { "automaticallyEscapeInsertModeOnActivePaneItemChange": true, "keymapBackslashToInnerCommentOrParagraphWhenToggleLineCommentsIsPending": true, "keymapCCToChangeInnerSmartWord": true, "keymapPToPutWithAutoIndent": true, "keymapUnderscoreToReplaceWithRegister": true, "keymapYToYankToLastCharacterOfLine": true, "showHoverSearchCounter": true, "statusBarModeStringStyle": "long", "useSmartcaseForSearch": true, "useSmartcaseForSearchCurrentWord": true, "wrapLeftRightMotion": true, "blackholeRegisteredOperators": [], "startInInsertModeScopes": [], "charactersToAddSpaceOnSurround": [], "highlightSearchExcludeScopes": [], "flashOnOperateBlacklist": [] } } ```

Read and check all "Check list" bellow.

Check list

You have to check all before open issue.

What

I'd like for vim mode plus to provide a service that custom commands can hook into. Specifically, I'd like to be able to find out the current count from the OperationStack.

Why

I maintain the VMP macros package, and I have a request: https://github.com/calebmeyer/vim-mode-plus-macros/issues/5 to use VMPs count to replay macros more than once.

This would also allow for other packages to implement VMP commands and have them feel more native.

t9md commented 6 years ago

I think you can get count of current operation stack like this.

const vimState = service.getEditorState(editor)
const countOfCurrentOperationStack = vimState.operationStack.getCount()

For how to access service of vmp from your pkg, see vim-mode-plus-ex-mode as example and also read Atom's official documentation describing how service works.

[NOTE]