emacs: add javascript support

This commit is contained in:
Kevin Baensch 2021-11-07 16:05:02 +01:00
parent f7a10421a5
commit fe0fe21a12
Signed by: derped
GPG key ID: C0F1D326C7626543
3 changed files with 50 additions and 19 deletions

View file

@ -99,10 +99,14 @@ in mkIf (elem "emacs::company" config.machine.pkgs) {
programs.emacs.init.usePackage = {
company = {
enable = true;
package = epkgs: [ epkgs.company epkgs.company-web ];
diminish = [ "company-mode" ];
hook = [ "(after-init . global-company-mode)" ]
++ optional (elem "emacs::rust" config.machine.pkgs)
''(rust-mode . (lambda () (setq company-backends '((company-capf :with company-yasnippet)))))'';
''(rust-mode . (lambda () (setq company-backends '((company-capf :with company-yasnippet)))))''
++ optional (elem "emacs::web-mode" config.machine.pkgs)
''(web-mode . (lambda () (set (make-local-variable 'company-backends) '(company-web-html company-css))
(company-mode t)))'';
bind = { "\t" = "'company-complete-common"; };
init = ''(require 'ffap)'';
config = ''

View file

@ -6,5 +6,6 @@ mkIf (elem "emacs::nix-mode" config.machine.pkgs) {
programs.emacs.init.usePackage.nix-mode = {
enable = true;
mode = [ ''"\\.nix\\'"'' ];
config = ''(setq nix-nixfmt-bin "nixfmt -w 150")'';
};
}

View file

@ -3,23 +3,49 @@
with lib;
mkIf (elem "emacs::web-mode" config.machine.pkgs) {
programs.emacs.init.usePackage.web-mode = {
enable = true;
mode = [
''("\\.html?\\'" . 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-engines-alist
'(("php" . "\\.phtml\\'")
("blade" . "\\.blade\\."))
)
'';
programs.emacs.init.usePackage = {
web-mode = {
enable = true;
# bind = {};
mode = [
''("\\.html\\'" . web-mode)''
''("\\.css\\'" . web-mode)''
''("\\.html?\\'" . 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-engines-alist
'(("php" . "\\.phtml\\'")
("blade" . "\\.blade\\."))
)
'';
};
js2-mode = {
enable = true;
};
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 = ''
(setq company-tooltip-align-annotations t)
'';
};
impatient-mode = {
enable = true;
};
simple-httpd = {
enable = true;
};
};
}