Skip to content
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

keymap option is ignored #47

Closed
edkolev opened this issue Jan 5, 2014 · 16 comments
Closed

keymap option is ignored #47

edkolev opened this issue Jan 5, 2014 · 16 comments

Comments

@edkolev
Copy link

edkolev commented Jan 5, 2014

sneak.vim doesn't respect the keymap option. Vanilla f and t do respect it. To reproduce:

  1. :set keymap=bulgarian-phonetic (or any other non-english keymap, I guess)
  2. enter абв (no english letters)
  3. fb goes to letter б (б is entered with key b) -- this is expected, just shows that f respects the keymap
  4. fbw says not found: bw -- at this point, I would expect the cursor to be placed on бв (бв is entered with keys bw)

I guess this has to do with the fact that s starts command mode, where the keymap is ignored by vim.

BTW Great plugin!

@justinmk
Copy link
Owner

justinmk commented Jan 5, 2014

Thanks for the report! Glad you like the plugin. I emailed the vim_use mailing list about this. As maybe you already know, getchar() appears to return the same keycode regardless of the current active keymap, and nr2char() returns the same character also. Also, feedkeys("b") even inserts a "b" in the current buffer, and so does norm! ib. So it appears that keymap is completely ignored by every Vim programmatic mechanism that I can think of.

Any ideas?

@edkolev
Copy link
Author

edkolev commented Jan 6, 2014

After a quick look in vim's docs, I found this (in :h mbyte-keymap):

In Insert and Command-line mode you can use CTRL-^ to toggle between using the
keyboard map or not. |i_CTRL-^| |c_CTRL-^|

I'm not sure how this can be used programmatically though (maybe with a :normal ...). I'll do some more research later if I have the time...

@justinmk
Copy link
Owner

justinmk commented Jan 6, 2014

Andy on vim_use gave a great clue about this! https://groups.google.com/forum/#!topic/vim_use/yPXKsV2Tc_c

It's a little tricky for multi-key maps (like e:: or >>) but I have it working locally. I will commit once I have the quirks worked out.

@edkolev
Copy link
Author

edkolev commented Jan 7, 2014

How about imcmdline? Maybe turning it on (default is off) after s is pressed would be simpler/safer to implement?

@justinmk
Copy link
Owner

justinmk commented Jan 7, 2014

My vim doesn't appear to have imcmdline. If you :set imcmdline, what is the result of :echo getchar() when you press the "b" key?

@edkolev
Copy link
Author

edkolev commented Jan 7, 2014

Setting imcmdline on/off doesn't make any difference to either getchar() or entering commands.. strange. Will test on vim on another platform at let you know.

On brew-installed 7.4 macvim, pressing "b" results in "98" (regardless of imcmdline)

@justinmk
Copy link
Owner

justinmk commented Jan 7, 2014

Thanks! When you :set imcmdline, what is the result of :echo &imcmdline ? It is always 0 for me, I guess because I am missing some compiler option (maybe +xim ?)

@edkolev
Copy link
Author

edkolev commented Jan 11, 2014

For some reason I can't get imcmdline to work as I expect (I expect being able to enter non-acsii chars in cmd mode when imcmdline is on). I've tried on an archlinux, ubuntu and osx. Also, compiling vim with --enable-xim and/or --enable-multi-byte didn't enable xim (-xim is printed by version()). Probably I'm missing something...

Anyway, I don't think modifying imcmdline would actually make any difference. After setting a keymap and trying

  • nmap z :<c-^>Sneak 2<cr>
  • nmap z :<c-^>echo getchar()<cr>

it seems to me that getchar() is not related to command mode in any way... it just gets the next pressed char...

Maybe the solution here would be not to support multi-key chars in vim-sneak

@justinmk
Copy link
Owner

it seems to me that getchar() is not related to command mode in any way.

I think that might be the case. But I have a pretty good hack working. I will commit next week

@edkolev
Copy link
Author

edkolev commented Jan 23, 2014

Throwing in an idea:
Maybe feedkeys() can be used. A quick test reveals it's affected by the input method (keymap) as long as "t" is passed as second argument, like so call feedkeys("az", "t") - this appends a з (which is typed in by z).

Not sure if this could be of any use...

@justinmk
Copy link
Owner

Cool! Great find. Will test

justinmk added a commit that referenced this issue Jan 31, 2014
@justinmk
Copy link
Owner

Hey, the changes are available in this branch: https://github.com/justinmk/vim-sneak/tree/mbyte-keymap

It looks for &iminsert == 1, otherwise it ignores the keymap. I thought about adding support for ctrl-^ within the sneak input-prompt, but decided that might be overkill. Would you normally have the keymap activated already before invoking s, or would you want some way to toggle it during the prompt?

@justinmk
Copy link
Owner

It works pretty well, except invalid sequences will keep accepting input until you hit <esc> or <enter>. It also doesn't show very good feedback about the currently pending multi-character sequence. (todo)

@edkolev
Copy link
Author

edkolev commented Feb 2, 2014

Nice! I tested it and didn't find any issues.

Regarding ctrl-^, I think it would be an overkill. There's a little chance that someone will have an English char next to a non-English char AND he would wan't to sneak up to these 2 chars.

Regarding multi-byte keymaps, I think that might also be an overkill for the bulgarian-phonetic keymap. I've never used another keymap, so I don't know how much use they make of multi-byte chars. Looking at the (distributed with vim) keymaps in runtime/keymap, I see some keymaps make heavy use of them, while others don't define any mbyte chars. If it were up to me - I would keep the source cleaner and the functionality limited, i.e. I would want a cleaner (hack-less) source tree and a 99% feature completeness, rather than 100% features and a hairy source tree.

Anyway, maybe it does make sense to support mbyte chars in vim-sneak.

BTW it seems some bozo decided to add Russian characters in bulgarian-phonetic, hence the mbyte chars http://vim.1045645.n5.nabble.com/keymap-files-for-Bulgarian-td1155752.html I'll contact him and ask him why didn't he include all freakin alphabets in bulgarian-phonetic, just Russian :)

Anyway, thank you for your work!

justinmk added a commit that referenced this issue Feb 7, 2014
@justinmk
Copy link
Owner

This is in the main branch now. In case you use streak-mode, there's still a known highlighting bug with multibyte chars like абв. #27

@edkolev
Copy link
Author

edkolev commented Feb 11, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants