4 ms·
I really like this approach from the dotnet world but with one caveat. The language server assumes a project layout and doesn't allow for any variation from tha
by flukus 10y ago
I really like this approach from the dotnet world but with one caveat. The language server assumes a project layout and doesn't allow for any variation from that. This has problems when you're generating code, say a web service interface or some lexx/yacc source. I like these to go in my build output (because they're build artifacts not source material), but AFAIK you can't tell the language server to also look at these files.
Another example is when you want to share code between projects without a seperate dll, like with a client/server model. Easy enough to do with make et al but not with a language server.
Neither problem is insurmountable though.
- Manishearth 10y agoRLS plugs into the compiler so I assume that it can pick up build output files that are to be compiled in.
- flukus 10y agoAFAIK (unless the rust one is very different to the .net one) it maintains it's own state by looking at the source, not at the compiled output. Adding a class in a new file should make it visible in intellisense before the code is recompiled.
- Manishearth 10y agoThe server-side of the Rust one will be completely different from the .net one. It just shares a protocol.
- demarq 10y agoWhile yes, it can be a pain, I love that rust makes it hard to be a special snowflake. It promotes everyone following set conventions and makes it easier to grok other peoples work. rust's powerful macros are an exception to this, I guess.
- flukus 10y agoIs there a convention for the placement of generated code?
- ekidd 10y agoYes. Cargo supports build.rs scripts that build code into a special directory reserved for code generation, IIRC. The cargo people generally think this sort of thing through.
- flukus 10y agoOk, I checked it out (http://doc.crates.io/build-script.html http://doc.crates.io/build-script.html) Would have been much better if you could tell it the dependencies instead of having to use yet another make clone (and a bad one at that) though.
- ekidd 10y ago> Would have been much better if you could tell it the dependencies instead of having to use yet another make clone (and a bad one at that) though. It's not intended to be used like make, with lots of shell scripts in a Makefile. Instead, you write all the actual build code for a given task once, and package it in a Rust crate, which can then be pulled as a build-time dependency. So, for example, there's a cmake crate (https://docs.rs/cmake/0.1.20/cmake/ https://docs.rs/cmake/0.1.20/cmake/) that handles any project using cmake. If you just have one of two glue files written in C, you use the gcc crate (http://alexcrichton.com/gcc-rs/gcc/index.html http://alexcrichton.com/gcc-rs/gcc/index.html), which—despite the name—can also handle other C compilers on other platforms. And if you need to generate code for a perfect hash function, you use phf (https://docs.rs/phf_codegen/0.7.20/phf_codegen/ https://docs.rs/phf_codegen/0.7.20/phf_codegen/). And so on. If you run into some other kind of common pattern across many projects, just write and publish another crate, and call it from build.rs. These libraries typically do a lot of work to handle things like cross-platform compatibility. If you already assume the programmer (1) knows Rust, and (2) might be running on either Linux, MacOS or Windows, this sort of interface is much more convenient than requiring them to get Makefiles and shell scripts working, and to handle per-platform compiler invocation issues, etc.