nvim在性能上比用overlay的emacs好很多。magit的blame显示总是有点卡,而且不直观。虽然也可以像gitsigns一样显示,但是没有gitsigns显示得好。
2 个赞
第一张图是调用什么命令显示出来的啊,默认是在当前行右边显示吧
Gitsigns show 刚刚找出来了
试试 GitHub - redguardtoo/vc-msg: Show commit message of current line in Emacs, 除了显示当前行谁改的,还可以显示当前行中选定的代码文本是谁改的.
1 个赞
大佬,你的vc-msg在用啊。用posframe显示了。
(use-package vc-msg
:defer t
:config
(with-no-warnings
(with-eval-after-load 'hydra
(defhydra vc-msg-show-hydra (:color blue)
("s" vc-msg-git-show-code "show")
("c" (vc-msg-git-copy-info :id) "copy hash")
("e" (vc-msg-git-copy-info :summary) "copy message")
("m" (let* ((info vc-msg-previous-commit-info))
(funcall 'magit-find-file
(plist-get info :id)
(concat (vc-msg-sdk-git-rootdir)
(plist-get info :filename)))) "magit-find-file")
("q" vc-msg-close "quit")
))
(setq vc-msg-force-vcs "git")
(setq vc-msg-copy-id-to-kill-ring nil)
(defun my-vc-msg-git-format (info)
"Format the message for popup from INFO.
From git-messenger."
(let* ((author (plist-get info :author)))
(cond
((string-match-p "Not Committed Yet" author)
"* Not Committed Yet*")
(t
(format "%s\n%s%s\n%s%s\n%s%s %s\n%s\n%s\n%s"
(propertize "* vc-msg *" 'face 'font-lock-comment-face)
(propertize "Commit: " 'face 'font-lock-keyword-face)
(propertize (vc-msg-sdk-short-id (plist-get info :id)) 'face 'font-lock-comment-face)
(propertize "Author: " 'face 'font-lock-keyword-face)
(propertize author 'face 'font-lock-string-face)
(propertize "Date : " 'face 'font-lock-keyword-face)
(propertize (vc-msg-sdk-format-datetime (plist-get info :author-time)) 'face 'font-lock-string-face)
(plist-get info :author-tz)
(propertize (make-string 38 ?─) 'face 'font-lock-comment-face)
(plist-get info :summary)
(propertize "\nPress q to quit" 'face '(:inherit (font-lock-comment-face italic))))
))))
(defun my-vc-msg-show ()
"Show commit message of current line.
If Git is used and some text inside the line is selected,
the correct commit which submits the selected text is displayed."
(interactive)
(let* (finish
(plugin (vc-msg-find-plugin))
(current-file (funcall vc-msg-get-current-file-function)))
(if plugin
(let* ((hydra-hint-display-type 'message)
(executer (plist-get plugin :execute))
(formatter (plist-get plugin :format))
(commit-info (and current-file
(funcall executer
current-file
(funcall vc-msg-get-line-num-function)
(funcall vc-msg-get-version-function))))
message
)
(cond
((and commit-info (listp commit-info))
;; the message to display
(setq message (funcall formatter commit-info))
(setq vc-msg-previous-commit-info commit-info)
;; copy the commit it/hash/changelist
(when vc-msg-copy-id-to-kill-ring
(let* ((id (vc-msg-get-friendly-id plugin commit-info)))
(kill-new id)
(message "%s => kill-ring" id)))
(vc-msg-show-hydra/body)
(let* ((popuped-message (vc-msg-clean message)))
(cond ((and (fboundp 'posframe-workable-p) (posframe-workable-p))
(let ((buffer-name "*my-vc-msg-show*"))
(posframe-show buffer-name
:string (concat (propertize "\n" 'face '(:height 0.3))
popuped-message
"\n"
(propertize "\n" 'face '(:height 0.3)))
:left-fringe 8
:right-fringe 8
:max-width (round (* (frame-width) 0.62))
:max-height (round (* (frame-height) 0.62))
:internal-border-width 1
:internal-border-color "#61AFEF"
:background-color (face-background 'tooltip nil t))
(unwind-protect
(push (read-event) unread-command-events)
(posframe-hide buffer-name))))
((and (fboundp 'pos-tip-show) (display-graphic-p))
(pos-tip-show popuped-message))
((fboundp 'lv-message)
(lv-message popuped-message)
(unwind-protect
(push (read-event) unread-command-events)
(lv-delete-window)))
(t (message "%s" popuped-message))))
(run-hook-with-args 'vc-msg-hook (vc-msg-detect-vcs-type) commit-info))
((stringp commit-info)
;; Failed. Show the reason.
(kill-new commit-info)
(message commit-info))
(t
;; Failed for unknown reason
(message "Shell command failed.")))
))))
(advice-add #'vc-msg-close :override #'ignore)
(advice-add #'vc-msg-git-format :override #'my-vc-msg-git-format)
(advice-add #'vc-msg-show :override #'my-vc-msg-show)
))
1 个赞
你要不要试试这个??
将文件中具有相同的 commit 所有行高亮起来
2 个赞
刚刚尝试了一下,一个小建议,头部的 Package-Requires
依赖可以加上 async
,这样 straight
就可以识别到 async 依赖了
(工作环境,不好提PR )
例如这样:
;; Package-Requires: ((emacs "24.2") (async "1.8"))
nvim愿意写插件的人数恐怕比emacs多两个数量级, 就一个TUI, 很多设置都有默认约定, 总的风格比较一致. emacs环境更复杂,风格也更多变,更关键的是很多东西就没有共识, 能找到个可用的包就不错了.
1 个赞