From 467ef76666dce9210642802c198a3f25d4019ab4 Mon Sep 17 00:00:00 2001 From: Juan Placencia Date: Fri, 22 Apr 2022 23:55:38 -0500 Subject: [PATCH] Fix JS searching and auto-save for ESLint --- uno/modules/lang/js/+index.org | 11 +++++++++++ uno/modules/lang/js/lsp.org | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/uno/modules/lang/js/+index.org b/uno/modules/lang/js/+index.org index 3ce9460..689d626 100644 --- a/uno/modules/lang/js/+index.org +++ b/uno/modules/lang/js/+index.org @@ -41,3 +41,14 @@ Define JavaScript language package. "&&") "Ligature symbols for JS.")) #+END_SRC + +* Projectile + +#+BEGIN_SRC emacs-lisp + (use-package emacs + :after (uno-lang-js projectile) + :init + (add-to-list 'projectile-globally-ignored-directories ".yarn") + (add-to-list 'projectile-globally-ignored-files "package-lock.json") + (add-to-list 'projectile-globally-ignored-files "yarn.lock")) +#+END_SRC diff --git a/uno/modules/lang/js/lsp.org b/uno/modules/lang/js/lsp.org index 2996a1d..2aab9e1 100644 --- a/uno/modules/lang/js/lsp.org +++ b/uno/modules/lang/js/lsp.org @@ -8,6 +8,7 @@ Define JavaScript language LSP Integration package. #+BEGIN_SRC emacs-lisp (use-package emacs :after (uno-lang-js uno-dev-lsp projectile) + :if (executable-find "node") :config (provide 'uno-lang-js-lsp)) #+END_SRC @@ -17,6 +18,8 @@ Define JavaScript language LSP Integration package. #+BEGIN_SRC emacs-lisp (use-package emacs :after uno-lang-js-lsp + :custom + (lsp-eslint-auto-fix-on-save t) :init (require 'seq) (defun uno/lang/js/lsp () @@ -63,6 +66,12 @@ Define JavaScript language LSP Integration package. (cond ((file-exists-p (concat -root ".yarn/")) "yarn") ((file-exists-p (concat -root "node_modules/")) "npm")))) + ;; https://github.com/emacs-lsp/lsp-mode/issues/1842#issuecomment-942861229 + (defun uno/lang/js/lsp/eslint-autofix () + "Run lsp-eslint-apply-all-fixes before lsp--before-save." + (when lsp-eslint-auto-fix-on-save + (lsp-eslint-fix-all))) + (advice-add 'lsp--before-save :before #'uno/lang/js/lsp/eslint-autofix) (uno/add-useless-buffer "\\*eslint\\*") (uno/add-useless-buffer "\\*eslint::.*\\*")) #+END_SRC