feat(emacs): Small repl things
This commit is contained in:
@@ -185,6 +185,12 @@ Used as a server admin account with little configuration.
|
|||||||
|
|
||||||
*** TODO [#A] [[id:6141dc5c-2232-4bc0-9464-410c21135c86][Strategies]]
|
*** TODO [#A] [[id:6141dc5c-2232-4bc0-9464-410c21135c86][Strategies]]
|
||||||
|
|
||||||
|
*** TODO When visiting a package, set read-only mode by default
|
||||||
|
|
||||||
|
*** TODO Evil ~:rxs~ command
|
||||||
|
|
||||||
|
Like ~:s~, but uses the ~rx~ macro.
|
||||||
|
|
||||||
*** TODO Completions w/ [[https://github.com/minad/corfu][Corfu]]
|
*** TODO Completions w/ [[https://github.com/minad/corfu][Corfu]]
|
||||||
|
|
||||||
*** TODO Overlay org-mode links with the domain name
|
*** TODO Overlay org-mode links with the domain name
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
;; syd-strategies-repl.el -*- lexical-binding: t; -*-
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(define-minor-mode syd-repl-mode
|
|
||||||
"A minor mode for repl buffers. One use is to universally customise the
|
|
||||||
display of all repl buffers.")
|
|
||||||
|
|
||||||
(provide 'syd-strategies-repl)
|
|
||||||
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
(require 'syd-text)
|
(require 'syd-text)
|
||||||
|
|
||||||
|
(comment
|
||||||
|
"For demonstration:"
|
||||||
|
(setq syd-strat--strategies
|
||||||
|
'((:documentation syd-emacs-lisp-lookup-documentation)
|
||||||
|
(:definition evil-goto-definition))))
|
||||||
|
|
||||||
;; :documentation : Identifier -> Marker
|
;; :documentation : Identifier -> Marker
|
||||||
(defvar-local syd-strat--strategies nil)
|
(defvar-local syd-strat--strategies nil)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,29 @@
|
|||||||
;;; syd-lang-nix.el -*- lexical-binding: t; -*-
|
;;; syd-lang-nix.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(require 'syd-handle-repl)
|
||||||
|
(require 'syd-handle-lookup)
|
||||||
|
|
||||||
|
(defun syd-nix-open-nix-repl ()
|
||||||
|
(interactive)
|
||||||
|
;; If possible, cd to the project root. Flakes force you to use relative
|
||||||
|
;; paths, which can be annoying in combination with
|
||||||
|
;;
|
||||||
|
;; REVIEW: Should this be something handled by `syd--call-repl-handler'?
|
||||||
|
(-some-> (syd-project-root) cd)
|
||||||
|
(nix-repl)
|
||||||
|
(current-buffer))
|
||||||
|
|
||||||
(use-package nix-mode
|
(use-package nix-mode
|
||||||
:mode "\\.nix\\'"
|
:mode "\\.nix\\'"
|
||||||
|
:init
|
||||||
|
(add-to-list 'auto-mode-alist
|
||||||
|
(cons (rx "/flake.lock'")
|
||||||
|
(if (fboundp 'json-mode)
|
||||||
|
'json-mode
|
||||||
|
'js-mode)))
|
||||||
:config
|
:config
|
||||||
(add-hook 'nix-mode-hook #'lsp))
|
(add-hook 'nix-mode-hook #'lsp)
|
||||||
|
(set-popup-rule! "^\\*nixos-options-doc\\*$" :ttl 0 :quit t)
|
||||||
|
(set-repl-handler! 'nix-mode #'syd-nix-open-nix-repl))
|
||||||
|
|
||||||
(provide 'syd-lang-nix)
|
(provide 'syd-lang-nix)
|
||||||
|
|||||||
@@ -183,12 +183,14 @@
|
|||||||
:states 'insert
|
:states 'insert
|
||||||
"C-d" #'syd-eshell-C-d)
|
"C-d" #'syd-eshell-C-d)
|
||||||
(:keymaps 'eshell-mode-map
|
(:keymaps 'eshell-mode-map
|
||||||
:states '(normal insert)
|
:states 'motion
|
||||||
"[ [" #'eshell-previous-prompt
|
"[ [" #'eshell-previous-prompt
|
||||||
"] ]" #'eshell-next-prompt
|
"] ]" #'eshell-next-prompt)
|
||||||
|
(:keymaps 'eshell-mode-map
|
||||||
|
:states '(normal insert)
|
||||||
"C-j" #'eshell-next-matching-input-from-input
|
"C-j" #'eshell-next-matching-input-from-input
|
||||||
"C-k" #'eshell-previous-matching-input-from-input)
|
"C-k" #'eshell-previous-matching-input-from-input
|
||||||
|
"C-s" #'eshell-isearch-backward)
|
||||||
:config
|
:config
|
||||||
;; When cd'd into a TRAMP remote, automatically expand '/' to the TRAMP
|
;; When cd'd into a TRAMP remote, automatically expand '/' to the TRAMP
|
||||||
;; notation referring to the remote's root.
|
;; notation referring to the remote's root.
|
||||||
|
|||||||
@@ -90,23 +90,67 @@
|
|||||||
(scroll-bar-mode -1)
|
(scroll-bar-mode -1)
|
||||||
(tool-bar-mode -1))
|
(tool-bar-mode -1))
|
||||||
|
|
||||||
(use-package persp-mode
|
(defun syd-init-kill-comint-on-exit ()
|
||||||
:disabled
|
(defun syd-comint--kill-buffer-sentinel (process output)
|
||||||
:unless noninteractive
|
"Process sentinel to auto kill associated buffer once PROCESS dies."
|
||||||
:commands persp-switch-to-buffer
|
(unless (process-live-p process)
|
||||||
:hook (on-init-ui-hook . persp-mode)
|
(kill-buffer (process-buffer process))))
|
||||||
:config
|
|
||||||
(setq persp-autokill-buffer-on-remove 'kill-weak
|
(defun syd-comint--add-kill-on-exit-sentinel ()
|
||||||
persp-reset-windows-on-nil-window-conf nil
|
"Replace current process sentinel with a new sentinel composed of the
|
||||||
persp-nil-hidden t
|
current one and `syd-comint--kill-buffer-sentinel'."
|
||||||
persp-auto-save-fname "autosave"
|
(let* ((process (get-buffer-process (current-buffer)))
|
||||||
persp-save-dir (concat syd-data-dir "workspaces/")
|
(og-sentinel (process-sentinel process))
|
||||||
persp-set-last-persp-for-new-frames t
|
(sentinel-list
|
||||||
persp-switch-to-added-buffer nil
|
(-remove #'null
|
||||||
persp-kill-foreign-buffer-behaviour 'kill
|
(list og-sentinel #'syd-comint--kill-buffer-sentinel)))
|
||||||
persp-remove-buffers-from-nil-persp-behaviour nil
|
(combined-sentinel
|
||||||
persp-auto-resume-time -1 ; Don't auto-load on startup
|
(lambda (process line)
|
||||||
persp-auto-save-opt (if noninteractive 0 1)))
|
(--each sentinel-list
|
||||||
|
(funcall it process line)))))
|
||||||
|
(setf (process-sentinel process) combined-sentinel)))
|
||||||
|
|
||||||
|
(defvar syd-comint--kill-on-exit-h-has-run nil
|
||||||
|
"Whether or not `syd-comint--kill-on-exit-h' has run or not. We need this
|
||||||
|
buffer-local var to prevent the hook from running several times, as can happen
|
||||||
|
for example when calling `shell'.")
|
||||||
|
|
||||||
|
(defun syd-comint--async-funcall (fn &optional buffer args delay)
|
||||||
|
"Run FUNCTION with ARGS in the buffer after a short DELAY."
|
||||||
|
(run-at-time (or delay 0.2) nil
|
||||||
|
`(lambda ()
|
||||||
|
(with-current-buffer ,buffer ,(cons fn args)))))
|
||||||
|
|
||||||
|
(syd-add-hook 'comint-mode-hook
|
||||||
|
(defun syd-comint--kill-on-exit-h ()
|
||||||
|
(unless syd-comint--kill-on-exit-h-has-run
|
||||||
|
(setq-local syd-comint--kill-on-exit-h-has-run t)
|
||||||
|
(syd-comint--async-funcall
|
||||||
|
#'syd-comint--add-kill-on-exit-sentinel
|
||||||
|
(current-buffer))))))
|
||||||
|
|
||||||
|
(with-eval-after-load 'comint
|
||||||
|
(custom-theme-set-faces
|
||||||
|
'user
|
||||||
|
;; Default prompt face is very ugly. Give it a more subtle look.
|
||||||
|
(require 'syd-kanagawa)
|
||||||
|
`(comint-highlight-prompt
|
||||||
|
((t :foreground ,(syd-kanagawa-get 'old-white)
|
||||||
|
:background unspecified
|
||||||
|
:weight bold))))
|
||||||
|
|
||||||
|
(syd-init-kill-comint-on-exit)
|
||||||
|
|
||||||
|
(general-def
|
||||||
|
:keymaps 'comint-mode-map
|
||||||
|
:states '(normal insert)
|
||||||
|
"C-k" #'comint-previous-input
|
||||||
|
"C-j" #'comint-next-input
|
||||||
|
"C-s" #'comint-history-isearch-backward)
|
||||||
|
(general-def
|
||||||
|
:keymaps 'comint-mode-map
|
||||||
|
:states 'insert
|
||||||
|
"C-d" #'comint-delchar-or-maybe-eof))
|
||||||
|
|
||||||
(syd-add-hook 'on-init-ui-hook
|
(syd-add-hook 'on-init-ui-hook
|
||||||
(defun syd-init-ui-hacks ()
|
(defun syd-init-ui-hacks ()
|
||||||
|
|||||||
Reference in New Issue
Block a user