feat(find_root): add `$ROOT` environment variable detection
fix https://github.com/helix-editor/helix/issues/4342
You can use ROOT=$PWD hx src/main.rs to specify the project root if helix is failed to detect the unusual project structure.
This allows helix to work under any path, like
ROOT=$PWD/interactive-demo hx interactive-demo/src/main.rs or
ROOT=/rust/github/crossterm/examples/interactive-demo hx /rust/github/crossterm/examples/interactive-demo/src/main.rs.
I think the root detection rule needs to be documented in the book. I can do it.
This would also be a very nice CLI flag tbh, because I believe a common user pattern with CLI software is to run:
and then understand some capabilities, I advocated earlier in element ( Matrix ) for having a Clap based CLI options, and this would be one of those usecases, where clap could give both discoverability, and some documentation of the feature as in a standardised way
we ended up solving this a different way with https://github.com/helix-editor/helix/pull/5748 with a project local config file instead (so you don't have to specify it on each startup). The implemented solution also allow multiple different roots for a single running helix instance (so you can still open the normal crossterm files too in your example) .Forcing all lsps to the same root with a single environment variable tends to also not work for mulpi language projects so I don't think we will be going forward with this.
we ended up solving this a different way with #5748 with a project local config file instead
it would be great if it was possible to use it from commandline too. a typical use case is to quickly explore a few examples/foo in a big unknown project. i can do hx ., but it affects filepicker only once untill lsp starts.
We usually don't add CLI options. There isn't any CLI flrags to set config options either. You can fairly quickly open the local config file (there is even a command for it), edit the config and then reload.
This is also not about the file picker. The file picker is not affected by LSP root detection. There is already commands to open the file picker in theCWD and current buffer dir. That should be sufficient for that usecase