nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.31k stars 1.69k forks source link

helix: consider running `hx --grammar fetch && hx --grammar build` on activation #5218

Open britter opened 3 months ago

britter commented 3 months ago

Description

When configuring custom grammars using the languages option, one needs to remember to run hx --grammar fetch and hx --grammar build. Otherwise the newly configured grammar does not work. This could be added as an activation step, much like the one for bat.

britter commented 3 months ago

Pinging maintainer @Philipp-M. WDYT?

teto commented 3 months ago

usuallly you would install those grammars via, wouldn't you ? not using hx but that's how nix+neovim does it

Philipp-M commented 3 months ago

I'm not sure whether that should be in a default activation hook, it takes some time, and I doubt that custom grammars are used by a lot of people. But I think this could be done though, when programs.helix.languages.grammar is set. I'm happy to review a PR doing that.

usuallly you would install those grammars via, wouldn't you ? not using hx but that's how nix+neovim does it

(I'm guessing you meant "Nix") Unfortunately not that easy yet in helix, see the discussion in https://github.com/nix-community/home-manager/issues/2871#issuecomment-1264459501. At some point, I think that feature could be added upstream, as I think installing via nix is certainly cleaner.

britter commented 2 months ago

@Philipp-M I can give it a shot. Not sure when I will get to it though. Maybe we can call fetch and build only for the grammars that are explicitly defined in languages. I don't recall whether the commands take a grammar name as an argument. Will check.

SrEstegosaurio commented 2 months ago

I think it only builds things defined in languages.toml as per the help message: -g, --grammar {fetch|build} Fetches or builds tree-sitter grammars listed in languages.toml

Also it fails since it need a toolchain present for building them, which I think should not be done outside of nix.

britter commented 2 months ago

@SrEstegosaurio as far as I can tell on my system it builds both, the built in grammars defined in the languages.toml that it ships with as well as the user supplies grammars from the user space language.toml.

SrEstegosaurio commented 2 months ago

I might mention that I'm using the h-m module in conjunction with the upstreram latest nix pacakge.

@britter do you happen to have a C/C++ compiler globally available?

britter commented 2 months ago

No, I load it into nix shell when I need to rebuild grammars. That works well enough for me.