Minor refactors & reformatting

This commit is contained in:
Henrik Lissner 2020-07-23 01:04:04 -04:00
parent 86843d7569
commit da1030985d
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
9 changed files with 52 additions and 48 deletions

View file

@ -55,19 +55,18 @@ And jumps to your `doom!' block."
(defmacro doom--if-compile (command on-success &optional on-failure) (defmacro doom--if-compile (command on-success &optional on-failure)
(declare (indent 2)) (declare (indent 2))
(let ((windowsym (make-symbol "doom-sync-window"))) `(with-current-buffer (compile ,command t)
`(with-current-buffer (compile ,command t) (let ((w (get-buffer-window (current-buffer))))
(let ((,windowsym (get-buffer-window (current-buffer)))) (select-window w)
(select-window ,windowsym) (add-hook
(add-hook 'compilation-finish-functions
'compilation-finish-functions (lambda (_buf status)
(lambda (_buf status) (if (equal status "finished\n")
(if (equal status "finished\n") (progn
(progn (delete-window w)
(delete-window ,windowsym) ,on-success)
,on-success) ,on-failure))
,on-failure)) nil 'local))))
nil 'local)))))
;;;###autoload ;;;###autoload
(defun doom/reload () (defun doom/reload ()

View file

@ -26,7 +26,7 @@ following shell commands:
(print! (info "Reloading Doom Emacs")) (print! (info "Reloading Doom Emacs"))
(doom-cli-execute-after "doom" "upgrade" "-p" (if force-p "-f"))) (doom-cli-execute-after "doom" "upgrade" "-p" (if force-p "-f")))
((print! "Nothing to do. Doom is up-to-date!"))))) ((print! "Doom is up-to-date!")))))
;; ;;
@ -47,7 +47,6 @@ following shell commands:
(defun doom-cli-upgrade (&optional auto-accept-p force-p) (defun doom-cli-upgrade (&optional auto-accept-p force-p)
"Upgrade Doom to the latest version non-destructively." "Upgrade Doom to the latest version non-destructively."
(require 'vc-git)
(let ((default-directory doom-emacs-dir) (let ((default-directory doom-emacs-dir)
process-file-side-effects) process-file-side-effects)
(print! (start "Preparing to upgrade Doom Emacs and its packages...")) (print! (start "Preparing to upgrade Doom Emacs and its packages..."))
@ -84,8 +83,8 @@ following shell commands:
(or (zerop (car (setq result (doom-call-process "git" "fetch" "--tags" doom-repo-remote branch)))) (or (zerop (car (setq result (doom-call-process "git" "fetch" "--tags" doom-repo-remote branch))))
(error "Failed to fetch from upstream")) (error "Failed to fetch from upstream"))
(let ((this-rev (vc-git--rev-parse "HEAD")) (let ((this-rev (cdr (doom-call-process "git" "rev-parse" "HEAD")))
(new-rev (vc-git--rev-parse target-remote))) (new-rev (cdr (doom-call-process "git" "rev-parse" target-remote))))
(cond (cond
((and (null this-rev) ((and (null this-rev)
(null new-rev)) (null new-rev))
@ -114,9 +113,9 @@ following shell commands:
(print! (start "Upgrading Doom Emacs...")) (print! (start "Upgrading Doom Emacs..."))
(print-group! (print-group!
(doom-clean-byte-compiled-files) (doom-clean-byte-compiled-files)
(unless (and (zerop (car (doom-call-process "git" "reset" "--hard" target-remote))) (or (and (zerop (car (doom-call-process "git" "reset" "--hard" target-remote)))
(equal (vc-git--rev-parse "HEAD") new-rev)) (equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) new-rev))
(error "Failed to check out %s" (substring new-rev 0 10))) (error "Failed to check out %s" (substring new-rev 0 10)))
(print! (info "%s") (cdr result)) (print! (info "%s") (cdr result))
t)))))) t))))))
(ignore-errors (ignore-errors

View file

@ -61,9 +61,9 @@ uses a straight or package.el command directly).")
;; than pulled, so packages are often out of date with upstream. ;; than pulled, so packages are often out of date with upstream.
package-archives package-archives
(let ((proto (if gnutls-verify-error "https" "http"))) (let ((proto (if gnutls-verify-error "https" "http")))
`(("gnu" . ,(concat proto "://elpa.gnu.org/packages/")) (list (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))
("melpa" . ,(concat proto "://melpa.org/packages/")) (cons "melpa" (concat proto "://melpa.org/packages/"))
("org" . ,(concat proto "://orgmode.org/elpa/"))))) (cons "org" (concat proto "://orgmode.org/elpa/")))))
;; package.el has no business modifying the user's init.el ;; package.el has no business modifying the user's init.el
(advice-add #'package--ensure-init-file :override #'ignore) (advice-add #'package--ensure-init-file :override #'ignore)

View file

@ -26,6 +26,8 @@ debian, and derivatives). On most it's 'fd'.")
projectile-locate-dominating-file) projectile-locate-dominating-file)
:init :init
(setq projectile-cache-file (concat doom-cache-dir "projectile.cache") (setq projectile-cache-file (concat doom-cache-dir "projectile.cache")
;; Auto-discovery is slow to do by default. Better to update the list
;; when you need to (`projectile-discover-projects-in-search-path').
projectile-auto-discover nil projectile-auto-discover nil
projectile-enable-caching doom-interactive-p projectile-enable-caching doom-interactive-p
projectile-globally-ignored-files '(".DS_Store" "Icon " "TAGS") projectile-globally-ignored-files '(".DS_Store" "Icon " "TAGS")
@ -165,8 +167,7 @@ And if it's a function, evaluate it."
;; it respects .gitignore. This is recommended in the projectile docs. ;; it respects .gitignore. This is recommended in the projectile docs.
(cond (cond
((when-let ((when-let
(bin (if (or (null default-directory) (bin (if (ignore-errors (file-remote-p default-directory nil t))
(file-remote-p default-directory nil t))
(cl-find-if find-exe-fn (list "fdfind" "fd")) (cl-find-if find-exe-fn (list "fdfind" "fd"))
doom-projectile-fd-binary)) doom-projectile-fd-binary))
(concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow" (concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow"

View file

@ -214,7 +214,7 @@ See `+format/buffer' for the interactive version of this function, and
(bound-and-true-p eglot--managed-mode) (bound-and-true-p eglot--managed-mode)
(eglot--server-capable :documentFormattingProvider)) (eglot--server-capable :documentFormattingProvider))
#'eglot-format-buffer) #'eglot-format-buffer)
(t #'format-all-buffer)))) (#'format-all-buffer))))
;;;###autoload ;;;###autoload
(defun +format/region (beg end) (defun +format/region (beg end)
@ -232,10 +232,10 @@ snippets or single lines."
(bound-and-true-p eglot--managed-mode) (bound-and-true-p eglot--managed-mode)
(eglot--server-capable :documentRangeFormattingProvider)) (eglot--server-capable :documentRangeFormattingProvider))
(call-interactively #'eglot-format)) (call-interactively #'eglot-format))
(t (save-restriction ((save-restriction
(narrow-to-region beg end) (narrow-to-region beg end)
(let ((+format-region-p t)) (let ((+format-region-p t))
(+format/buffer)))))) (+format/buffer))))))
;;;###autoload ;;;###autoload
(defun +format/region-or-buffer () (defun +format/region-or-buffer ()

View file

@ -234,24 +234,26 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
(setq-local company-transformers nil) (setq-local company-transformers nil)
(setq-local company-lsp-async t) (setq-local company-lsp-async t)
(setq-local company-lsp-cache-candidates nil) (setq-local company-lsp-cache-candidates nil)
(lsp!)))) (lsp!)))
(when (featurep! :tools lsp +eglot)
;; Map eglot specific helper
(map! :localleader
:after cc-mode
:map c++-mode-map
:n :desc "Show type inheritance hierarchy" "ct" #'+cc/eglot-ccls-inheritance-hierarchy)
;; NOTE : This setting is untested yet
(after! eglot
;; IS-MAC custom configuration
(when IS-MAC
(add-to-list 'eglot-workspace-configuration
`((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
"-isystem/usr/local/include"]
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir"))))))))))))
(when (and (featurep! +lsp) (featurep! :tools lsp +eglot))
;; Map eglot specific helper
(map! :localleader
:after cc-mode
:map c++-mode-map
:n :desc "Show type inheritance hierarchy" "ct" #'+cc/eglot-ccls-inheritance-hierarchy)
;; NOTE : This setting is untested yet
(after! eglot
;; IS-MAC custom configuration
(when IS-MAC
(add-to-list 'eglot-workspace-configuration
`((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
"-isystem/usr/local/include"]
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir")))))))))))
(use-package! ccls (use-package! ccls
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot))) :when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))

View file

@ -31,7 +31,7 @@
(use-package! flutter (use-package! flutter
:when (featurep! +flutter) :when (featurep! +flutter)
:defer t :defer t
:config :init
(map! :map dart-mode-map (map! :map dart-mode-map
:localleader :localleader
"r" #'flutter-run-or-hot-reload)) "r" #'flutter-run-or-hot-reload))

View file

@ -422,6 +422,7 @@ relative to `org-directory', unless it is an absolute path."
;; Add support for youtube links + previews ;; Add support for youtube links + previews
(require 'org-yt nil t) (require 'org-yt nil t)
(defadvice! +org-dont-preview-if-disabled-a (&rest _) (defadvice! +org-dont-preview-if-disabled-a (&rest _)
"Make `org-yt' respect `org-display-remote-inline-images'." "Make `org-yt' respect `org-display-remote-inline-images'."
:before-while #'org-yt-image-data-fun :before-while #'org-yt-image-data-fun
@ -769,7 +770,6 @@ between the two."
"p" #'org-priority "p" #'org-priority
"u" #'org-priority-up))) "u" #'org-priority-up)))
(map! :after org-agenda (map! :after org-agenda
:map org-agenda-mode-map :map org-agenda-mode-map
:m "C-SPC" #'org-agenda-show-and-scroll-up :m "C-SPC" #'org-agenda-show-and-scroll-up

View file

@ -13,9 +13,11 @@
:desc "Encrypt buffer" "e" #'ansible-encrypt-buffer :desc "Encrypt buffer" "e" #'ansible-encrypt-buffer
:desc "Look up in Ansible docs" "h" #'ansible-doc)) :desc "Look up in Ansible docs" "h" #'ansible-doc))
(after! ansible-doc (after! ansible-doc
(set-evil-initial-state! '(ansible-doc-module-mode) 'emacs)) (set-evil-initial-state! '(ansible-doc-module-mode) 'emacs))
(use-package! jinja2-mode (use-package! jinja2-mode
:mode "\\.j2$" :mode "\\.j2$"
:config :config
@ -25,6 +27,7 @@
(add-hook! 'jinja2-mode-hook (add-hook! 'jinja2-mode-hook
(remove-hook 'after-save-hook 'jinja2-indent-buffer t))) (remove-hook 'after-save-hook 'jinja2-indent-buffer t)))
(def-project-mode! +ansible-yaml-mode (def-project-mode! +ansible-yaml-mode
:modes '(yaml-mode) :modes '(yaml-mode)
:add-hooks '(ansible ansible-auto-decrypt-encrypt ansible-doc-mode) :add-hooks '(ansible ansible-auto-decrypt-encrypt ansible-doc-mode)