helix: ship nix-shell syntax highlighting
This commit is contained in:
parent
62907acedc
commit
975bdd64cb
|
@ -2,6 +2,7 @@
|
|||
, fetchFromGitea
|
||||
, htmlq
|
||||
, tree-sitter
|
||||
, tree-sitter-nix-shell
|
||||
}:
|
||||
|
||||
tree-sitter.buildGrammar {
|
||||
|
@ -24,6 +25,15 @@ tree-sitter.buildGrammar {
|
|||
'';
|
||||
doCheck = true;
|
||||
|
||||
passthru = {
|
||||
generated = tree-sitter-nix-shell.overrideAttrs (orig: {
|
||||
# provide a package which has the output of `tree-sitter generate`, but not the binary compiled parser
|
||||
buildPhase = "true";
|
||||
installPhase = "cp -r . $out";
|
||||
checkPhase = "true";
|
||||
});
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "parse `#!/usr/bin/env nix-shell` scripts with tree-sitter";
|
||||
homepage = "https://git.uninsane.org/colin/tree-sitter-nix-shell";
|
||||
|
|
|
@ -97,6 +97,8 @@ let
|
|||
|
||||
gocryptfs = callPackage ./patched/gocryptfs { inherit (unpatched) gocryptfs; };
|
||||
|
||||
helix = callPackage ./patched/helix { inherit (unpatched) helix; };
|
||||
|
||||
# jackett doesn't allow customization of the bind address: this will probably always be here.
|
||||
jackett = callPackage ./patched/jackett { inherit (unpatched) jackett; };
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{ helix
|
||||
, rsync
|
||||
, substituteAll
|
||||
, tree-sitter-nix-shell
|
||||
}:
|
||||
|
||||
let
|
||||
languages = substituteAll {
|
||||
src = ./languages.toml;
|
||||
tree_sitter_nix_shell = tree-sitter-nix-shell.generated;
|
||||
};
|
||||
in
|
||||
helix.overrideAttrs (upstream: {
|
||||
configurePhase = (upstream.configurePhase or "") + ''
|
||||
cat ${languages} >> languages.toml
|
||||
substituteAllInPlace languages.toml
|
||||
|
||||
${rsync}/bin/rsync -arv ${tree-sitter-nix-shell.generated}/ runtime/grammars/sources/nix-shell/
|
||||
${rsync}/bin/rsync -arv ${tree-sitter-nix-shell}/queries/ runtime/queries/nix-shell/
|
||||
|
||||
# helix tries to delete the sources during installPhase
|
||||
chmod -R +w runtime/grammars/sources/nix-shell
|
||||
'';
|
||||
})
|
|
@ -0,0 +1,22 @@
|
|||
# Helix text-editor interprets this file as documented here:
|
||||
# - <https://github.com/helix-editor/helix/blob/master/book/src/languages.md>
|
||||
#
|
||||
# hack in support for nix-shell documents
|
||||
# these have a shebang of `#!/usr/bin/env nix-shell`
|
||||
# and a subsequent line: `#!nix-shell -i <lang> [args]`
|
||||
[[language]]
|
||||
name = "nix-shell"
|
||||
scope = "source.nix_shell"
|
||||
shebangs = [ "nix-shell" ]
|
||||
file-types = [ "nix-shell" ]
|
||||
injection-regex = "nix-shell"
|
||||
indent = { tab-width = 2, unit = " " }
|
||||
roots = []
|
||||
grammar = "nix-shell"
|
||||
|
||||
[[grammar]]
|
||||
name = "nix-shell"
|
||||
source = { path = "@tree_sitter_nix_shell@" }
|
||||
# source = { path = "/home/colin/dev/tree-sitter-nix-shell" }
|
||||
# source = { git = "https://git.uninsane.org/colin/tree-sitter-nix-shell", rev = "c2fcc8b6ee91af2cb58a38f62c0800f82d783738" }
|
||||
|
Loading…
Reference in New Issue