Giter VIP home page Giter VIP logo

Comments (16)

justinmk avatar justinmk commented on May 12, 2024

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?

from vim-sneak.

edkolev avatar edkolev commented on May 12, 2024

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...

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

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.

from vim-sneak.

edkolev avatar edkolev commented on May 12, 2024

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

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

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?

from vim-sneak.

edkolev avatar edkolev commented on May 12, 2024

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)

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

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 ?)

from vim-sneak.

edkolev avatar edkolev commented on May 12, 2024

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

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

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

from vim-sneak.

edkolev avatar edkolev commented on May 12, 2024

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...

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

Cool! Great find. Will test

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

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?

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

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)

from vim-sneak.

edkolev avatar edkolev commented on May 12, 2024

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!

from vim-sneak.

justinmk avatar justinmk commented on May 12, 2024

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

from vim-sneak.

edkolev avatar edkolev commented on May 12, 2024

Thanks!

from vim-sneak.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.