135 lines
3.7 KiB
Nix
135 lines
3.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
doomEmacs = pkgs.fetchFromGitHub {
|
|
owner = "doomemacs";
|
|
repo = "doomemacs";
|
|
rev = "8f55404781edacf66fa330205533b002de3fb5ee";
|
|
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
|
|
{
|
|
config = {
|
|
home.packages = [
|
|
(pkgs.emacs.pkgs.withPackages (epkgs: [
|
|
epkgs.vterm
|
|
]))
|
|
|
|
pkgs.emacs-all-the-icons-fonts
|
|
pkgs.fira-code
|
|
pkgs.fontconfig
|
|
pkgs.graphviz
|
|
pkgs.isort
|
|
pkgs.libvterm # native vterm library
|
|
pkgs.nerd-fonts.fira-code
|
|
pkgs.nerd-fonts.droid-sans-mono
|
|
pkgs.nil # nix lsp language server
|
|
pkgs.nixfmt-rfc-style
|
|
(pkgs.ripgrep.override {withPCRE2 = true;})
|
|
pkgs.pipenv
|
|
pkgs.poetry
|
|
pkgs.python3
|
|
];
|
|
|
|
fonts.fontconfig.enable = true;
|
|
|
|
# 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 = [
|
|
"${config.xdg.configHome}/emacs/bin"
|
|
];
|
|
|
|
home.sessionVariables = {
|
|
DOOMDIR = "${config.xdg.configHome}/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"] ''
|
|
# Always remove and recreate the symlink to ensure it points to the source directory
|
|
rm -rf "${config.xdg.configHome}/doom"
|
|
ln -sf "${config.home.homeDirectory}/nixos-configs/home/modules/emacs/doom" "${config.xdg.configHome}/doom"
|
|
|
|
# Run doom sync to apply any configuration changes
|
|
if command -v doom >/dev/null 2>&1; then
|
|
doom sync
|
|
fi
|
|
'';
|
|
};
|
|
}
|