rust-lang / rust.vim

Vim configuration for Rust.
Apache License 2.0
3.91k stars 297 forks source link

Please recommend a preferred toml mode for Cargo.toml #91

Open joshtriplett opened 8 years ago

joshtriplett commented 8 years ago

Please consider recommending a mode to use when editing Cargo.toml files, and linking to that from README.md.

(If such a mode provides a way to customize it to recognize Cargo-specific keys and values and do syntax checking, even better.)

mbyio commented 8 years ago

I think you mean plugin, not mode, right?

Including special syntax highlighting for Cargo-specific keys sounds like a good idea to me.

The only existing vim plugin for toml that I could find is cespare/vim-toml (I didn't test it). I'm not sure it's maintained though, so it probably makes sense to include a toml syntax file in rust.vim instead (and maybe only activate it for files named Cargo.toml, to avoid conflicting with other toml plugins). This would also make it easier to add special syntax highlighting for official settings.

joshtriplett commented 8 years ago

On July 29, 2016 2:48:10 PM PDT, "Michael B. Younkin" notifications@github.com wrote:

I think you mean plugin, not mode, right?

Plugin providing a filetype, yes.

Including special syntax highlighting for Cargo-specific keys sounds like a good idea to me.

The only existing vim plugin for toml that I could find is cespare/vim-toml (I didn't test it). I'm not sure it's maintained though, so it probably makes sense to include a toml syntax file in rust.vim instead (and maybe only activate it for files named Cargo.toml, to avoid conflicting with other toml plugins). This would also make it easier to add special syntax highlighting for official settings.

I've used that exact vim-toml plugin, and it seems to work well; it has some Rust additions too, such as recognizing Cargo.lock as toml.

I'd definitely love to see it extended to highlight official keys, though.


You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/rust-lang/rust.vim/issues/91#issuecomment-236302293

mbyio commented 8 years ago

Hm, IMO that plugin probably should leave the Rust specific stuff to rust.vim, but it's a different project so whatever.

It's not really ideal for one Vim plugin to depend on another. Personally I'd rather have rust.vim just include all the toml stuff.

This is a feature that'd be relatively easy to implement either way though.

Maybe an actual rust.vim maintainer would care to comment?

chris-morgan commented 8 years ago

I think that having cargotoml and cargolock filetypes with a kind of validation built into the highlighting would be a good idea. However, I’m not intending to implement it in the near future myself. If someone else wants to, well and good; I’ll review it.

mbyio commented 8 years ago

@chris-morgan would be okay with having all the toml stuff as part of this plugin, or should rust.vim depend on cespare/vim-toml and add on the extra validation only if it's installed?

Personally, I'm in favor of just including it in this plugin, especially since cespare/vim-toml doesn't seem to be maintained. But either solution is justifiable.

chris-morgan commented 8 years ago

@michael-younkin Depending on cespare/vim-toml doesn’t make it Just Work™, and we can’t simply embed it because of licensing (their MIT vs. our Apache2/MIT), so seeking relicensing or writing a new syntax file (not difficult) is the way to go.

I feel that vim.rs probably shouldn’t provide a toml syntax file. Maybe name it something else, e.g. rusttoml. Then again, if it were just exactly that, maybe it wouldn’t be so bad to collide. So long as compatibility is maintained, so that layering of syntax files can be done and work regardless of cespare/vim-toml availability. If doing things that way, we’d be setting 'filetype' to toml.cargotoml and toml.cargolock.

Eh, I dunno. I’d need to try implementing it all to decide how it should be done.

doesn’t seem to be maintained.

(Sometimes software is simply complete.)

joshtriplett commented 8 years ago

@chris-morgan What about submitting some patches to vim-toml to allow extending it with a list of known keys to highlight, telling people to package vim-toml for use with Cargo.* files, and then using that extension to highlight Cargo keys?