cespare / vim-toml

Vim syntax for TOML
MIT License
625 stars 40 forks source link

utf-8 support #49

Closed alehresmann closed 4 years ago

alehresmann commented 4 years ago

Hello,

it looks like not all syntax highlighting works when working with certain characters from utf-8:

see for instance the following example in toml:

[hello] [héllo]

test = 1 tést = 2 test2 = 3 ∪nion = 4

I get the following syntax highlighting:

2020-01-16-161759_1581x859_scrot

I do highlight that my file was indeed a utf-8 file, as defined by the TOML spec: $ file -i example.toml example.toml: text/plain; charset=utf-8

cespare commented 4 years ago

Sorry, but that isn't valid TOML.

Quoting the TOML spec:

Bare keys may only contain ASCII letters, ASCII digits, underscores, and dashes (A-Za-z0-9_-). Note that bare keys are allowed to be composed of only ASCII digits, e.g. 1234, but are always interpreted as strings.

[examples]

Quoted keys follow the exact same rules as either basic strings or literal strings and allow you to use a much broader set of key names. Best practice is to use bare keys except when absolutely necessary.

Therefore, Héllo is not a valid TOML key; it must be quoted as "Héllo".

Similarly for tables:

Naming rules for tables are the same as for keys (see definition of Keys above).

If you quote these names, you'll see that vim-toml handles it correctly:

screen_20200116135151