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

Add ambiwidth option #116

Open
sei40kr opened this issue Mar 10, 2022 · 2 comments
Open

Add ambiwidth option #116

sei40kr opened this issue Mar 10, 2022 · 2 comments

Comments

@sei40kr
Copy link

sei40kr commented Mar 10, 2022

I want an option to tell Neovim what to do with East Asian Width Class Ambiguous.

Neovim already has ambiwidth option but it's unstable since it applies to all the characters in Neovim.

						*'ambiwidth'* *'ambw'*
'ambiwidth' 'ambw'	string (default: "single")
			global
	Tells Vim what to do with characters with East Asian Width Class
	Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek
	letters, Cyrillic letters).

	There are currently two possible values:
	"single":	Use the same width as characters in US-ASCII.  This is
			expected by most users.
	"double":	Use twice the width of ASCII characters.
							*E834* *E835*
	The value "double" cannot be used if 'listchars' or 'fillchars'
	contains a character that would be double width.

	There are a number of CJK fonts for which the width of glyphs for
	those characters are solely based on how many octets they take in
	legacy/traditional CJK encodings.  In those encodings, Euro,
	Registered sign, Greek/Cyrillic letters are represented by two octets,
	therefore those fonts have "wide" glyphs for them.  This is also
	true of some line drawing characters used to make tables in text
	file.  Therefore, when a CJK font is used for GUI Vim or
	Vim is running inside a terminal (emulators) that uses a CJK font
	(or Vim is run inside an xterm invoked with "-cjkwidth" option.),
	this option should be set to "double" to match the width perceived
	by Vim with the width of glyphs in the font.  Perhaps it also has
	to be set to "double" under CJK MS-Windows when the system locale is
	set to one of CJK locales.  See Unicode Standard Annex #11
	(http://www.unicode.org/reports/tr11).

I've already implemented this in my dotfiles, so I want to port this to upstream.
https://github.com/sei40kr/dotfiles/blob/master/config/neovim/lua/config/plugins/nvim-web-devicons.lua#L14-L18
https://github.com/sei40kr/yonvim/blob/main/lua/yvim/plugin/web-devicons.lua

@sei40kr sei40kr changed the title Add Add ambiwidth option Mar 10, 2022
@kyazdani42
Copy link
Member

i'm not sure this should be implemented here, maybe plugin authors using this could manage it themselves ? So just a documentation improvement would be needed ?

@sei40kr
Copy link
Author

sei40kr commented Aug 10, 2022

@kyazdani42
Sorry for my late repsonse.

I think it should be implemented here.

I noticed Vim already have setcellwidths() to set the cell widths of specific unicode characters.
And recently same feature has been merged to Neovim upstream in neovim/neovim#19686.

So in the near future, we can provide the default cell width for each icon easily using setcellwidths(), like vim-ambiwidth does.

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