mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 03:50:24 +10:00
Updating Doom Emacs.
This commit is contained in:
@@ -88,6 +88,13 @@ There are several ways to manually install the module:
|
||||
1. You can use =M-x vterm-module-compile= to let emacs automatically compile and
|
||||
install the module.
|
||||
|
||||
Modify ~vterm-module-cmake-args~ to pass arguments to the cmake build script.
|
||||
e.g. To use a local build of libvterm instead of the included one.
|
||||
|
||||
#+BEGIN_SRC elisp
|
||||
(setq vterm-module-cmake-args "-DUSE_SYSTEM_LIBVTERM=yes")
|
||||
#+END_SRC
|
||||
|
||||
*WARNING*: Emacs will hang during the compilation. It may take a while.
|
||||
|
||||
2. You can compile and install the module yourself. Go to the vterm installation
|
||||
|
||||
@@ -29,13 +29,12 @@ If prefix ARG is non-nil, recreate vterm buffer in the current project's root."
|
||||
(when (bound-and-true-p evil-local-mode)
|
||||
(evil-change-to-initial-state))
|
||||
(goto-char (point-max)))
|
||||
(require 'vterm)
|
||||
(setenv "PROOT" (or (doom-project-root) default-directory))
|
||||
(let ((buffer (get-buffer-create buffer-name)))
|
||||
(with-current-buffer buffer
|
||||
(doom-mark-buffer-as-real-h)
|
||||
(unless (eq major-mode 'vterm-mode)
|
||||
(vterm-mode)))
|
||||
(vterm-mode))
|
||||
(+vterm--change-directory-if-remote))
|
||||
(pop-to-buffer buffer)))))
|
||||
|
||||
;;;###autoload
|
||||
@@ -50,8 +49,44 @@ If prefix ARG is non-nil, cd into `default-directory' instead of project root."
|
||||
;; This hack forces vterm to redraw, fixing strange artefacting in the tty.
|
||||
(save-window-excursion
|
||||
(pop-to-buffer "*scratch*"))
|
||||
(let ((default-directory
|
||||
(if arg
|
||||
default-directory
|
||||
(or (doom-project-root) default-directory))))
|
||||
(vterm)))
|
||||
(let* ((project-root (or (doom-project-root) default-directory))
|
||||
(default-directory
|
||||
(if arg
|
||||
default-directory
|
||||
project-root))
|
||||
display-buffer-alist)
|
||||
(setenv "PROOT" project-root)
|
||||
(vterm)
|
||||
(+vterm--change-directory-if-remote)))
|
||||
|
||||
(defun +vterm--change-directory-if-remote ()
|
||||
"When `default-directory` is remote, use the corresponding
|
||||
method to prepare vterm at the corresponding remote directory."
|
||||
(when (and (featurep 'tramp)
|
||||
(tramp-tramp-file-p default-directory))
|
||||
(message "default-directory is %s" default-directory)
|
||||
(with-parsed-tramp-file-name default-directory path
|
||||
(let ((method (cadr (assoc `tramp-login-program
|
||||
(assoc path-method tramp-methods)))))
|
||||
(vterm-send-string
|
||||
(concat method " "
|
||||
(when path-user (concat path-user "@")) path-host))
|
||||
(vterm-send-return)
|
||||
(vterm-send-string
|
||||
(concat "cd " path-localname))
|
||||
(vterm-send-return)))))
|
||||
|
||||
|
||||
(defvar +vterm--insert-point nil)
|
||||
|
||||
;;;###autoload
|
||||
(defun +vterm-remember-insert-point-h ()
|
||||
"Remember point when leaving insert mode."
|
||||
(setq-local +vterm--insert-point (point)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vterm-goto-insert-point-h ()
|
||||
"Go to the point we were at when we left insert mode."
|
||||
(when +vterm--insert-point
|
||||
(goto-char +vterm--insert-point)
|
||||
(setq-local +vterm--insert-point nil)))
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
;;; term/vterm/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package! vterm
|
||||
:when module-file-suffix
|
||||
:defer t
|
||||
:preface (setq vterm-install t)
|
||||
:when (bound-and-true-p module-file-suffix)
|
||||
:commands vterm vterm-mode
|
||||
:preface (setq vterm-install t) ; compile the package when you load vterm
|
||||
:hook (vterm-mode . doom-mark-buffer-as-real-h)
|
||||
:hook (vterm-mode . hide-mode-line-mode) ; modeline serves no purpose in vterm
|
||||
:config
|
||||
(set-popup-rule! "^vterm" :size 0.25 :vslot -4 :select t :quit nil :ttl 0)
|
||||
|
||||
(add-hook 'vterm-mode-hook #'doom-mark-buffer-as-real-h)
|
||||
;; Automatically kill buffer when vterm exits.
|
||||
(add-hook! 'vterm-exit-functions
|
||||
(defun +vterm-kill-buffer-on-quit-fn (buffer event)
|
||||
(if buffer (kill-buffer buffer))))
|
||||
;; Modeline serves no purpose in vterm
|
||||
(add-hook 'vterm-mode-hook #'hide-mode-line-mode)
|
||||
;; Don't prompt about processes when killing vterm
|
||||
(setq-hook! 'vterm-mode-hook confirm-kill-processes nil))
|
||||
;; Once vterm is dead, the vterm buffer is useless. Why keep it around? We can
|
||||
;; spawn another if want one.
|
||||
(setq vterm-kill-buffer-on-exit t)
|
||||
|
||||
(setq-hook! 'vterm-mode-hook
|
||||
;; Don't prompt about dying processes when killing vterm
|
||||
confirm-kill-processes nil
|
||||
;; Prevent premature horizontal scrolling
|
||||
hscroll-margin 0)
|
||||
|
||||
;; Restore the point's location when leaving and re-entering insert mode.
|
||||
(when (featurep! :editor evil)
|
||||
(add-hook! 'vterm-mode-hook
|
||||
(defun +vterm-init-remember-point-h ()
|
||||
(add-hook 'evil-insert-state-exit-hook #'+vterm-remember-insert-point-h nil t)
|
||||
(add-hook 'evil-insert-state-entry-hook #'+vterm-goto-insert-point-h nil t)))))
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; term/vterm/packages.el
|
||||
|
||||
(package! vterm :built-in 'prefer)
|
||||
(package! vterm
|
||||
:built-in 'prefer
|
||||
:pin "422ffe029b92c47e4acf0e2ed06cbc83636d7e44")
|
||||
|
||||
Reference in New Issue
Block a user