dev: merge branch 'master'

This commit is contained in:
Matt Nish-Lapidus 2024-07-30 10:29:35 -04:00
commit c6e7dff916
10 changed files with 84 additions and 21 deletions

View file

@ -413,6 +413,7 @@
:desc "Create workspace" "c" #'+workspace/new
:desc "Create named workspace" "C" #'+workspace/new-named
:desc "Delete workspace" "k" #'+workspace/kill
:desc "Delete saved workspace" "K" #'+workspace/delete
:desc "Save workspace" "S" #'+workspace/save
:desc "Switch to other workspace" "o" #'+workspace/other
:desc "Switch to left workspace" "p" #'+workspace/switch-left

View file

@ -382,6 +382,7 @@
:desc "Save workspace to file" "s" #'+workspace/save
:desc "Kill session" "x" #'+workspace/kill-session
:desc "Kill this workspace" "d" #'+workspace/kill
:desc "Delete saved workspace" "D" #'+workspace/delete
:desc "Rename workspace" "r" #'+workspace/rename
:desc "Restore last session" "R" #'+workspace/restore-last-session
:desc "Next workspace" "]" #'+workspace/switch-right

View file

@ -39,11 +39,16 @@ replacing its contents."
(let ((evil-kill-on-visual-paste (not evil-kill-on-visual-paste)))
(call-interactively #'evil-paste-after)))
(defun +evil--window-swap (direction)
(defun +evil--window-swap (direction &optional invert-wrap?)
"Move current window to the next window in DIRECTION.
If there are no windows there and there is only one window, split in that
direction and place this window there. If there are no windows and this isn't
the only window, use evil-window-move-* (e.g. `evil-window-move-far-left')."
the only window, uses evil-window-move-* (e.g. `evil-window-move-far-left').
If already at the edge of the frame and `+evil-want-move-window-to-wrap-around'
is non-nil, move the window to the other end of the frame. Inverts
`+evil-want-move-window-to-wrap-around' if INVERT-WRAP? is non-nil."
(unless (memq direction '(left right up down))
(user-error "Invalid direction: %s" direction))
(when (window-dedicated-p)
@ -61,7 +66,14 @@ the only window, use evil-window-move-* (e.g. `evil-window-move-far-left')."
'(up down) '(left right))
if (window-in-direction dir nil this-window)
return t)))
(user-error "Window is already at the edge")
(if (funcall (if invert-wrap? #'not #'identity) +evil-want-move-window-to-wrap-around)
(call-interactively
(pcase direction
('left #'evil-window-move-far-right)
('right #'evil-window-move-far-left)
('up #'evil-window-move-very-bottom)
('down #'evil-window-move-very-top)))
(user-error "Window is already at the edge"))
(call-interactively
(pcase direction
('left #'evil-window-move-far-left)
@ -77,21 +89,25 @@ the only window, use evil-window-move-* (e.g. `evil-window-move-far-left')."
(select-window that-window))))
;;;###autoload
(defun +evil/window-move-left ()
(defun +evil/window-move-left (&optional arg)
"Swap windows to the left."
(interactive) (+evil--window-swap 'left))
(interactive "P")
(+evil--window-swap 'left (or arg +evil-want-move-window-to-wrap-around)))
;;;###autoload
(defun +evil/window-move-right ()
(defun +evil/window-move-right (&optional arg)
"Swap windows to the right"
(interactive) (+evil--window-swap 'right))
(interactive "P")
(+evil--window-swap 'right (or arg +evil-want-move-window-to-wrap-around)))
;;;###autoload
(defun +evil/window-move-up ()
(defun +evil/window-move-up (&optional arg)
"Swap windows upward."
(interactive) (+evil--window-swap 'up))
(interactive "P")
(+evil--window-swap 'up (or arg +evil-want-move-window-to-wrap-around)))
;;;###autoload
(defun +evil/window-move-down ()
(defun +evil/window-move-down (&optional arg)
"Swap windows downward."
(interactive) (+evil--window-swap 'down))
(interactive "P")
(+evil--window-swap 'down (or arg +evil-want-move-window-to-wrap-around)))
;;;###autoload
(defun +evil/window-split-and-follow ()

View file

@ -12,6 +12,9 @@ Set this to `nil' to disable universal-repeating on these keys.")
"If non-nil, the o/O keys will continue comment lines if the point is on a
line with a linewise comment.")
(defvar +evil-want-move-window-to-wrap-around nil
"If non-nil, `+evil/window-move-*' commands will wrap around.")
(defvar +evil-preprocessor-regexp "^\\s-*#[a-zA-Z0-9_]"
"The regexp used by `+evil/next-preproc-directive' and
`+evil/previous-preproc-directive' on ]# and [#, to jump between preprocessor

View file

@ -44,6 +44,8 @@ This is controlled by `+format-on-save-disabled-modes'."
(add-to-list 'doom-debug-variables '(apheleia-log-only-errors . nil))
(add-to-list 'doom-debug-variables '(apheleia-log-debug-info . t))
(add-to-list 'apheleia-mode-alist '(sh-mode . shfmt))
;; A psuedo-formatter that dispatches to the appropriate LSP client (via
;; `lsp-mode' or `eglot') that is capable of formatting. Without +lsp, users
;; must manually set `+format-with' to `lsp' to use it, or activate

View file

@ -235,7 +235,6 @@ They are (with examples):
- ~wolfram:sin(x^3)~
- ~wikipedia:Emacs~
- ~youtube:P196hEuA_Xc~ (link only)
- ~yt:P196hEuA_Xc~ (like =youtube=, but includes an inline preview of the video)
** evil-mode keybindings
For =evil-mode= users, an overview of org-mode keybindings is provided [[https://github.com/Somelauw/evil-org-mode/blob/master/README.org#keybindings][here]].

View file

@ -64,7 +64,7 @@
(when (modulep! :editor evil +everywhere)
(package! evil-org
:recipe (:host github :repo "doomelpa/evil-org-mode")
:pin "a9706da260c45b98601bcd72b1d2c0a24a017700"))
:pin "06518c65ff4f7aea2ea51149d701549dcbccce5d"))
(when (modulep! :tools pdf)
(package! org-pdftools :pin "4e420233a153a9c4ab3d1a7e1d7d3211c836f0ac"))
(when (modulep! :tools magit)

View file

@ -18,10 +18,6 @@
:config
(set-docsets! 'sh-mode "Bash")
(set-electric! 'sh-mode :words '("else" "elif" "fi" "done" "then" "do" "esac" ";;"))
(set-formatter! 'shfmt '("shfmt" "-ci"
(unless indent-tabs-mode
(list "-i" (number-to-string tab-width)))))
(set-repl-handler! 'sh-mode #'+sh/open-repl)
(set-lookup-handlers! 'sh-mode :documentation #'+sh-lookup-documentation-handler)
(set-ligatures! 'sh-mode

View file

@ -43,10 +43,20 @@ Can be a list of backends; accepts any value `company-backends' accepts.")
(when (modulep! :config default +bindings)
(setq lsp-keymap-prefix nil))
;; REVIEW: Remove when zigtools/zls#1879 is resolved.
(after! lsp-zig
(unless (featurep :system 'windows)
(setq lsp-zig-download-url-format "https://github.com/zigtools/zls/releases/latest/download/zls-%s-%s.tar.xz")))
(unless (featurep :system 'windows)
;; HACK: Frustratingly enough, the value of `lsp-zig-download-url-format' is
;; used immediately while the lsp-zig package is loading, so changing it
;; *after* lsp-zig makes no difference. What's worse, the variable is a
;; constant, so we can't change it *before* the package is loaded either!
;; Thank god a (non-inlined) function is used to build the URL, so we have
;; something to advise.
;; REVIEW: Remove when zigtools/zls#1879 is resolved.
(defadvice! +lsp--use-correct-zls-download-url-a (fn &rest args)
"See zigtools/zls#1879."
:around #'lsp-zig--zls-url
(let ((lsp-zig-download-url-format
"https://github.com/zigtools/zls/releases/latest/download/zls-%s-%s.tar.xz"))
(apply fn args))))
:config
(add-to-list 'doom-debug-variables 'lsp-log-io)

View file

@ -122,6 +122,24 @@ Returns t on success, nil otherwise."
(and (member name (persp-list-persp-names-in-file fname))
t)))
;;;###autoload
(defun +workspace-delete (workspace)
"Delete WORKSPACE from the saved workspaces in `persp-save-dir'.
Return t if WORKSPACE was successfully deleted. Throws error if WORKSPACE is not
found or wasn't saved with `+workspace-save'."
(let* ((fname (expand-file-name +workspaces-data-file persp-save-dir))
(workspace-name (if (stringp workspace) workspace (persp-name workspace)))
(workspace-names (persp-list-persp-names-in-file fname))
(workspace-idx (cl-position workspace-name workspace-names :test #'equal)))
(unless workspace-idx
(error "Couldn't find saved workspace '%s'" workspace-name))
(doom-file-write
fname (list (cl-remove-if (lambda (ws) (equal workspace-name (nth 1 ws)))
(doom-file-read fname :by 'read)
:count 1)))
(not (member name (persp-list-persp-names-in-file fname)))))
;;;###autoload
(defun +workspace-new (name)
"Create a new workspace named NAME. If one already exists, return nil.
@ -267,6 +285,23 @@ workspace to delete."
(+workspace-message (format "Deleted '%s' workspace" name) 'success)))
('error (+workspace-error ex t))))
;;;###autoload
(defun +workspace/delete (name)
"Delete a saved workspace in `persp-save-dir'.
Can only selete workspaces saved with `+workspace/save' or `+workspace-save'."
(interactive
(list
(completing-read "Delete saved workspace: "
(cl-loop with wsfile = (doom-path persp-save-dir +workspaces-data-file)
for p in (persp-list-persp-names-in-file wsfile)
collect p))))
(and (condition-case-unless-debug ex
(or (+workspace-delete name)
(+workspace-error (format "Couldn't delete '%s' workspace" name)))
('error (+workspace-error ex t)))
(+workspace-message (format "Deleted '%s' workspace" name) 'success)))
;;;###autoload
(defun +workspace/kill-session (&optional interactive)
"Delete the current session, all workspaces, windows and their buffers."