Skip to content

Commit

Permalink
tree-sitter: add shell completions
Browse files Browse the repository at this point in the history
Adds shell completions for `bash`, `fish`, and `zsh`. Tree-sitter also
supports `elvish` and `powershell`, and will support `nushell` in the
next release.

Note that I have only tested the bash completions!
  • Loading branch information
ribru17 committed Dec 11, 2024
1 parent 11d0a39 commit 1e284fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkgs/development/tools/parsing/tree-sitter/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
, nix-update-script
, runCommand
, which
, installShellFiles
, rustPlatform
, emscripten
, Security
Expand Down Expand Up @@ -116,7 +117,7 @@ rustPlatform.buildRustPackage {
buildInputs =
lib.optionals stdenv.hostPlatform.isDarwin [ Security CoreServices ];
nativeBuildInputs =
[ which ]
[ which installShellFiles ]
++ lib.optionals webUISupport [ emscripten ];

patches = lib.optionals webUISupport [
Expand Down Expand Up @@ -150,6 +151,11 @@ rustPlatform.buildRustPackage {
PREFIX=$out make install
${lib.optionalString (!enableShared) "rm $out/lib/*.so{,.*}"}
${lib.optionalString (!enableStatic) "rm $out/lib/*.a"}
'' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd tree-sitter \
--bash <($out/bin/tree-sitter complete --shell bash) \
--fish <($out/bin/tree-sitter complete --shell fish) \
--zsh <($out/bin/tree-sitter complete --shell zsh)
'';

# test result: FAILED. 120 passed; 13 failed; 0 ignored; 0 measured; 0 filtered out
Expand Down

0 comments on commit 1e284fa

Please sign in to comment.