feat(emacs): Small repl things
This commit is contained in:
@@ -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)
|
||||
|
||||
(comment
|
||||
"For demonstration:"
|
||||
(setq syd-strat--strategies
|
||||
'((:documentation syd-emacs-lisp-lookup-documentation)
|
||||
(:definition evil-goto-definition))))
|
||||
|
||||
;; :documentation : Identifier -> Marker
|
||||
(defvar-local syd-strat--strategies nil)
|
||||
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
;;; 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
|
||||
:mode "\\.nix\\'"
|
||||
:init
|
||||
(add-to-list 'auto-mode-alist
|
||||
(cons (rx "/flake.lock'")
|
||||
(if (fboundp 'json-mode)
|
||||
'json-mode
|
||||
'js-mode)))
|
||||
: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)
|
||||
|
||||
@@ -183,12 +183,14 @@
|
||||
:states 'insert
|
||||
"C-d" #'syd-eshell-C-d)
|
||||
(:keymaps 'eshell-mode-map
|
||||
:states '(normal insert)
|
||||
:states 'motion
|
||||
"[ [" #'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-k" #'eshell-previous-matching-input-from-input)
|
||||
|
||||
"C-k" #'eshell-previous-matching-input-from-input
|
||||
"C-s" #'eshell-isearch-backward)
|
||||
:config
|
||||
;; When cd'd into a TRAMP remote, automatically expand '/' to the TRAMP
|
||||
;; notation referring to the remote's root.
|
||||
|
||||
@@ -90,23 +90,67 @@
|
||||
(scroll-bar-mode -1)
|
||||
(tool-bar-mode -1))
|
||||
|
||||
(use-package persp-mode
|
||||
:disabled
|
||||
:unless noninteractive
|
||||
:commands persp-switch-to-buffer
|
||||
:hook (on-init-ui-hook . persp-mode)
|
||||
:config
|
||||
(setq persp-autokill-buffer-on-remove 'kill-weak
|
||||
persp-reset-windows-on-nil-window-conf nil
|
||||
persp-nil-hidden t
|
||||
persp-auto-save-fname "autosave"
|
||||
persp-save-dir (concat syd-data-dir "workspaces/")
|
||||
persp-set-last-persp-for-new-frames t
|
||||
persp-switch-to-added-buffer nil
|
||||
persp-kill-foreign-buffer-behaviour 'kill
|
||||
persp-remove-buffers-from-nil-persp-behaviour nil
|
||||
persp-auto-resume-time -1 ; Don't auto-load on startup
|
||||
persp-auto-save-opt (if noninteractive 0 1)))
|
||||
(defun syd-init-kill-comint-on-exit ()
|
||||
(defun syd-comint--kill-buffer-sentinel (process output)
|
||||
"Process sentinel to auto kill associated buffer once PROCESS dies."
|
||||
(unless (process-live-p process)
|
||||
(kill-buffer (process-buffer process))))
|
||||
|
||||
(defun syd-comint--add-kill-on-exit-sentinel ()
|
||||
"Replace current process sentinel with a new sentinel composed of the
|
||||
current one and `syd-comint--kill-buffer-sentinel'."
|
||||
(let* ((process (get-buffer-process (current-buffer)))
|
||||
(og-sentinel (process-sentinel process))
|
||||
(sentinel-list
|
||||
(-remove #'null
|
||||
(list og-sentinel #'syd-comint--kill-buffer-sentinel)))
|
||||
(combined-sentinel
|
||||
(lambda (process line)
|
||||
(--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
|
||||
(defun syd-init-ui-hacks ()
|
||||
|
||||
Reference in New Issue
Block a user