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,9 +22,6 @@ Returns (approximately):
This is used by `file-exists-p!' and `project-file-exists-p!'." This is used by `file-exists-p!' and `project-file-exists-p!'."
(declare (pure t) (side-effect-free t)) (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) (if (and (listp spec)
(memq (car spec) '(or and))) (memq (car spec) '(or and)))
(cons (car spec) (cons (car spec)
@ -36,9 +33,9 @@ This is used by `file-exists-p!' and `project-file-exists-p!'."
(and (stringp ,filevar) (and (stringp ,filevar)
,(if directory ,(if directory
`(let ((default-directory ,directory)) `(let ((default-directory ,directory))
(,exists-fn ,filevar)) (file-exists-p ,filevar))
(list exists-fn filevar)) `(file-exists-p ,filevar))
,filevar)))))) ,filevar)))))
(defun doom--path (&rest segments) (defun doom--path (&rest segments)
(let (file-name-handler-alist) (let (file-name-handler-alist)

View file

@ -216,8 +216,8 @@ localleader prefix."
For example, :nvi will map to (list 'normal 'visual 'insert). See For example, :nvi will map to (list 'normal 'visual 'insert). See
`doom-evil-state-alist' to customize this." `doom-evil-state-alist' to customize this."
(cl-loop for l across (substring (symbol-name keyword) 1) (cl-loop for l across (doom-keyword-name keyword)
if (cdr (assq l doom-evil-state-alist)) collect it if (assq l doom-evil-state-alist) collect (cdr it)
else do (error "not a valid state: %s" l))) 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))) (rest (cdr binding)))
(setq (setq
body (pcase type 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))) (`defun `(cl-letf* ((,(car rest) (symbol-function #',(car rest)))
((symbol-function #',(car rest)) ((symbol-function #',(car rest))
(lambda ,(cadr rest) ,@(cddr rest)))) (lambda ,(cadr rest) ,@(cddr rest))))

View file

@ -109,9 +109,7 @@ uses a straight or package.el command directly).")
;; ;;
;;; Bootstrappers ;;; Bootstrappers
(defun doom--ensure-straight () (defun doom--ensure-straight (recipe pin)
(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")) (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el"))
(repo-url (concat "http" (if gnutls-verify-error "s") (repo-url (concat "http" (if gnutls-verify-error "s")
"://github.com/" "://github.com/"
@ -143,11 +141,11 @@ uses a straight or package.el command directly).")
;; Don't install straight for us -- we've already done that -- only set ;; Don't install straight for us -- we've already done that -- only set
;; up its recipe repos for us. ;; up its recipe repos for us.
(eval-region (search-forward "(require 'straight)") (eval-region (search-forward "(require 'straight)")
(point-max)))))) (point-max)))))
(defun doom--ensure-core-packages () (defun doom--ensure-core-packages (packages)
(doom-log "Installing core packages") (doom-log "Installing core packages")
(dolist (package doom-packages) (dolist (package packages)
(let ((name (car package))) (let ((name (car package)))
(when-let (recipe (plist-get (cdr package) :recipe)) (when-let (recipe (plist-get (cdr package) :recipe))
(straight-override-recipe (cons name 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." "Ensure `straight' is installed and was compiled with this version of Emacs."
(when (or force-p (null (bound-and-true-p straight-recipe-repositories))) (when (or force-p (null (bound-and-true-p straight-recipe-repositories)))
(doom-log "Initializing straight") (doom-log "Initializing straight")
(let ((doom-packages (doom-package-list nil 'core-only))) (let ((packages (doom-package-list nil 'core)))
(doom--ensure-straight) (cl-destructuring-bind (&key recipe pin &allow-other-keys)
(doom--ensure-core-packages)))) (alist-get 'straight packages)
(doom--ensure-straight recipe pin))
(doom--ensure-core-packages packages))))
(defun doom-initialize-packages (&optional force-p) (defun doom-initialize-packages (&optional force-p)
"Process all packages, essential and otherwise, if they haven't already been. "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 (use-package! flyspell-correct
:commands flyspell-correct-at-point flyspell-correct-previous :commands flyspell-correct-previous
:general ([remap ispell-word] #'flyspell-correct-at-point) :general ([remap ispell-word] #'flyspell-correct-at-point)
:config :config
(cond ((and (featurep! :completion helm) (cond ((and (featurep! :completion helm)

View file

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

View file

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

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 info-lookup-symbol] #'counsel-info-lookup-symbol
[remap load-theme] #'counsel-load-theme [remap load-theme] #'counsel-load-theme
[remap locate] #'counsel-locate [remap locate] #'counsel-locate
[remap org-goto] #'counsel-org-goto
[remap org-set-tags-command] #'counsel-org-tag [remap org-set-tags-command] #'counsel-org-tag
[remap projectile-compile-project] #'+ivy/project-compile [remap projectile-compile-project] #'+ivy/project-compile
[remap recentf-open-files] #'counsel-recentf [remap recentf-open-files] #'counsel-recentf

View file

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

View file

@ -209,7 +209,7 @@
(map! :map markdown-mode-map (map! :map markdown-mode-map
:ig "*" (general-predicate-dispatch nil :ig "*" (general-predicate-dispatch nil
(looking-at-p "\\*\\* *") (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 "s--" #'doom/decrease-font-size
;; Conventional text-editing keys & motions ;; Conventional text-editing keys & motions
"s-a" #'mark-whole-buffer "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 :n "s-/" #'evilnc-comment-or-uncomment-lines
:v "s-/" #'evilnc-comment-operator :v "s-/" #'evilnc-comment-operator
:gi [s-backspace] #'doom/backward-kill-to-bol-and-indent :gi [s-backspace] #'doom/backward-kill-to-bol-and-indent

View file

@ -552,13 +552,13 @@ To change these keys see `+evil-repeat-keys'."
"a" (evilem-create #'evil-forward-arg) "a" (evilem-create #'evil-forward-arg)
"A" (evilem-create #'evil-backward-arg) "A" (evilem-create #'evil-backward-arg)
"s" #'evil-avy-goto-char-2 "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-avy-goto-char-timer))
;; evil-snipe ;; evil-snipe
(:after evil-snipe (:after evil-snipe
:map evil-snipe-parent-transient-map :map evil-snipe-parent-transient-map
"C-;" (λ! (require 'evil-easymotion) "C-;" (cmd! (require 'evil-easymotion)
(call-interactively (call-interactively
(evilem-create #'evil-snipe-repeat (evilem-create #'evil-snipe-repeat
:bind ((evil-snipe-scope 'whole-buffer) :bind ((evil-snipe-scope 'whole-buffer)

View file

@ -107,7 +107,7 @@ information.")
;; ;;
;; Library ;;; Library
(defun +file-templates-in-emacs-dirs-p (file) (defun +file-templates-in-emacs-dirs-p (file)
"Returns t if FILE is in Doom or your private directory." "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) (when (and (bound-and-true-p flycheck-mode)
(eq major-mode 'emacs-lisp-mode) (eq major-mode 'emacs-lisp-mode)
(or (not buffer-file-name) (or (not buffer-file-name)
(cl-loop for dir in (list doom-emacs-dir doom-private-dir) (cl-find-if (doom-partial #'file-in-directory-p buffer-file-name)
if (file-in-directory-p buffer-file-name dir) +emacs-lisp-disable-flycheck-in-dirs)))
return t)))
(add-to-list (make-local-variable 'flycheck-disabled-checkers) (add-to-list (make-local-variable 'flycheck-disabled-checkers)
'emacs-lisp-checkdoc) 'emacs-lisp-checkdoc)
(set (make-local-variable 'flycheck-emacs-lisp-check-form) (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'. "Regexp to use for `outline-regexp' in `emacs-lisp-mode'.
This marks a foldable marker for `outline-minor-mode' in elisp buffers.") 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 ;; `elisp-mode' is loaded at startup. In order to lazy load its config we need
;; to pretend it isn't loaded ;; to pretend it isn't loaded

View file

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

View file

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

View file

@ -53,4 +53,4 @@
(define-key! doc-view-mode-map (define-key! doc-view-mode-map
"ESC" #'delete-window "ESC" #'delete-window
"q" #'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; -*- ;;; 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 ;; sp's default rules are obnoxious, so disable them
(provide 'smartparens-lua) (provide 'smartparens-lua)
@ -16,7 +22,23 @@
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation) (set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
(set-electric! 'lua-mode :words '("else" "end")) (set-electric! 'lua-mode :words '("else" "end"))
(set-repl-handler! 'lua-mode #'+lua/open-repl) (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 (use-package! moonscript
@ -31,32 +53,6 @@
(when (featurep! :checkers syntax) (when (featurep! :checkers syntax)
(require 'flycheck-moonscript nil t))) (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 ;;; Frameworks

View file

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

View file

@ -8,4 +8,4 @@
;;;###package multi-term ;;;###package multi-term
(setq multi-term-dedicated-window-height 20 (setq multi-term-dedicated-window-height 20
multi-term-switch-after-close 'PREVIOUS 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")) (setq lsp-session-file (concat doom-etc-dir "lsp-session"))
;; Auto-kill LSP server after last workspace buffer is killed. ;; Auto-kill LSP server after last workspace buffer is killed.
(setq lsp-keep-workspace-alive nil) (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) (setq lsp-flycheck-live-reporting nil)
;; For `lsp-clients' ;; For `lsp-clients'
(setq lsp-server-install-dir (concat doom-etc-dir "lsp/") (setq lsp-server-install-dir (concat doom-etc-dir "lsp/")

View file

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

View file

@ -230,7 +230,7 @@ the command buffer."
(after! org (after! org
;; Org has a scorched-earth window management policy I'm not fond of. i.e. it ;; 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 ;; 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) (defadvice! +popup--suppress-delete-other-windows-a (orig-fn &rest args)
:around '(org-add-log-note :around '(org-add-log-note
org-capture-place-template org-capture-place-template

View file

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