CppCXY / EmmyLuaCodeStyle

fast, powerful, and feature-rich Lua formatting and checking tool.
MIT License
138 stars 26 forks source link

Table alignment fails when there are non-latin characters #146

Closed gepbird closed 11 months ago

gepbird commented 11 months ago

When there are non-latin characters (eg. é) in an array, align_array_table formatting doesn't work.

Also reproducible with default settings.

only_latin = {
  { 'aaaa', nil },
  { 'e',    nil },
}

with_non_latin = {
  { 'aaaa', nil },
  { 'é', nil }, -- nil should be followed by spaces
}

lua-language-server version: 3.7.0

CppCXY commented 11 months ago

This is by design, because non-ASCII characters I can't assume how wide they will be rendered on your editor, and in my work environment, non-ASCII characters and general English letters are not the same width, and they simply don't align correctly, so I detect that non-ASCII characters will abandon alignment if there are non-ASCII characters except for end-of-line comments

gepbird commented 11 months ago

@CppCXY Thanks for your quick response as always!

What about extending the allowed list of characters from ASCII to UTF-8 Basic Latin and Latin-1 Supplement (from U+0000 to U+00FF)? I'm pretty sure these characters render the same everywhere.

CppCXY commented 11 months ago

I need to do a lot of character set work, which C++ naturally lacks, My algorithm also needs to be revised, and my current focus is not on this project, so it will not be updated in such a timely manner

CppCXY commented 11 months ago

@CppCXY Thanks for your quick response as always!

What about extending the allowed list of characters from ASCII to UTF-8 Basic Latin and Latin-1 Supplement (from U+0000 to U+00FF)? I'm pretty sure these characters render the same everywhere.

but it is rendered as two characters: "¬­®", In fact, it is three characters

CppCXY commented 11 months ago

You can update the latest version from sumneko and then manually update this submodule, I will not release this version for the time being

CppCXY commented 11 months ago

It took 7-13% more time to implement this feature, and I needed to check if it was necessary

gepbird commented 11 months ago

You can update the latest version from sumneko and then manually update this submodule, I will not release this version for the time being

I cloned lua-language-server recursively, updated this submodule (I saw your latest commit in the git log), ran ./make.sh, symlinked the generated bin/lua-language-server to ~/.local/share/nvim/mason/bin/lua-language-server and it behaves the same as before: formatting the snippet I started with in this issue is the same, it is not fixed. Probably I messed up something and its using the old version, I'm not sure.

I'm happy to wait a few weaks until you and sumneko make a new release.

CppCXY commented 11 months ago

please try https://github.com/CppCXY/lua-language-server/actions/runs/6447382434 I test: image