helix icon indicating copy to clipboard operation
helix copied to clipboard

feat(find_root): add `$ROOT` environment variable detection

Open zjp-CN opened this issue 3 years ago • 2 comments

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.

zjp-CN avatar Oct 19 '22 09:10 zjp-CN

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.

zjp-CN avatar Oct 19 '22 09:10 zjp-CN

This would also be a very nice CLI flag tbh, because I believe a common user pattern with CLI software is to run:

--help

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

TotalKrill avatar Oct 31 '22 10:10 TotalKrill

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.

pascalkuthe avatar Jul 14 '23 22:07 pascalkuthe

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.

univerz avatar Jul 28 '23 22:07 univerz

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

pascalkuthe avatar Jul 28 '23 22:07 pascalkuthe