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

Mac OS + Vim + Accent characters #466

Closed
kenan-rhoton opened this issue Apr 18, 2018 · 7 comments
Closed

Mac OS + Vim + Accent characters #466

kenan-rhoton opened this issue Apr 18, 2018 · 7 comments

Comments

@kenan-rhoton
Copy link

Expected behavior:

When using vim within kitty within MacOS, and typing something containing accents, like for example:

Déjà vu

I would expect it to appear in vim as typed, and for the accented character to behave as a single character. In particular, i should be able to modify the above sentence into

Déjí vu

By simply hovering over the à character and typing the sequence r´i.

Actual behavior:

Upon typing:

Déjà vu

What visually appears is:

Dé j| vu (Note the spaces after each accented character and the "wrong" grave accent)

However, in order to replace "correctly", i need to both remove the accented character and the following space, but this space has some very "interesting properties":

  1. If the file is saved and reloaded, the space will not appear visually, but the text will behave as if it were there, which means that you cannot visually determine where a character is in a given line if there is an accented character previously.
  2. This behavior continues as long as that space exists, which you can remove despite not seeing it by inferring it from previous behavior.
  3. Replacing the space without changing the previous character replaces both characters.

The consequence of this is that vim is unusable under Kitty when working in a language that requires accented characters (such as Spanish).

I believe this is related to the characters being composed of two unicode characters combined, and it's possible it may be more of a vim issue (maybe even some configuration unknown to me could solve it).

@kovidgoyal
Copy link
Owner

kovidgoyal commented Apr 18, 2018

The way to add an acute accent to a character in macOS is by

  1. Set macos_option_as_alt to no in kitty.conf
  2. In insert or replace mode in vim (or indeed in any macOS text control) type Option+e and then the letter. This will produce the accented letter as single unicode codepoint that should work fine in vim.

I'm not sure why you think typing ´i will do what you want. Is that something vim specific? And how are you typing the ´ in that?

Most accented letters are represented in unicode in two possible ways, either as single codepoints, or in "decomposed" form as two code points, the base letter and the combining diactritical mark. For example
é can be represented as either U+00e9 or U+0065 U+0301

In neither of those representations is U+00b4 involved (the accent character you are using which is the non-combining form of the accent involved)

Note that currently it's possible that step two above will not work in kitty because of a bug, see #465

@kovidgoyal
Copy link
Owner

If it does not work you can work around it by using the send_text feature of kitty. Something like:

map ctrl+shift+x send_text \u0301

Then typing e and then pressing ctrl+shift+x should produce é

@kovidgoyal
Copy link
Owner

Actually, no, 2. not working is not caused by #465 but by a fundamental limitation of glfw on macOS, it does not support dead keys at all. glfw/glfw#41

So while simple compose option key + letter will work, dead keys wont work. Best to use the send_text work around I documented above.

@kenan-rhoton
Copy link
Author

The map ctrl+shift+x send_text all \u0301 workaround is not working, it's inserting an ~A instead. Other options mentioned do nothing at all.

As for the typing of `i producing ì, that is simply how it works normally on my spanish keyboard when inputting text anywhere.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Apr 18, 2018

WOrks for me, steps I tried:

  1. Add
map ctrl+shift+x send_text all \u0301

to kitty.conf

  1. Start kitty and run: cat

  2. Type i and then press ctrl+shift+x
    The terminal displays: ì

@kenan-rhoton
Copy link
Author

The above works within cat (displaying í) but not within vim (displaying i~A )

@kovidgoyal
Copy link
Owner

Works in vim as well for me although I tried with an upto date vim, not the one that comes with macOS (version 8.0 patch level 1542). In any case vim has its own method for inputting accents called digraphs, IIRC it works with ctrl+V but check :help digraph

As for the native macOS method, as I said, it will need towait for support for dead keys in macOS to be added to glfw, see #465

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

No branches or pull requests

2 participants