Update emacs web-mode configuration.

This commit is contained in:
Kevin Baensch 2023-01-29 14:34:19 +01:00
parent 2be7df22bc
commit c5eb628248
Signed by: derped
GPG key ID: C0F1D326C7626543

View file

@ -6,11 +6,22 @@ mkIf (elem "emacs::web-mode" config.machine.pkgs) {
programs.emacs.init.usePackage = { programs.emacs.init.usePackage = {
web-mode = { web-mode = {
enable = true; 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 = {}; # bind = {};
mode = [ mode = [
''("\\.html\\'" . web-mode)'' ''("\\.html\\'" . web-mode)''
''("\\.css\\'" . web-mode)'' ''("\\.css\\'" . web-mode)''
''("\\.html?\\'" . web-mode)'' ''("\\.html?\\'" . web-mode)''
''("\\.svelte\\'" . web-mode)''
''("\\.phtml\\'" . web-mode)'' ''("\\.phtml\\'" . web-mode)''
''("\\.tpl\\.php\\'" . web-mode)'' ''("\\.tpl\\.php\\'" . web-mode)''
''("\\.[agj]sp\\'" . web-mode)'' ''("\\.[agj]sp\\'" . web-mode)''
@ -20,6 +31,21 @@ mkIf (elem "emacs::web-mode" config.machine.pkgs) {
''("\\.djhtml\\'" . web-mode)'' ''("\\.djhtml\\'" . web-mode)''
]; ];
config = '' 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 (setq web-mode-engines-alist
'(("php" . "\\.phtml\\'") '(("php" . "\\.phtml\\'")
("blade" . "\\.blade\\.")) ("blade" . "\\.blade\\."))
@ -34,26 +60,34 @@ mkIf (elem "emacs::web-mode" config.machine.pkgs) {
}; };
typescript-mode = { typescript-mode = {
enable = true; enable = true;
hook = lib.optional (elem "emacs::lsp" config.machine.pkgs) hook = [ "(typescript-mode . (lambda () (subword-mode)))" ]
++ lib.optional (elem "emacs::lsp" config.machine.pkgs)
''(typescript-mode . (lambda () (lsp)))''; ''(typescript-mode . (lambda () (lsp)))'';
mode = [ mode = [
''("\\.ts\\'" . typescript-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))
'';
}; };
# tide = {
# enable = true;
# after = [ "typescript-mode" "company" "flycheck" ];
# hook = [
# "(typescript-mode . tide-setup)"
# "(typescript-mode . tide-hl-identifier-mode)"
# "(before-save . tide-format-before-save)"
# ];
# config = ''
# (flycheck-mode +1)
# (setq flycheck-check-syntax-automatically '(save mode-enabled))
# (setq company-tooltip-align-annotations t)
# '';
# };
impatient-mode = { impatient-mode = {
enable = true; enable = true;
}; };