cargo-script-mvs icon indicating copy to clipboard operation
cargo-script-mvs copied to clipboard

Settle on an extension

Open epage opened this issue 3 years ago • 2 comments

  • Thoughts
    • Command name might influence this (#41)
    • With the explosion of extensions, how do we decide when an extension should not be overloaded
    • A non-.rs extension can signal syntax extensions exist like she-bang support or implicit main and might help with tooling, like IDE support
  • Ideas
    • .rs (do we make the syntax legal for all .rs files)
    • .rsh (rust shell)

epage avatar Apr 25 '22 18:04 epage

From reddit

chris-morgan

Point of curiosity: have you figured out why these other things have used an extension other than .rs?

epage

My guess is two parts

  • it technically is a different format because a #! isn't valid rust (in most scripting languages, its a comment)
  • file associations on windows

Longer term, a possible benefit is editor integration for editing the cargo fragment, etc.

Now whether these are worth it is a separate conversation.

chris-morgan

Actually it is.

As for Windows file associations, although entry points for scripting languages have often taken a different file extension, they certainly haven’t always, and it’s perfectly normal to define multiple actions on a file type, e.g. batch files have two, one to execute (the default) and one to edit. I’m fairly confident that a lot more friction is caused than saved by using a different extension.

Editor integration for the Cargo fragment: let the editor look at the shebang or find such a Cargo fragment, it’s clearly marked syntactically. (I’ve had slightly imperfect TOML syntax highlighting inside such a fragment for some time locally, though it looks like it’s one of the things I haven’t got round to pushing back to the main rust.vim repository.)

epage avatar Jun 20 '22 14:06 epage

Also from reddit

I want the default action for source files to be opening them in an editor. That's what you want (spitballing) 99% of the time. .crs files were an easy way to override that on a file-by-file basis. I did briefly consider doing something similar to the py launcher on Windows that checks for the presence of a hashbang, but then I realised having some .rs files open in an editor and some compile and execute was a terrible idea.

I don't think it mattered in the end, because I've literally never seen a .crs file in the wild. It was primarily just a case of "this might be handy, might as well".

epage avatar Jun 20 '22 14:06 epage

Sticking to just .rs and file association is in the RFC as an unresolved question

epage avatar Apr 07 '23 17:04 epage