[emacs] Prebuild tree-sitter grammars
This commit is contained in:
@@ -9,6 +9,49 @@ let
|
|||||||
rev = "8f55404781edacf66fa330205533b002de3fb5ee";
|
rev = "8f55404781edacf66fa330205533b002de3fb5ee";
|
||||||
sha256 = "sha256-vHwgENjip2+AFzs4oZfnKEAJKwf5Zid7fakImvxxQUw=";
|
sha256 = "sha256-vHwgENjip2+AFzs4oZfnKEAJKwf5Zid7fakImvxxQUw=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Pre-built tree-sitter grammars for common languages
|
||||||
|
treeSitterGrammars = with pkgs.tree-sitter-grammars; [
|
||||||
|
# Core languages
|
||||||
|
tree-sitter-bash
|
||||||
|
tree-sitter-c
|
||||||
|
tree-sitter-cpp
|
||||||
|
tree-sitter-css
|
||||||
|
tree-sitter-html
|
||||||
|
tree-sitter-javascript
|
||||||
|
tree-sitter-json
|
||||||
|
tree-sitter-markdown
|
||||||
|
tree-sitter-python
|
||||||
|
tree-sitter-rust
|
||||||
|
tree-sitter-yaml
|
||||||
|
|
||||||
|
# Configuration and markup
|
||||||
|
tree-sitter-dockerfile
|
||||||
|
tree-sitter-nix
|
||||||
|
tree-sitter-toml
|
||||||
|
|
||||||
|
# Development tools and frameworks
|
||||||
|
tree-sitter-elisp
|
||||||
|
tree-sitter-typescript
|
||||||
|
tree-sitter-tsx
|
||||||
|
tree-sitter-go
|
||||||
|
tree-sitter-java
|
||||||
|
tree-sitter-lua
|
||||||
|
tree-sitter-make
|
||||||
|
tree-sitter-sql
|
||||||
|
|
||||||
|
# Additional useful languages
|
||||||
|
tree-sitter-haskell
|
||||||
|
tree-sitter-ruby
|
||||||
|
tree-sitter-scala
|
||||||
|
tree-sitter-clojure
|
||||||
|
tree-sitter-scheme
|
||||||
|
tree-sitter-latex
|
||||||
|
tree-sitter-org-nvim
|
||||||
|
tree-sitter-vim
|
||||||
|
tree-sitter-regex
|
||||||
|
tree-sitter-comment
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
@@ -35,7 +78,37 @@ in
|
|||||||
|
|
||||||
fonts.fontconfig.enable = true;
|
fonts.fontconfig.enable = true;
|
||||||
|
|
||||||
home.file."${config.xdg.configHome}/emacs".source = doomEmacs;
|
# Mount emacs and tree-sitter grammars from nix store
|
||||||
|
home.file = {
|
||||||
|
"${config.xdg.configHome}/emacs".source = doomEmacs;
|
||||||
|
} // lib.listToAttrs (lib.flatten (map (grammar:
|
||||||
|
let
|
||||||
|
# Extract just the language name from the package name
|
||||||
|
grammarName = let
|
||||||
|
fullName = grammar.pname or (lib.getName grammar);
|
||||||
|
# Remove "tree-sitter-" prefix and "-grammar" suffix
|
||||||
|
cleaned = lib.removePrefix "tree-sitter-" fullName;
|
||||||
|
final = lib.removeSuffix "-grammar" cleaned;
|
||||||
|
in final;
|
||||||
|
in [
|
||||||
|
# Place grammars where Emacs tree-sitter expects them
|
||||||
|
{
|
||||||
|
name = ".local/share/doom/etc/tree-sitter/libtree-sitter-${grammarName}.so";
|
||||||
|
value.source = "${grammar}/parser";
|
||||||
|
}
|
||||||
|
# Also place in standard tree-sitter location as backup
|
||||||
|
{
|
||||||
|
name = ".local/share/tree-sitter/bin/libtree-sitter-${grammarName}.so";
|
||||||
|
value.source = "${grammar}/parser";
|
||||||
|
}
|
||||||
|
] ++ lib.optionals (builtins.pathExists "${grammar}/queries") [
|
||||||
|
{
|
||||||
|
name = ".local/share/tree-sitter/queries/${grammarName}";
|
||||||
|
value.source = "${grammar}/queries";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
) treeSitterGrammars));
|
||||||
|
|
||||||
home.sessionPath = [
|
home.sessionPath = [
|
||||||
"${config.xdg.configHome}/emacs/bin"
|
"${config.xdg.configHome}/emacs/bin"
|
||||||
];
|
];
|
||||||
@@ -43,6 +116,8 @@ in
|
|||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
DOOMDIR = "${config.xdg.configHome}/doom";
|
DOOMDIR = "${config.xdg.configHome}/doom";
|
||||||
DOOMLOCALDIR = "${config.xdg.dataHome}/doom";
|
DOOMLOCALDIR = "${config.xdg.dataHome}/doom";
|
||||||
|
# Set tree-sitter grammar directory to use pre-built grammars
|
||||||
|
TREE_SITTER_DIR = "${config.xdg.dataHome}/tree-sitter";
|
||||||
};
|
};
|
||||||
|
|
||||||
home.activation.doomConfig = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
home.activation.doomConfig = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
|
|||||||
Reference in New Issue
Block a user