General refactors & reformatting across the board

This commit is contained in:
Henrik Lissner 2020-06-04 20:02:46 -04:00
parent af91af01fa
commit 8bf902d5f4
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
25 changed files with 133 additions and 132 deletions

View file

@ -22,23 +22,20 @@ Returns (approximately):
This is used by `file-exists-p!' and `project-file-exists-p!'."
(declare (pure t) (side-effect-free t))
(let ((exists-fn (if (fboundp 'projectile-file-exists-p)
#'projectile-file-exists-p
#'file-exists-p)))
(if (and (listp spec)
(memq (car spec) '(or and)))
(cons (car spec)
(mapcar (doom-rpartial #'doom--resolve-path-forms directory)
(cdr spec)))
(let ((filevar (make-symbol "file")))
`(let* ((file-name-handler-alist nil)
(,filevar ,spec))
(and (stringp ,filevar)
,(if directory
`(let ((default-directory ,directory))
(,exists-fn ,filevar))
(list exists-fn filevar))
,filevar))))))
(if (and (listp spec)
(memq (car spec) '(or and)))
(cons (car spec)
(mapcar (doom-rpartial #'doom--resolve-path-forms directory)
(cdr spec)))
(let ((filevar (make-symbol "file")))
`(let* ((file-name-handler-alist nil)
(,filevar ,spec))
(and (stringp ,filevar)
,(if directory
`(let ((default-directory ,directory))
(file-exists-p ,filevar))
`(file-exists-p ,filevar))
,filevar)))))
(defun doom--path (&rest segments)
(let (file-name-handler-alist)

View file

@ -216,8 +216,8 @@ localleader prefix."
For example, :nvi will map to (list 'normal 'visual 'insert). See
`doom-evil-state-alist' to customize this."
(cl-loop for l across (substring (symbol-name keyword) 1)
if (cdr (assq l doom-evil-state-alist)) collect it
(cl-loop for l across (doom-keyword-name keyword)
if (assq l doom-evil-state-alist) collect (cdr it)
else do (error "not a valid state: %s" l)))

View file

@ -183,7 +183,7 @@ the same name, for use with `funcall' or `apply'. ARGLIST and BODY are as in
(rest (cdr binding)))
(setq
body (pcase type
(`defmacro `(cl-macrolet ((,(car rest) ,(cadr rest) ,@(cddr rest))) ,body))
(`defmacro `(cl-macrolet ((,@rest)) ,body))
(`defun `(cl-letf* ((,(car rest) (symbol-function #',(car rest)))
((symbol-function #',(car rest))
(lambda ,(cadr rest) ,@(cddr rest))))

View file

@ -109,45 +109,43 @@ uses a straight or package.el command directly).")
;;
;;; Bootstrappers
(defun doom--ensure-straight ()
(cl-destructuring-bind (&key pin recipe &allow-other-keys)
(doom-package-get 'straight)
(let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el"))
(repo-url (concat "http" (if gnutls-verify-error "s")
"://github.com/"
(or (plist-get recipe :repo) "raxod502/straight.el")))
(branch (or (plist-get recipe :branch) straight-repository-branch))
(call (if doom-debug-p #'doom-exec-process #'doom-call-process)))
(unless (file-directory-p repo-dir)
(message "Installing straight...")
(cond
((eq straight-vc-git-default-clone-depth 'full)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir))
((null pin)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir
"--depth" (number-to-string straight-vc-git-default-clone-depth)
"--branch" straight-repository-branch))
((integerp straight-vc-git-default-clone-depth)
(make-directory repo-dir t)
(let ((default-directory repo-dir))
(funcall call "git" "init")
(funcall call "git" "checkout" "-b" straight-repository-branch)
(funcall call "git" "remote" "add" "origin" repo-url)
(funcall call "git" "fetch" "origin" pin
"--depth" (number-to-string straight-vc-git-default-clone-depth))
(funcall call "git" "checkout" "--detach" pin)))))
(require 'straight (concat repo-dir "/straight.el"))
(doom-log "Initializing recipes")
(with-temp-buffer
(insert-file-contents (doom-path repo-dir "bootstrap.el"))
;; Don't install straight for us -- we've already done that -- only set
;; up its recipe repos for us.
(eval-region (search-forward "(require 'straight)")
(point-max))))))
(defun doom--ensure-straight (recipe pin)
(let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el"))
(repo-url (concat "http" (if gnutls-verify-error "s")
"://github.com/"
(or (plist-get recipe :repo) "raxod502/straight.el")))
(branch (or (plist-get recipe :branch) straight-repository-branch))
(call (if doom-debug-p #'doom-exec-process #'doom-call-process)))
(unless (file-directory-p repo-dir)
(message "Installing straight...")
(cond
((eq straight-vc-git-default-clone-depth 'full)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir))
((null pin)
(funcall call "git" "clone" "--origin" "origin" repo-url repo-dir
"--depth" (number-to-string straight-vc-git-default-clone-depth)
"--branch" straight-repository-branch))
((integerp straight-vc-git-default-clone-depth)
(make-directory repo-dir t)
(let ((default-directory repo-dir))
(funcall call "git" "init")
(funcall call "git" "checkout" "-b" straight-repository-branch)
(funcall call "git" "remote" "add" "origin" repo-url)
(funcall call "git" "fetch" "origin" pin
"--depth" (number-to-string straight-vc-git-default-clone-depth))
(funcall call "git" "checkout" "--detach" pin)))))
(require 'straight (concat repo-dir "/straight.el"))
(doom-log "Initializing recipes")
(with-temp-buffer
(insert-file-contents (doom-path repo-dir "bootstrap.el"))
;; Don't install straight for us -- we've already done that -- only set
;; up its recipe repos for us.
(eval-region (search-forward "(require 'straight)")
(point-max)))))
(defun doom--ensure-core-packages ()
(defun doom--ensure-core-packages (packages)
(doom-log "Installing core packages")
(dolist (package doom-packages)
(dolist (package packages)
(let ((name (car package)))
(when-let (recipe (plist-get (cdr package) :recipe))
(straight-override-recipe (cons name recipe)))
@ -157,9 +155,11 @@ uses a straight or package.el command directly).")
"Ensure `straight' is installed and was compiled with this version of Emacs."
(when (or force-p (null (bound-and-true-p straight-recipe-repositories)))
(doom-log "Initializing straight")
(let ((doom-packages (doom-package-list nil 'core-only)))
(doom--ensure-straight)
(doom--ensure-core-packages))))
(let ((packages (doom-package-list nil 'core)))
(cl-destructuring-bind (&key recipe pin &allow-other-keys)
(alist-get 'straight packages)
(doom--ensure-straight recipe pin))
(doom--ensure-core-packages packages))))
(defun doom-initialize-packages (&optional force-p)
"Process all packages, essential and otherwise, if they haven't already been.

View file

@ -86,7 +86,7 @@ e.g. proselint and langtool."
(use-package! flyspell-correct
:commands flyspell-correct-at-point flyspell-correct-previous
:commands flyspell-correct-previous
:general ([remap ispell-word] #'flyspell-correct-at-point)
:config
(cond ((and (featurep! :completion helm)

View file

@ -128,7 +128,7 @@ be negative.")
"C-c C-e" #'helm-rg--bounce)
(map! :map helm-rg--bounce-mode-map
"q" #'kill-current-buffer
"C-c C-c" (λ! (helm-rg--bounce-dump) (kill-current-buffer))
"C-c C-c" (cmd! (helm-rg--bounce-dump) (kill-current-buffer))
"C-x C-c" #'helm-rg--bounce-dump-current-file
"C-c C-k" #'kill-current-buffer))

View file

@ -40,9 +40,9 @@
[up] #'ido-prev-match
:map ido-file-completion-map
;; Go to $HOME with ~
"~" (λ! (if (looking-back "/" (point-min))
(insert "~/")
(call-interactively #'self-insert-command)))))
"~" (cmd! (if (looking-back "/" (point-min))
(insert "~/")
(call-interactively #'self-insert-command)))))
(use-package! ido-vertical-mode

View file

@ -184,6 +184,7 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
[remap info-lookup-symbol] #'counsel-info-lookup-symbol
[remap load-theme] #'counsel-load-theme
[remap locate] #'counsel-locate
[remap org-goto] #'counsel-org-goto
[remap org-set-tags-command] #'counsel-org-tag
[remap projectile-compile-project] #'+ivy/project-compile
[remap recentf-open-files] #'counsel-recentf

View file

@ -45,7 +45,7 @@
(interactive)
(if (featurep! :completion ivy)
(call-interactively #'counsel-file-jump)
(λ! (doom-project-find-file default-directory))))
(cmd! (doom-project-find-file default-directory))))
;;;###autoload
(defun +default/discover-projects (arg)

View file

@ -209,7 +209,7 @@
(map! :map markdown-mode-map
:ig "*" (general-predicate-dispatch nil
(looking-at-p "\\*\\* *")
(λ! (forward-char 2)))))))
(cmd! (forward-char 2)))))))
;;
@ -291,7 +291,7 @@ Continues comments if executed from a commented line. Consults
"s--" #'doom/decrease-font-size
;; Conventional text-editing keys & motions
"s-a" #'mark-whole-buffer
"s-/" (λ! (save-excursion (comment-line 1)))
"s-/" (cmd! (save-excursion (comment-line 1)))
:n "s-/" #'evilnc-comment-or-uncomment-lines
:v "s-/" #'evilnc-comment-operator
:gi [s-backspace] #'doom/backward-kill-to-bol-and-indent

View file

@ -552,18 +552,18 @@ To change these keys see `+evil-repeat-keys'."
"a" (evilem-create #'evil-forward-arg)
"A" (evilem-create #'evil-backward-arg)
"s" #'evil-avy-goto-char-2
"SPC" (λ!! #'evil-avy-goto-char-timer t)
"SPC" (cmd!! #'evil-avy-goto-char-timer t)
"/" #'evil-avy-goto-char-timer))
;; evil-snipe
(:after evil-snipe
:map evil-snipe-parent-transient-map
"C-;" (λ! (require 'evil-easymotion)
(call-interactively
(evilem-create #'evil-snipe-repeat
:bind ((evil-snipe-scope 'whole-buffer)
(evil-snipe-enable-highlight)
(evil-snipe-enable-incremental-highlight))))))
"C-;" (cmd! (require 'evil-easymotion)
(call-interactively
(evilem-create #'evil-snipe-repeat
:bind ((evil-snipe-scope 'whole-buffer)
(evil-snipe-enable-highlight)
(evil-snipe-enable-incremental-highlight))))))
;; evil-surround
:v "S" #'evil-surround-region

View file

@ -107,7 +107,7 @@ information.")
;;
;; Library
;;; Library
(defun +file-templates-in-emacs-dirs-p (file)
"Returns t if FILE is in Doom or your private directory."

View file

@ -220,9 +220,8 @@ verbosity when editing a file in `doom-private-dir' or `doom-emacs-dir'."
(when (and (bound-and-true-p flycheck-mode)
(eq major-mode 'emacs-lisp-mode)
(or (not buffer-file-name)
(cl-loop for dir in (list doom-emacs-dir doom-private-dir)
if (file-in-directory-p buffer-file-name dir)
return t)))
(cl-find-if (doom-partial #'file-in-directory-p buffer-file-name)
+emacs-lisp-disable-flycheck-in-dirs)))
(add-to-list (make-local-variable 'flycheck-disabled-checkers)
'emacs-lisp-checkdoc)
(set (make-local-variable 'flycheck-emacs-lisp-check-form)

View file

@ -7,6 +7,14 @@
"Regexp to use for `outline-regexp' in `emacs-lisp-mode'.
This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
(defvar +emacs-lisp-disable-flycheck-in-dirs
(list doom-emacs-dir doom-private-dir)
"List of directories to disable `emacs-lisp-checkdoc' in.
This checker tends to produce a lot of false positives in your .emacs.d and
private config, so it is mostly useless there. However, special hacks are
employed so that flycheck still does *some* helpful linting.")
;; `elisp-mode' is loaded at startup. In order to lazy load its config we need
;; to pretend it isn't loaded

View file

@ -45,9 +45,9 @@
"a" #'go-import-add
"r" #'go-remove-unused-imports)
(:prefix ("b" . "build")
:desc "go run ." "r" (λ! (compile "go run ."))
:desc "go build" "b" (λ! (compile "go build"))
:desc "go clean" "c" (λ! (compile "go clean")))
:desc "go run ." "r" (cmd! (compile "go run ."))
:desc "go build" "b" (cmd! (compile "go build"))
:desc "go clean" "c" (cmd! (compile "go clean")))
(:prefix ("t" . "test")
"t" #'+go/test-rerun
"a" #'+go/test-all

View file

@ -20,6 +20,6 @@
:defer t
:init
(map! :after json-mode
:map json-mode-map
:localleader
"s" #'counsel-jq))
:map json-mode-map
:localleader
"s" #'counsel-jq))

View file

@ -9,9 +9,9 @@
(map! :map kotlin-mode-map
:localleader
:prefix ("b" . "build")
:desc "gradlew assemble" "a" (λ! (+kotlin/run-gradlew "assemble"))
:desc "gradlew build" "b" (λ! (+kotlin/run-gradlew "build"))
:desc "gradlew test" "t" (λ! (+kotlin/run-gradlew "test"))))
:desc "gradlew assemble" "a" (cmd! (+kotlin/run-gradlew "assemble"))
:desc "gradlew build" "b" (cmd! (+kotlin/run-gradlew "build"))
:desc "gradlew test" "t" (cmd! (+kotlin/run-gradlew "test"))))
(use-package! flycheck-kotlin

View file

@ -53,4 +53,4 @@
(define-key! doc-view-mode-map
"ESC" #'delete-window
"q" #'delete-window
"k" (λ! (quit-window) (delete-window))))
"k" (cmd! (quit-window) (delete-window))))

View file

@ -1,5 +1,11 @@
;;; lang/lua/config.el -*- lexical-binding: t; -*-
(defvar +lua-lsp-dir (concat doom-etc-dir "lsp/lua-language-server/")
"Absolute path to the directory of sumneko's lua-language-server.
This directory MUST contain the 'main.lua' file and be the in-source build of
lua-language-server.")
;; sp's default rules are obnoxious, so disable them
(provide 'smartparens-lua)
@ -16,7 +22,23 @@
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
(set-electric! 'lua-mode :words '("else" "end"))
(set-repl-handler! 'lua-mode #'+lua/open-repl)
(set-company-backend! 'lua-mode '(company-lua company-yasnippet)))
(set-company-backend! 'lua-mode '(company-lua company-yasnippet))
(set-eglot-client!
'lua-mode
;; The absolute path to lua-language-server binary is necessary because the
;; bundled dependencies aren't found otherwise. The only reason this is a
;; function is to dynamically change when/if lua-lsp-dir variable changed
(list (doom-path lua-lsp-dir
(cond (IS-MAC "bin/macOS")
(IS-LINUX "bin/Linux")
(IS-WINDOWS "bin/Windows"))
"lua-language-server")
"-E" "-e" "LANG=en"
(doom-path lua-lsp-dir "main.lua")))
(when (featurep! +lsp)
(add-hook 'lua-mode-local-vars-hook #'lsp!)))
(use-package! moonscript
@ -31,32 +53,6 @@
(when (featurep! :checkers syntax)
(require 'flycheck-moonscript nil t)))
;;
;;; LSP
(defvar lua-lsp-dir (concat doom-etc-dir "lsp/lua-language-server/")
"Absolute path to the directory of sumneko's lua-language-server.
This directory MUST contain the 'main.lua' file and be the in-source
build of lua-language-server.")
;; We need the absolute path to lua-language-server binary
;; because the bundled dependencies aren't found otherwise
;; The only reason this is a function is to dynamically change
;; when/if lua-lsp-dir variable changed
(defun doom--abs-path-to-lua-lsp ()
"Return the absolute path to lua-language-server."
(let ((binary-subdir
(cond (IS-MAC "bin/macOS/")
(IS-LINUX "bin/Linux/")
;; TODO : Forwards or backwards slash for WIN ?
(IS-WINDOWS "bin/Windows/")
;; TODO : Error or empty string here ?
(t ""))))
(concat lua-lsp-dir binary-subdir "lua-language-server")))
(after! lua-mode
(set-eglot-client! 'lua-mode `(,(doom--abs-path-to-lua-lsp) "-E" "-e" "LANG=\"en\"" ,(concat lua-lsp-dir "main.lua"))))
(when (featurep! +lsp)
(add-hook 'lua-mode-local-vars-hook #'lsp!))
;;
;;; Frameworks

View file

@ -353,7 +353,7 @@ relative to `org-directory', unless it is an absolute path."
(defun +org-init-capture-frame-h ()
(add-hook 'org-capture-after-finalize-hook #'+org-capture-cleanup-frame-h)
(defadvice! +org-capture-refile-cleanup-frame (&rest _)
(defadvice! +org-capture-refile-cleanup-frame-a (&rest _)
:after #'org-capture-refile
(+org-capture-cleanup-frame-h))
@ -972,14 +972,14 @@ compelling reason, so..."
:n "zi" #'org-toggle-inline-images
:map org-read-date-minibuffer-local-map
"C-h" (λ! (org-eval-in-calendar '(calendar-backward-day 1)))
"C-l" (λ! (org-eval-in-calendar '(calendar-forward-day 1)))
"C-k" (λ! (org-eval-in-calendar '(calendar-backward-week 1)))
"C-j" (λ! (org-eval-in-calendar '(calendar-forward-week 1)))
"C-S-h" (λ! (org-eval-in-calendar '(calendar-backward-month 1)))
"C-S-l" (λ! (org-eval-in-calendar '(calendar-forward-month 1)))
"C-S-k" (λ! (org-eval-in-calendar '(calendar-backward-year 1)))
"C-S-j" (λ! (org-eval-in-calendar '(calendar-forward-year 1)))))
"C-h" (cmd! (org-eval-in-calendar '(calendar-backward-day 1)))
"C-l" (cmd! (org-eval-in-calendar '(calendar-forward-day 1)))
"C-k" (cmd! (org-eval-in-calendar '(calendar-backward-week 1)))
"C-j" (cmd! (org-eval-in-calendar '(calendar-forward-week 1)))
"C-S-h" (cmd! (org-eval-in-calendar '(calendar-backward-month 1)))
"C-S-l" (cmd! (org-eval-in-calendar '(calendar-forward-month 1)))
"C-S-k" (cmd! (org-eval-in-calendar '(calendar-backward-year 1)))
"C-S-j" (cmd! (org-eval-in-calendar '(calendar-forward-year 1)))))
(use-package! evil-org-agenda

View file

@ -8,4 +8,4 @@
;;;###package multi-term
(setq multi-term-dedicated-window-height 20
multi-term-switch-after-close 'PREVIOUS
multi-term-buffer-name "doom terminal")
multi-term-buffer-name "doom:terminal")

View file

@ -6,7 +6,8 @@
(setq lsp-session-file (concat doom-etc-dir "lsp-session"))
;; Auto-kill LSP server after last workspace buffer is killed.
(setq lsp-keep-workspace-alive nil)
;; Let `flycheck-check-syntax-automatically' determine this.
;; Let `flycheck-check-syntax-automatically' determine this. Will be removed
;; soon: https://github.com/emacs-lsp/lsp-mode/pull/1701/files
(setq lsp-flycheck-live-reporting nil)
;; For `lsp-clients'
(setq lsp-server-install-dir (concat doom-etc-dir "lsp/")

View file

@ -7,9 +7,9 @@
(map! :after terraform-mode
:map terraform-mode-map
:localleader
:desc "terraform apply" "a" (λ! (compile "terraform apply" t))
:desc "terraform init" "i" (λ! (compile "terraform init"))
:desc "terraform plan" "p" (λ! (compile "terraform plan")))
:desc "terraform apply" "a" (cmd! (compile "terraform apply" t))
:desc "terraform init" "i" (cmd! (compile "terraform init"))
:desc "terraform plan" "p" (cmd! (compile "terraform plan")))
(use-package! company-terraform

View file

@ -230,7 +230,7 @@ the command buffer."
(after! org
;; Org has a scorched-earth window management policy I'm not fond of. i.e. it
;; kills all other windows just so it can monopolize the frame. No thanks. We
;; can do better ourselves.
;; can do better.
(defadvice! +popup--suppress-delete-other-windows-a (orig-fn &rest args)
:around '(org-add-log-note
org-capture-place-template

View file

@ -49,7 +49,6 @@
'org-todo-keyword-outd
'org-todo
'org-done
'org-indent
'font-lock-comment-face
'line-number
'line-number-current-line))