Switch nix formatter and lsp

Change formatter alejandra -> nixfmt (new official formatter)
Change LSP nil -> nixd for more features
This commit is contained in:
Evie Litherland-Smith 2024-07-30 15:04:58 +01:00
parent 4f98a8cd93
commit 3e357cbe95

View file

@ -3,8 +3,9 @@
pkgs, pkgs,
fonts, fonts,
... ...
}: { }:
imports = [../shell/default.nix]; {
imports = [ ../shell/default.nix ];
services.emacs = { services.emacs = {
enable = true; enable = true;
package = config.programs.emacs.finalPackage; package = config.programs.emacs.finalPackage;
@ -18,39 +19,45 @@
# git clone https://git.xenia.me.uk/pixelifytica/emacs.git ~/.emacs.d # git clone https://git.xenia.me.uk/pixelifytica/emacs.git ~/.emacs.d
enable = true; enable = true;
package = pkgs.emacs29-pgtk; package = pkgs.emacs29-pgtk;
extraConfig = let extraConfig =
fixed-font-family = "${fonts.monospace.name}"; let
variable-font-family = "${fonts.sansSerif.name}"; fixed-font-family = "${fonts.monospace.name}";
font-height = builtins.toString (builtins.floor (builtins.mul fonts.sizes.applications 10)); variable-font-family = "${fonts.sansSerif.name}";
custom-theme-name = "nix"; font-height = builtins.toString (builtins.floor (builtins.mul fonts.sizes.applications 10));
custom-theme = pkgs.writeTextFile { custom-theme-name = "nix";
name = "custom-emacs-theme"; custom-theme = pkgs.writeTextFile {
destination = "/${custom-theme-name}-theme.el"; name = "custom-emacs-theme";
text = '' destination = "/${custom-theme-name}-theme.el";
(deftheme ${custom-theme-name} text = ''
"Use Nix customised fonts for main faces") (deftheme ${custom-theme-name}
"Use Nix customised fonts for main faces")
(custom-theme-set-variables (custom-theme-set-variables
'${custom-theme-name} '${custom-theme-name}
'(menu-bar-mode nil)) '(menu-bar-mode nil))
(custom-theme-set-faces (custom-theme-set-faces
'${custom-theme-name} '${custom-theme-name}
'(default ((t (:family "${fixed-font-family}" :height ${font-height})))) '(default ((t (:family "${fixed-font-family}" :height ${font-height}))))
'(fixed-pitch ((t (:family "${fixed-font-family}")))) '(fixed-pitch ((t (:family "${fixed-font-family}"))))
'(fixed-pitch-serif ((t (:family "${fixed-font-family}")))) '(fixed-pitch-serif ((t (:family "${fixed-font-family}"))))
'(variable-pitch ((t (:family "${variable-font-family}"))))) '(variable-pitch ((t (:family "${variable-font-family}")))))
(provide-theme '${custom-theme-name}) (provide-theme '${custom-theme-name})
''; '';
}; };
custom-theme-hash = builtins.hashFile "sha256" "${custom-theme}/${custom-theme-name}-theme.el"; custom-theme-hash = builtins.hashFile "sha256" "${custom-theme}/${custom-theme-name}-theme.el";
in '' in
(add-to-list 'custom-theme-load-path "${custom-theme}") ''
(add-to-list 'custom-safe-themes "${custom-theme-hash}") (add-to-list 'custom-theme-load-path "${custom-theme}")
(load-theme '${custom-theme-name}) (add-to-list 'custom-safe-themes "${custom-theme-hash}")
''; (load-theme '${custom-theme-name})
extraPackages = epkgs: with epkgs; [treesit-grammars.with-all-grammars mu4e]; '';
extraPackages =
epkgs: with epkgs; [
treesit-grammars.with-all-grammars
mu4e
];
}; };
home.packages = with pkgs; [ home.packages = with pkgs; [
# Emacs requirements # Emacs requirements
@ -68,8 +75,18 @@
mp3info mp3info
# Customised LaTeX install # Customised LaTeX install
(texlive.combine (texlive.combine {
{inherit (pkgs.texlive) scheme-medium dvisvgm dvipng wrapfig amsmath ulem hyperref capt-of;}) inherit (texlive)
scheme-medium
dvisvgm
dvipng
wrapfig
amsmath
ulem
hyperref
capt-of
;
})
# Development tools # Development tools
## Code screenshots ## Code screenshots
@ -86,30 +103,29 @@
nodePackages.eslint nodePackages.eslint
## Formatters ## Formatters
alejandra nixfmt-rfc-style
shfmt shfmt
stylua stylua
nodePackages.prettier nodePackages.prettier
## Language servers ## Language servers
nil # Nix lsp nixd
lua-language-server lua-language-server
nodePackages.typescript-language-server nodePackages.typescript-language-server
## Interpreters ## Interpreters
(python3.withPackages (python3.withPackages (
(ps: ps: with ps; [
with ps; [ tkinter
tkinter python-lsp-server
python-lsp-server mypy
mypy numpy
numpy scipy
scipy xarray
xarray matplotlib
matplotlib ]
])) ))
(luajit.withPackages (luajit.withPackages (ps: [ (ps.callPackage ./luarocks/scilua.nix { }) ]))
(ps: [(ps.callPackage ./luarocks/scilua.nix {})]))
]; ];
xdg.configFile = { xdg.configFile = {
"ruff/pyproject.toml".source = ./ruff.toml; "ruff/pyproject.toml".source = ./ruff.toml;