From 3e357cbe951d5528f64e5a738e72a6f53a1d2295 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Tue, 30 Jul 2024 15:04:58 +0100 Subject: [PATCH] Switch nix formatter and lsp Change formatter alejandra -> nixfmt (new official formatter) Change LSP nil -> nixd for more features --- home/emacs/default.nix | 114 +++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/home/emacs/default.nix b/home/emacs/default.nix index c6058145..3abcd719 100644 --- a/home/emacs/default.nix +++ b/home/emacs/default.nix @@ -3,8 +3,9 @@ pkgs, fonts, ... -}: { - imports = [../shell/default.nix]; +}: +{ + imports = [ ../shell/default.nix ]; services.emacs = { enable = true; package = config.programs.emacs.finalPackage; @@ -18,39 +19,45 @@ # git clone https://git.xenia.me.uk/pixelifytica/emacs.git ~/.emacs.d enable = true; package = pkgs.emacs29-pgtk; - extraConfig = let - fixed-font-family = "${fonts.monospace.name}"; - variable-font-family = "${fonts.sansSerif.name}"; - font-height = builtins.toString (builtins.floor (builtins.mul fonts.sizes.applications 10)); - custom-theme-name = "nix"; - custom-theme = pkgs.writeTextFile { - name = "custom-emacs-theme"; - destination = "/${custom-theme-name}-theme.el"; - text = '' - (deftheme ${custom-theme-name} - "Use Nix customised fonts for main faces") + extraConfig = + let + fixed-font-family = "${fonts.monospace.name}"; + variable-font-family = "${fonts.sansSerif.name}"; + font-height = builtins.toString (builtins.floor (builtins.mul fonts.sizes.applications 10)); + custom-theme-name = "nix"; + custom-theme = pkgs.writeTextFile { + name = "custom-emacs-theme"; + destination = "/${custom-theme-name}-theme.el"; + text = '' + (deftheme ${custom-theme-name} + "Use Nix customised fonts for main faces") - (custom-theme-set-variables - '${custom-theme-name} - '(menu-bar-mode nil)) + (custom-theme-set-variables + '${custom-theme-name} + '(menu-bar-mode nil)) - (custom-theme-set-faces - '${custom-theme-name} - '(default ((t (:family "${fixed-font-family}" :height ${font-height})))) - '(fixed-pitch ((t (:family "${fixed-font-family}")))) - '(fixed-pitch-serif ((t (:family "${fixed-font-family}")))) - '(variable-pitch ((t (:family "${variable-font-family}"))))) + (custom-theme-set-faces + '${custom-theme-name} + '(default ((t (:family "${fixed-font-family}" :height ${font-height})))) + '(fixed-pitch ((t (:family "${fixed-font-family}")))) + '(fixed-pitch-serif ((t (:family "${fixed-font-family}")))) + '(variable-pitch ((t (:family "${variable-font-family}"))))) - (provide-theme '${custom-theme-name}) - ''; - }; - custom-theme-hash = builtins.hashFile "sha256" "${custom-theme}/${custom-theme-name}-theme.el"; - in '' - (add-to-list 'custom-theme-load-path "${custom-theme}") - (add-to-list 'custom-safe-themes "${custom-theme-hash}") - (load-theme '${custom-theme-name}) - ''; - extraPackages = epkgs: with epkgs; [treesit-grammars.with-all-grammars mu4e]; + (provide-theme '${custom-theme-name}) + ''; + }; + custom-theme-hash = builtins.hashFile "sha256" "${custom-theme}/${custom-theme-name}-theme.el"; + in + '' + (add-to-list 'custom-theme-load-path "${custom-theme}") + (add-to-list 'custom-safe-themes "${custom-theme-hash}") + (load-theme '${custom-theme-name}) + ''; + extraPackages = + epkgs: with epkgs; [ + treesit-grammars.with-all-grammars + mu4e + ]; }; home.packages = with pkgs; [ # Emacs requirements @@ -68,8 +75,18 @@ mp3info # Customised LaTeX install - (texlive.combine - {inherit (pkgs.texlive) scheme-medium dvisvgm dvipng wrapfig amsmath ulem hyperref capt-of;}) + (texlive.combine { + inherit (texlive) + scheme-medium + dvisvgm + dvipng + wrapfig + amsmath + ulem + hyperref + capt-of + ; + }) # Development tools ## Code screenshots @@ -86,30 +103,29 @@ nodePackages.eslint ## Formatters - alejandra + nixfmt-rfc-style shfmt stylua nodePackages.prettier ## Language servers - nil # Nix lsp + nixd lua-language-server nodePackages.typescript-language-server ## Interpreters - (python3.withPackages - (ps: - with ps; [ - tkinter - python-lsp-server - mypy - numpy - scipy - xarray - matplotlib - ])) - (luajit.withPackages - (ps: [(ps.callPackage ./luarocks/scilua.nix {})])) + (python3.withPackages ( + ps: with ps; [ + tkinter + python-lsp-server + mypy + numpy + scipy + xarray + matplotlib + ] + )) + (luajit.withPackages (ps: [ (ps.callPackage ./luarocks/scilua.nix { }) ])) ]; xdg.configFile = { "ruff/pyproject.toml".source = ./ruff.toml;