-
Notifications
You must be signed in to change notification settings - Fork 35
Added support for repeat.vim. #9
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
base: develop
Are you sure you want to change the base?
Conversation
I'm afraid I'm going to have to reject this one. Vim's repeat command is for repeating text changes - the common use is to do a change, move the cursor somewhere else, and hit So - if I do a textual change, call vebugger's step-over, and press repeat, the current behaviour(which is also the one I expect) is that the text change will be repeated. Instead, you suggest that the step-over will be repeated. Not to mention the fact that step-over is not undoable - which means that after I do this mistake, I can't hit As a side note - repeat doesn't have to be a mandatory requirement. While it's true that it's hard to detect the presence of autoloaded functions - in repeat's case you don't have to. All you have to do is call it with |
In that case, what if I removed the call to repeat#set, but left the VBGrepeat mapping in? (Alternatively, I could just hide the call to repeat#set behind a setting that is disabled by default.) The main motivation for this patch is that it's a pain to type '\di' to keep stepping forward, but adding a single-key mapping to each of the step commands is just wasteful. I think there is a strong argument for the convenience of being able to repeat the last vebugger command, it's just that using '.' for it might not be the best idea. |
repeat.vim works by storing the last repeatable command's info in global variables. You can probably do the same with your own global(or script) variables, and make you own keymapable command for repeating them. |
The problem is there's no nice way to get the last vebugger command performed without some kind of hook in the plugin. You can get the last ex command using the : register, but that can be overwritten by other ex commands and doesn't include commands performed via maps. AFAIK, the only effective way to handle it in a vimrc is to redefine all of the commands and mappings used for vebugger to call a wrapper function. I suppose in the end the code doesn't look too different either way, although I can't help but think that if you've got to the stage where you're redefining most of the plugin's UI layer, it would just make more sense to patch the plugin itself... |
Maybe I explained myself wrong. I didn't say not to register the last vebugger command in some hook inside the plugin - what I said is not to register them using repeat.vim's |
3d1e500
to
d2a1d0f
Compare
mapping for repeating commands.
d2a1d0f
to
4a32590
Compare
OK, so something like this then? (Obviously it needs documentation and the remaining commands should be fixed to use the wrapper function for consistency - I just wanted to make sure I understood you correctly regarding how the hook should be defined.) |
What is |
A function to be defined in the user's vimrc (i.e. the aforementioned hook), which is called after each vebugger command. Said function can be used to set global variables (enabling a 'repeat vebugger command' mapping), call repeat#set, etc. as per the user's preference. |
If you are making an extension hook, make it right. The main users of extension hooks are not human Vim users, but other plugins that extend Vebugger. But such plugins will have to ask the user to call the plugin functions inside the user's Personally, I think that having a post-cmd just for registering the command is an overkill, but if you still want this extension hook I suggest a different approach:
If you don't mind, I'd rather implement this thing myself, since it requires some modification to the activation path of the commands(I don't want the |
Sure, that sounds fine. Autocmds are definitely the better approach to take, it just didn't occur to me to use them. |
@rdnetto I've pushed it to I've also added Please check it out and see if there is anything you want to add/change. At any rate, it'll be a while before I make a new release - this is a breaking change which means bumping the major version, and I want to push some more big features(watchers, catching exceptions, moving up&down the backtrace) before I release version 2.0. |
Overall it looks good, but there is one thing I'd like to change: |
Well, the idea was that even if an event listener throws, the user action will still happen(because I'd like to avoid breaking the main functionality of the plugin just because some other plugin has errors...), but your point about it making the event listeners harder to debug is valid. I've changed it to use BTW - this has nothing to do with |
This PR should be closed, the feature is implemented as far as is planned. |
This patch allows stepping in, etc. to be repeated using the '.' key.
It adds a dependency on tpope's repeat.vim. (Detecting if it is available is non-trivial as it is autoloaded, so making it optional is somewhat tricky.) I suspect most people who are interested in using vim-vebugger probably have it installed already anyway, so it probably doesn't matter too much.