100 lines
3.1 KiB
Nix
100 lines
3.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
with lib;
|
|
mkIf (elem "emacs::web-mode" config.machine.pkgs) {
|
|
programs.emacs.init.usePackage = {
|
|
web-mode = {
|
|
enable = true;
|
|
init = "(require 'sgml-mode)";
|
|
hook = [
|
|
"(web-mode . (lambda () (sgml-electric-tag-pair-mode)))"
|
|
''
|
|
(web-mode . (lambda ()
|
|
(when (and (buffer-file-name)
|
|
(equal (file-name-extension (buffer-file-name)) "svelte"))
|
|
(lsp))))
|
|
''
|
|
];
|
|
# bind = {};
|
|
mode = [
|
|
''("\\.html\\'" . web-mode)''
|
|
''("\\.css\\'" . web-mode)''
|
|
''("\\.html?\\'" . web-mode)''
|
|
''("\\.svelte\\'" . web-mode)''
|
|
''("\\.phtml\\'" . web-mode)''
|
|
''("\\.tpl\\.php\\'" . web-mode)''
|
|
''("\\.[agj]sp\\'" . web-mode)''
|
|
''("\\.as[cp]x\\'" . web-mode)''
|
|
''("\\.erb\\'" . web-mode)''
|
|
''("\\.mustache\\'" . web-mode)''
|
|
''("\\.djhtml\\'" . web-mode)''
|
|
];
|
|
config = ''
|
|
(setq web-mode-markup-indent-offset 2)
|
|
(setq web-mode-css-indent-offset 2)
|
|
(setq web-mode-code-indent-offset 2)
|
|
(setq web-mode-sql-indent-offset 2)
|
|
(setq web-mode-script-padding 2)
|
|
(setq web-mode-style-padding 2)
|
|
(setq web-mode-part-padding 2)
|
|
(setq web-mode-block-padding 2)
|
|
(setq web-mode-enable-comment-annotation 't)
|
|
|
|
(setq web-mode-enable-current-element-highlight 't)
|
|
|
|
(setq web-mode-enable-sql-detection 't)
|
|
(setq web-mode-auto-close-style 2)
|
|
|
|
(setq web-mode-engines-alist
|
|
'(("php" . "\\.phtml\\'")
|
|
("blade" . "\\.blade\\."))
|
|
)
|
|
'';
|
|
};
|
|
js2-mode = {
|
|
enable = true;
|
|
mode = [
|
|
''("\\.js\\'" . js2-mode)''
|
|
];
|
|
};
|
|
typescript-mode = {
|
|
enable = true;
|
|
hook =
|
|
["(typescript-mode . (lambda () (subword-mode)))"]
|
|
++ lib.optional (elem "emacs::lsp" config.machine.pkgs)
|
|
''(typescript-mode . (lambda () (lsp)))'';
|
|
mode = [
|
|
''("\\.ts\\'" . typescript-mode)''
|
|
''("\\.tsx?\\'" . typescript-tsx-mode)''
|
|
];
|
|
init = ''
|
|
(define-derived-mode typescript-tsx-mode typescript-mode "tsx")
|
|
'';
|
|
config = ''
|
|
(setq typescript-indent-level 2)
|
|
'';
|
|
};
|
|
# https://github.com/NixOS/nixpkgs/pull/150239
|
|
tree-sitter = {
|
|
enable = true;
|
|
package = epkgs: [epkgs.tree-sitter (epkgs.tree-sitter-langs.withPlugins (p: epkgs.tree-sitter-langs.plugins ++ [p.tree-sitter-markdown p.tree-sitter-tsx]))];
|
|
hook = [
|
|
"(typescript-mode . tree-sitter-hl-mode)"
|
|
"(typescript-tsx-mode . tree-sitter-hl-mode)"
|
|
];
|
|
config = ''
|
|
(tree-sitter-require 'tsx)
|
|
(add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx))
|
|
'';
|
|
};
|
|
impatient-mode = {
|
|
enable = true;
|
|
};
|
|
simple-httpd = {
|
|
enable = true;
|
|
};
|
|
};
|
|
}
|