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)
(declare (indent 2))
(let ((windowsym (make-symbol "doom-sync-window")))
`(with-current-buffer (compile ,command t)
(let ((,windowsym (get-buffer-window (current-buffer))))
(select-window ,windowsym)
(add-hook
'compilation-finish-functions
(lambda (_buf status)
(if (equal status "finished\n")
(progn
(delete-window ,windowsym)
,on-success)
,on-failure))
nil 'local)))))
`(with-current-buffer (compile ,command t)
(let ((w (get-buffer-window (current-buffer))))
(select-window w)
(add-hook
'compilation-finish-functions
(lambda (_buf status)
(if (equal status "finished\n")
(progn
(delete-window w)
,on-success)
,on-failure))
nil 'local))))
;;;###autoload
(defun doom/reload ()

View file

@ -26,7 +26,7 @@ following shell commands:
(print! (info "Reloading Doom Emacs"))
(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)
"Upgrade Doom to the latest version non-destructively."
(require 'vc-git)
(let ((default-directory doom-emacs-dir)
process-file-side-effects)
(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))))
(error "Failed to fetch from upstream"))
(let ((this-rev (vc-git--rev-parse "HEAD"))
(new-rev (vc-git--rev-parse target-remote)))
(let ((this-rev (cdr (doom-call-process "git" "rev-parse" "HEAD")))
(new-rev (cdr (doom-call-process "git" "rev-parse" target-remote))))
(cond
((and (null this-rev)
(null new-rev))
@ -114,9 +113,9 @@ following shell commands:
(print! (start "Upgrading Doom Emacs..."))
(print-group!
(doom-clean-byte-compiled-files)
(unless (and (zerop (car (doom-call-process "git" "reset" "--hard" target-remote)))
(equal (vc-git--rev-parse "HEAD") new-rev))
(error "Failed to check out %s" (substring new-rev 0 10)))
(or (and (zerop (car (doom-call-process "git" "reset" "--hard" target-remote)))
(equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) new-rev))
(error "Failed to check out %s" (substring new-rev 0 10)))
(print! (info "%s") (cdr result))
t))))))
(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.
package-archives
(let ((proto (if gnutls-verify-error "https" "http")))
`(("gnu" . ,(concat proto "://elpa.gnu.org/packages/"))
("melpa" . ,(concat proto "://melpa.org/packages/"))
("org" . ,(concat proto "://orgmode.org/elpa/")))))
(list (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))
(cons "melpa" (concat proto "://melpa.org/packages/"))
(cons "org" (concat proto "://orgmode.org/elpa/")))))
;; package.el has no business modifying the user's init.el
(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)
:init
(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-enable-caching doom-interactive-p
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.
(cond
((when-let
(bin (if (or (null default-directory)
(file-remote-p default-directory nil t))
(bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if find-exe-fn (list "fdfind" "fd"))
doom-projectile-fd-binary))
(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)
(eglot--server-capable :documentFormattingProvider))
#'eglot-format-buffer)
(t #'format-all-buffer))))
(#'format-all-buffer))))
;;;###autoload
(defun +format/region (beg end)
@ -232,10 +232,10 @@ snippets or single lines."
(bound-and-true-p eglot--managed-mode)
(eglot--server-capable :documentRangeFormattingProvider))
(call-interactively #'eglot-format))
(t (save-restriction
(narrow-to-region beg end)
(let ((+format-region-p t))
(+format/buffer))))))
((save-restriction
(narrow-to-region beg end)
(let ((+format-region-p t))
(+format/buffer))))))
;;;###autoload
(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-lsp-async t)
(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
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))

View file

@ -31,7 +31,7 @@
(use-package! flutter
:when (featurep! +flutter)
:defer t
:config
:init
(map! :map dart-mode-map
:localleader
"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
(require 'org-yt nil t)
(defadvice! +org-dont-preview-if-disabled-a (&rest _)
"Make `org-yt' respect `org-display-remote-inline-images'."
:before-while #'org-yt-image-data-fun
@ -769,7 +770,6 @@ between the two."
"p" #'org-priority
"u" #'org-priority-up)))
(map! :after org-agenda
:map org-agenda-mode-map
:m "C-SPC" #'org-agenda-show-and-scroll-up

View file

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