From 742687a51e2e62ff6cf409403828270ac6e232cc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 8 Apr 2019 23:01:30 -0400 Subject: [PATCH] Add delq! and pushnew! macros And move projectile configs to their respective modules (and out of package configs). --- core/core-lib.el | 14 ++++++++++++++ core/core-projects.el | 13 +------------ modules/lang/cc/config.el | 11 ++++++----- modules/lang/javascript/config.el | 8 ++++---- modules/lang/web/+css.el | 8 ++++++++ 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 7f71cad74..6bc55a105 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -135,6 +135,20 @@ Accepts the same arguments as `message'." (defalias 'lambda! 'λ!) +(defmacro pushnew! (place &rest values) + "Like `cl-pushnew', but will prepend VALUES to PLACE. +The order VALUES is preserved." + `(dolist (--value-- (nreverse (list ,@values))) + (cl-pushnew --value-- ,place))) + +(defmacro delq! (elt list &optional fetcher) + "Delete ELT from LIST in-place." + `(setq ,list + (delq ,(if fetcher + `(funcall ,fetcher ,elt ,list) + elt) + ,list))) + (defmacro defer-until! (condition &rest body) "Run BODY when CONDITION is true (checks on `after-load-functions'). Meant to serve as a predicated alternative to `after!'." diff --git a/core/core-projects.el b/core/core-projects.el index 0571cb5ce..7734ee700 100644 --- a/core/core-projects.el +++ b/core/core-projects.el @@ -39,18 +39,7 @@ Emacs.") ;; a more generic project root file (push ".project" projectile-project-root-files-bottom-up) - - (setq projectile-globally-ignored-directories - (append projectile-globally-ignored-directories - (list (abbreviate-file-name doom-local-dir) ".sync" - "node_modules" "flow-typed")) - projectile-other-file-alist - (append projectile-other-file-alist - '(("css" "scss" "sass" "less" "styl") - ("scss" "css") - ("sass" "css") - ("less" "css") - ("styl" "css")))) + (push (abbreviate-file-name doom-local-dir) projectile-globally-ignored-directories) ;; Accidentally indexing big directories like $HOME or / will massively bloat ;; projectile's cache (into the hundreds of MBs). This purges those entries diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index c53273bea..e6f83ae1c 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -237,13 +237,14 @@ This is ignored by ccls.") (def-package! ccls :when (featurep! +lsp) :hook ((c-mode-local-vars c++-mode-local-vars objc-mode-local-vars) . +cc|init-ccls) + :init + (after! projectile + (add-to-list 'projectile-globally-ignored-directories ".ccls-cache") + (add-to-list 'projectile-project-root-files-bottom-up ".ccls-root") + (add-to-list 'projectile-project-root-files-top-down-recurring "compile_commands.json")) :config (defun +cc|init-ccls () (setq-local company-transformers nil) (setq-local company-lsp-async t) (setq-local company-lsp-cache-candidates nil) - (lsp)) - (after! projectile - (add-to-list 'projectile-globally-ignored-directories ".ccls-cache") - (add-to-list 'projectile-project-root-files-bottom-up ".ccls-root") - (add-to-list 'projectile-project-root-files-top-down-recurring "compile_commands.json"))) + (lsp))) diff --git a/modules/lang/javascript/config.el b/modules/lang/javascript/config.el index 0a4e553d4..d38dfa03f 100644 --- a/modules/lang/javascript/config.el +++ b/modules/lang/javascript/config.el @@ -23,6 +23,10 @@ ;; Other :yield "import")) +(after! projectile + (pushnew! projectile-project-root-files "package.json") + (pushnew! projectile-globally-ignored-directories "node_modules" "flow-typed")) + ;; ;; Major modes @@ -54,10 +58,6 @@ (set-electric! 'js2-mode :chars '(?\} ?\) ?. ?:)) (set-repl-handler! 'js2-mode #'+javascript/open-repl) - (after! projectile - (add-to-list 'projectile-project-root-files "package.json") - (add-to-list 'projectile-globally-ignored-directories "node_modules")) - (map! :map js2-mode-map :localleader "S" #'+javascript/skewer-this-buffer)) diff --git a/modules/lang/web/+css.el b/modules/lang/web/+css.el index 3d9635125..b10b9a0ed 100644 --- a/modules/lang/web/+css.el +++ b/modules/lang/web/+css.el @@ -12,6 +12,14 @@ "CSS" "HTML" "Bourbon" "Compass" ["Sass" (memq major-mode '(scss-mode sass-mode))])) +(after! projectile + (pushnew! projectile-project-root-files + '("css" "scss" "sass" "less" "styl") + '("scss" "css") + '("sass" "css") + '("less" "css") + '("styl" "css"))) + ;; ;; Major modes