Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacs: Add basic tree-sitter support #219559

Merged
merged 3 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkgs/applications/editors/emacs/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
else if withAthena then "athena"
else "lucid")
, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, withTreeSitter ? lib.versionAtLeast version "29", tree-sitter ? null
}:

assert (libXft != null) -> libpng != null; # probably a bug
Expand All @@ -58,6 +59,7 @@ assert withGTK2 -> !withGTK3 && gtk2-x11 != null && !withPgtk;
assert withGTK3 -> !withGTK2 && ((gtk3-x11 != null) || withPgtk);
assert withPgtk -> withGTK3 && !withX && gtk3 != null;
assert withXwidgets -> withGTK3 && webkitgtk != null;
assert withTreeSitter -> tree-sitter != null;


(if withMacport then llvmPackages_6.stdenv else stdenv).mkDerivation (finalAttrs: (lib.optionalAttrs nativeComp {
Expand Down Expand Up @@ -164,7 +166,8 @@ assert withXwidgets -> withGTK3 && webkitgtk != null;
ImageCaptureCore GSS ImageIO
]
++ lib.optionals stdenv.isDarwin [ sigtool ]
++ lib.optionals nativeComp [ libgccjit ];
++ lib.optionals nativeComp [ libgccjit ]
++ lib.optionals withTreeSitter [ tree-sitter ];

hardeningDisable = [ "format" ];

Expand Down Expand Up @@ -193,6 +196,7 @@ assert withXwidgets -> withGTK3 && webkitgtk != null;
++ lib.optional withImageMagick "--with-imagemagick"
++ lib.optional withXinput2 "--with-xinput2"
++ lib.optional (!withToolkitScrollBars) "--without-toolkit-scroll-bars"
++ lib.optional withTreeSitter "--with-tree-sitter"
;

installTargets = [ "tags" "install" ];
Expand Down Expand Up @@ -241,6 +245,7 @@ assert withXwidgets -> withGTK3 && webkitgtk != null;

passthru = {
inherit nativeComp;
treeSitter = withTreeSitter;
pkgs = recurseIntoAttrs (emacsPackagesFor finalAttrs.finalPackage);
tests = { inherit (nixosTests) emacs-daemon; };
};
Expand Down
11 changes: 11 additions & 0 deletions pkgs/build-support/emacs/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ let

nativeComp = emacs.nativeComp or false;

treeSitter = emacs.treeSitter or false;

in

packagesFun: # packages explicitly requested by the user
Expand Down Expand Up @@ -109,6 +111,9 @@ runCommand
${optionalString nativeComp ''
mkdir -p $out/share/emacs/native-lisp
''}
${optionalString treeSitter ''
mkdir -p $out/lib
''}

local requires
for pkg in $explicitRequires; do
Expand All @@ -133,6 +138,9 @@ runCommand
${optionalString nativeComp ''
linkPath "$1" "share/emacs/native-lisp" "share/emacs/native-lisp"
''}
${optionalString treeSitter ''
linkPath "$1" "lib" "lib"
''}
}

# Iterate over the array of inputs (avoiding nix's own interpolation)
Expand Down Expand Up @@ -164,6 +172,9 @@ runCommand
${optionalString nativeComp ''
(add-to-list 'native-comp-eln-load-path "$out/share/emacs/native-lisp/")
''}
${optionalString treeSitter ''
(add-to-list 'treesit-extra-load-path "$out/lib/")
''}
EOF

# Generate a subdirs.el that statically adds all subdirectories to load-path.
Expand Down