bungcip / better-toml

toml extension for vs code editor
74 stars 13 forks source link

Add Cargo.toml schema validation #3

Closed bungcip closed 7 years ago

bungcip commented 7 years ago

Add builtin Cargo.toml schema to validate rust project that use cargo.

bluejekyll commented 7 years ago

I'll second this, getting an error in validation with Cargo.toml, example:

...
[target.'cfg(target_os = "macos")'.dependencies]
security-framework = "^0.1.10"

Error:

file: 'file:///Users/.../Development/rust/trust-dns/client/Cargo.toml'
severity: 'Error'
message: 'Expected "\"", [ \t] or [A-Za-z0-9_\-] but "'" found.'
at: '64,10'
source: 'Toml Parser'
bungcip commented 7 years ago

hi, @bluejekyll. Thanks for reporting. better-toml use `toml-node (https://github.com/BinaryMuse/toml-node) as its parser. There is a bug in their implementation which not support single quote key. I already report the bug here (https://github.com/BinaryMuse/toml-node/issues/34).

You can workaround the problem by switching ' to " like this:

[target."cfg(target_os = 'macos')".dependencies]

but now you will hit with another bug -_-; (https://github.com/BinaryMuse/toml-node/issues/33).

I already planning to write a new toml parser because toml-node only output is json. Which is too simple for editor need.

BinaryMuse commented 7 years ago

toml-node only output is json. Which is too simple for editor need.

@bungcip Is there something I could add that would enable the use case you need?

bungcip commented 7 years ago

hi @BinaryMuse, For my use case, I need toml-node to produce some AST node which contain information about line, column, and its type (like table, key, or value).

Currently, to get the line & column number, I basically doing this: toml.parse(input) -> js -> dump to json -> get line & column in json ouput

which is wrong when you have some strange toml file like this: image

GabrielMajeri commented 7 years ago

Hi, the issue with the single quotes has been fixed in toml-node v2.3.2, could you perhaps upgrade this plugin to use a newer version and close this bug?

bungcip commented 7 years ago

new version of better-toml just released. sory for delay.