Skip to content

Commit a92366a

Browse files
snoweuphhorriblename
authored andcommitted
formatter/conform-nvim/emacs: init
1 parent 8f00691 commit a92366a

4 files changed

Lines changed: 44 additions & 2 deletions

File tree

docs/manual/release-notes/rl-26.12.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949

5050
- `formatter/conform-nvim/presets/sblc`: initialize.
5151

52+
- `formatter/conform-nvim/presets/emacs`: initialize.
53+
5254
[gmvar](https://github.com/gmvar):
5355

5456
[beancount-language-server]: https://github.com/polarmutex/beancount-language-server

modules/plugins/formatter/conform-nvim/presets/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
./deno.nix
1919
./djlint.nix
2020
./dockerfmt.nix
21+
./emacs.nix
2122
./fantomas.nix
2223
./fish-indent.nix
2324
./floskell.nix
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}: let
7+
inherit (lib.modules) mkIf;
8+
inherit (lib.nvim.types) mkFormatterPresetEnableOption;
9+
inherit (lib.meta) getExe;
10+
11+
cfg = config.vim.formatter.conform-nvim.presets.emacs;
12+
in {
13+
options.vim.formatter.conform-nvim.presets.emacs = {
14+
enable = mkFormatterPresetEnableOption {
15+
option = "emacs";
16+
display = "Emacs";
17+
};
18+
};
19+
20+
config = mkIf cfg.enable {
21+
vim.formatter.conform-nvim.setupOpts.formatters.emacs = {
22+
command = getExe pkgs.emacs-nox;
23+
args = [
24+
"--batch"
25+
"--eval"
26+
# elisp
27+
''
28+
(let ((file (car command-line-args-left)))
29+
(with-current-buffer (find-file-noselect file)
30+
(lisp-mode)
31+
(indent-region (point-min) (point-max))
32+
(save-buffer)))
33+
''
34+
"$FILENAME"
35+
];
36+
stdin = false;
37+
};
38+
};
39+
}

modules/plugins/languages/lisp.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
cfg = config.vim.languages.lisp;
1414

15-
defaultFormat = ["sbcl"];
16-
formats = ["sbcl" "injected"];
15+
defaultFormat = ["emacs"];
16+
formats = ["sbcl" "emacs" "injected"];
1717
in {
1818
options.vim.languages.lisp = {
1919
enable = mkEnableOption "Lisp support";

0 commit comments

Comments
 (0)